Skip to content

Commit cbbe26c

Browse files
committed
Throw exception in autoloader
1 parent 05b71a3 commit cbbe26c

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

autoload.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,19 @@
1515
use PHPStan\DependencyInjection\Container;
1616

1717
if (!isset($container) || !$container instanceof Container) {
18-
echo 'No container found, or container not of expected type' . PHP_EOL;
19-
die(-1);
18+
throw new \RuntimeException('No container found, or container not of expected type');
2019
}
2120

2221
foreach ($container->getServicesByTag('phpstan.magento.autoloader') as $autoloader) {
2322
/** @var Autoloader|object $autoloader */
2423
if (!$autoloader instanceof Autoloader) {
25-
echo 'Services tagged with \'phpstan.magento.autoloader\' must extend ' .
26-
'bitExpert\PHPStan\Magento\Autoload\Autoloader!' . PHP_EOL .
27-
get_class($autoloader) . ' does not.' . PHP_EOL;
28-
die(-1);
24+
throw new \RuntimeException(
25+
sprintf(
26+
'Service "%s" tagged with "phpstan.magento.autoloader" must implement %s!',
27+
get_class($autoloader),
28+
'bitExpert\PHPStan\Magento\Autoload\Autoloader'
29+
)
30+
);
2931
}
3032

3133
$autoloader->register();

0 commit comments

Comments
 (0)