Skip to content

Commit a660dcd

Browse files
ENGCOM-6674: Bugfix #26479 Exception when Autoloader was not registered properly #26480
- Merge Pull Request #26480 from lbajsarowicz/magento2:bugfix/autoloader-array - Merged commits: 1. ab1b1de 2. 61bc535
2 parents 3811867 + 61bc535 commit a660dcd

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

lib/internal/Magento/Framework/Autoload/AutoloaderRegistry.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\Framework\Autoload;
77

8+
use InvalidArgumentException;
89
use Magento\Framework\Autoload\AutoloaderInterface;
910

1011
/**
@@ -23,23 +24,23 @@ class AutoloaderRegistry
2324
* @param AutoloaderInterface $newAutoloader
2425
* @return void
2526
*/
26-
public static function registerAutoloader(AutoloaderInterface $newAutoloader)
27+
public static function registerAutoloader(AutoloaderInterface $newAutoloader): void
2728
{
2829
self::$autoloader = $newAutoloader;
2930
}
3031

3132
/**
3233
* Returns the registered autoloader
3334
*
34-
* @throws \Exception
35+
* @throws InvalidArgumentException
3536
* @return AutoloaderInterface
3637
*/
37-
public static function getAutoloader()
38+
public static function getAutoloader(): AutoloaderInterface
3839
{
39-
if (self::$autoloader !== null) {
40-
return self::$autoloader;
41-
} else {
42-
throw new \Exception('Autoloader is not registered, cannot be retrieved.');
40+
if (!self::$autoloader instanceof AutoloaderInterface) {
41+
throw new InvalidArgumentException('Autoloader is not registered, cannot be retrieved.');
4342
}
43+
44+
return self::$autoloader;
4445
}
4546
}

0 commit comments

Comments
 (0)