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

 - Merge Pull Request #26480 from lbajsarowicz/magento2:bugfix/autoloader-array
 - Merged commits:
   1. ab1b1de
   2. 61bc535
  • Loading branch information
magento-engcom-team committed Jan 23, 2020
2 parents 3811867 + 61bc535 commit a660dcd
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 a660dcd

Please sign in to comment.