Skip to content

Commit

Permalink
ENGCOM-6674: Bugfix #26479 Exception when Autoloader was not register…
Browse files Browse the repository at this point in the history
…ed properly #26480
  • Loading branch information
slavvka committed Feb 7, 2020
2 parents dcca509 + a660dcd commit 477c3a2
Showing 1 changed file with 8 additions and 7 deletions.
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;
}
}

0 comments on commit 477c3a2

Please sign in to comment.