Skip to content

Bugfix #26479 Exception when Autoloader was not registered properly #26480

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions lib/internal/Magento/Framework/Autoload/AutoloaderRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
namespace Magento\Framework\Autoload;

use InvalidArgumentException;
use Magento\Framework\Autoload\AutoloaderInterface;

/**
Expand All @@ -23,23 +24,23 @@ class AutoloaderRegistry
* @param AutoloaderInterface $newAutoloader
* @return void
*/
public static function registerAutoloader(AutoloaderInterface $newAutoloader)
public static function registerAutoloader(AutoloaderInterface $newAutoloader): void
{
self::$autoloader = $newAutoloader;
}

/**
* Returns the registered autoloader
*
* @throws \Exception
* @throws InvalidArgumentException
* @return AutoloaderInterface
*/
public static function getAutoloader()
public static function getAutoloader(): AutoloaderInterface
{
if (self::$autoloader !== null) {
return self::$autoloader;
} else {
throw new \Exception('Autoloader is not registered, cannot be retrieved.');
if (!self::$autoloader instanceof AutoloaderInterface) {
throw new InvalidArgumentException('Autoloader is not registered, cannot be retrieved.');
}

return self::$autoloader;
}
}