lib/Doctrine/ORM/Mapping/Factory/Autoloader.php
public static function register(
        string $metadataDir,
        string $metadataNamespace,
        ?callable $notFoundCallback = null
    ) : Closure {
        $metadataNamespace = ltrim($metadataNamespace, '\\');

        if (! ($notFoundCallback === null || is_callable($notFoundCallback))) {
            $type = is_object($notFoundCallback) ? get_class($notFoundCallback) : gettype($notFoundCallback);

            throw new InvalidArgumentException(
                sprintf('Invalid \$notFoundCallback given: must be a callable, "%s" given', $type)
            );
        }

        $autoloader = static function ($className) use ($metadataDir, $metadataNamespace, $notFoundCallback) {
            if (strpos($className, $metadataNamespace) === 0) {
                $file = Autoloader::resolveFile($metadataDir, $metadataNamespace, $className);

                if ($notFoundCallback && ! file_exists($file)) {
                    call_user_func($notFoundCallback, $metadataDir, $metadataNamespace, $className);
                }

                require $file;
            }
        };

        spl_autoload_register($autoloader);

        return $autoloader;
    }
public static function register(
        string $metadataDir,
        string $metadataNamespace,
        ?callable $notFoundCallback = null
    ) : Closure {
        $metadataNamespace = ltrim($metadataNamespace, '\\');

        if (! ($notFoundCallback === null || is_callable($notFoundCallback))) {
            $type = is_object($notFoundCallback) ? get_class($notFoundCallback) : gettype($notFoundCallback);

            throw new InvalidArgumentException(
                sprintf('Invalid \$notFoundCallback given: must be a callable, "%s" given', $type)
            );
        }

        $autoloader = static function ($className) use ($metadataDir, $metadataNamespace, $notFoundCallback) {
            if (strpos($className, $metadataNamespace) === 0) {
                $file = Autoloader::resolveFile($metadataDir, $metadataNamespace, $className);

                if ($notFoundCallback && ! file_exists($file)) {
                    call_user_func($notFoundCallback, $metadataDir, $metadataNamespace, $className);
                }

                require $file;
            }
        };

        spl_autoload_register($autoloader);

        return $autoloader;
    }
public static function register ( string $ metadataDir , string $ metadataNamespace , ? callable $ notFoundCallback = null ) : Closure { $ metadataNamespace = ltrim ( $ metadataNamespace , '\\' ) ; if ( ! ( $ notFoundCallback === null || is_callable ( $ notFoundCallback ) ) ) { $ type = is_object ( $ notFoundCallback ) ? get_class ( $ notFoundCallback ) : gettype ( $ notFoundCallback ) ; throw new InvalidArgumentException ( sprintf ( 'Invalid \$notFoundCallback given: must be a callable, "%s" given' , $ type ) ) ; } $ autoloader = static function ( $ className ) use ( $ metadataDir , $ metadataNamespace , $ notFoundCallback ) { if ( strpos ( $ className , $ metadataNamespace ) === 0 ) { $ file = Autoloader :: resolveFile ( $ metadataDir , $ metadataNamespace , $ className ) ; if ( $ notFoundCallback && ! file_exists ( $ file ) ) { call_user_func ( $ notFoundCallback , $ metadataDir , $ metadataNamespace , $ className ) ; } require $ file ; } } ; spl_autoload_register ( $ autoloader ) ; return $ autoloader ; }
Registers and returns autoloader callback for the given metadata dir and namespace.

@param callable|null $notFoundCallback Invoked when the proxy file is not found.

@throws InvalidArgumentException
Registers and returns autoloader callback for the given metadata dir and namespace .