Index: branches/5.2.x/tools/class_locator.php =================================================================== diff -u -r16376 -r16792 --- branches/5.2.x/tools/class_locator.php (.../class_locator.php) (revision 16376) +++ branches/5.2.x/tools/class_locator.php (.../class_locator.php) (revision 16792) @@ -1,6 +1,6 @@ Init(); -/** @var \Composer\Autoload\ClassLoader $composer_class_loader */ +/** @var ClassLoader $composer_class_loader */ $composer_class_loader = require FULL_PATH . '/vendor/autoload.php'; return function ($class) use ($application, $composer_class_loader) { + // 1. Search for class within In-Portal. $file = $application->findClassFile($class); if ( $file !== false ) { return $file; } - return $composer_class_loader->findFile($class); + // 2. Search for class within Composer + register custom autoloaders. + $file = $composer_class_loader->findFile($class); + + if ( $file !== false ) { + return $file; + } + + // 3. Use custom autoloaders. + $dynamic_autoloader_namespaces = array( + 'ConsoleHelpers\\PHPUnitCompat\\', + 'Yoast\\PHPUnitPolyfills\\', + ); + + foreach ( $dynamic_autoloader_namespaces as $dynamic_autoloader_namespace ) { + if ( strpos($class, $dynamic_autoloader_namespace) !== 0 ) { + continue; + } + + return (new ReflectionClass($class))->getFileName(); + } + + return false; };