private function locateClassByName(string $className) : ?string
    {
        if (class_exists($className, false) || interface_exists($className, false) || trait_exists($className, false)) {
            $filename = (new ReflectionClass($className))->getFileName();

            if (! is_string($filename)) {
                return null;
            }

            return $filename;
        }

        self::$autoloadLocatedFile = null;
        self::$currentAstLocator   = $this->astLocator; // passing the locator on to the implicitly instantiated `self`
        $previousErrorHandler      = set_error_handler(static function () : void {
        });
        stream_wrapper_unregister('file');
        stream_wrapper_register('file', self::class);
        class_exists($className);
        stream_wrapper_restore('file');
        set_error_handler($previousErrorHandler);

        return self::$autoloadLocatedFile;
    }
private function locateClassByName(string $className) : ?string
    {
        if (class_exists($className, false) || interface_exists($className, false) || trait_exists($className, false)) {
            $filename = (new ReflectionClass($className))->getFileName();

            if (! is_string($filename)) {
                return null;
            }

            return $filename;
        }

        self::$autoloadLocatedFile = null;
        self::$currentAstLocator   = $this->astLocator; // passing the locator on to the implicitly instantiated `self`
        $previousErrorHandler      = set_error_handler(static function () : void {
        });
        stream_wrapper_unregister('file');
        stream_wrapper_register('file', self::class);
        class_exists($className);
        stream_wrapper_restore('file');
        set_error_handler($previousErrorHandler);

        return self::$autoloadLocatedFile;
    }
private function locateClassByName ( string $ className ) : ? string { if ( class_exists ( $ className , false ) || interface_exists ( $ className , false ) || trait_exists ( $ className , false ) ) { $ filename = ( new ReflectionClass ( $ className ) ) -> getFileName ( ) ; if ( ! is_string ( $ filename ) ) { return null ; } return $ filename ; } self :: $ autoloadLocatedFile = null ; self :: $ currentAstLocator = $ this -> astLocator ; // passing the locator on to the implicitly instantiated `self` $ previousErrorHandler = set_error_handler ( static function ( ) : void { } ) ; stream_wrapper_unregister ( 'file' ) ; stream_wrapper_register ( 'file' , self :: class ) ; class_exists ( $ className ) ; stream_wrapper_restore ( 'file' ) ; set_error_handler ( $ previousErrorHandler ) ; return self :: $ autoloadLocatedFile ; }
Attempt to locate a class by name.

If class already exists, simply use internal reflection API to get the
filename and store it.

If class does not exist, we make an assumption that whatever autoloaders
that are registered will be loading a file. We then override the file://
protocol stream wrapper to "capture" the filename we expect the class to
be in, and then restore it. Note that class_exists will cause an error
that it cannot find the file, so we squelch the errors by overriding the
error handler temporarily.

@throws ReflectionException
Attempt to locate a class by name .