src/AbstractLocator.php
protected function classReflection(string $class): \ReflectionClass
    {
        $loader = function ($class) {
            if ($class == LocatorException::class) {
                return;
            }

            throw new LocatorException("Class '{$class}' can not be loaded");
        };

        //To suspend class dependency exception
        spl_autoload_register($loader);

        try {
            //In some cases reflection can thrown an exception if class invalid or can not be loaded,
            //we are going to handle such exception and convert it soft exception
            return new \ReflectionClass($class);
        } catch (\Throwable $e) {
            if ($e instanceof LocatorException && $e->getPrevious() != null) {
                $e = $e->getPrevious();
            }

            $this->getLogger()->error(
                sprintf(
                    "%s: %s in %s:%s",
                    $class,
                    $e->getMessage(),
                    $e->getFile(),
                    $e->getLine()
                ),
                ['error' => $e]
            );

            throw new LocatorException($e->getMessage(), $e->getCode(), $e);
        } finally {
            spl_autoload_unregister($loader);
        }
    }
protected function classReflection(string $class): \ReflectionClass
    {
        $loader = function ($class) {
            if ($class == LocatorException::class) {
                return;
            }

            throw new LocatorException("Class '{$class}' can not be loaded");
        };

        //To suspend class dependency exception
        spl_autoload_register($loader);

        try {
            //In some cases reflection can thrown an exception if class invalid or can not be loaded,
            //we are going to handle such exception and convert it soft exception
            return new \ReflectionClass($class);
        } catch (\Throwable $e) {
            if ($e instanceof LocatorException && $e->getPrevious() != null) {
                $e = $e->getPrevious();
            }

            $this->getLogger()->error(
                sprintf(
                    "%s: %s in %s:%s",
                    $class,
                    $e->getMessage(),
                    $e->getFile(),
                    $e->getLine()
                ),
                ['error' => $e]
            );

            throw new LocatorException($e->getMessage(), $e->getCode(), $e);
        } finally {
            spl_autoload_unregister($loader);
        }
    }
protected function classReflection ( string $ class ) : \ ReflectionClass { $ loader = function ( $ class ) { if ( $ class == LocatorException :: class ) { return ; } throw new LocatorException ( "Class '{$class}' can not be loaded" ) ; } ; //To suspend class dependency exception spl_autoload_register ( $ loader ) ; try { //In some cases reflection can thrown an exception if class invalid or can not be loaded, //we are going to handle such exception and convert it soft exception return new \ ReflectionClass ( $ class ) ; } catch ( \ Throwable $ e ) { if ( $ e instanceof LocatorException && $ e -> getPrevious ( ) != null ) { $ e = $ e -> getPrevious ( ) ; } $ this -> getLogger ( ) -> error ( sprintf ( "%s: %s in %s:%s" , $ class , $ e -> getMessage ( ) , $ e -> getFile ( ) , $ e -> getLine ( ) ) , [ 'error' => $ e ] ) ; throw new LocatorException ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e ) ; } finally { spl_autoload_unregister ( $ loader ) ; } }
Safely get class reflection, class loading errors will be blocked and reflection will be
excluded from analysis.

@param string $class

@return \ReflectionClass
Safely get class reflection class loading errors will be blocked and reflection will be excluded from analysis .