Skip to content
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

Throw exception in autoloader #170

Merged
merged 1 commit into from
Dec 21, 2021
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
14 changes: 8 additions & 6 deletions autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@
use PHPStan\DependencyInjection\Container;

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

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

$autoloader->register();
Expand Down