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

PHP Fatal error: Uncaught Error: Class 'Yii' not found when running the analysis #27

Open
senguttuvang opened this issue Mar 14, 2020 · 1 comment

Comments

@senguttuvang
Copy link

➜ MMR git:(PHP-Static-Code-Analysis) ✗ vendor/bin/phpstan analyse frontend

Note: Using configuration file /vagrant/MMR/phpstan.neon.
PHP Fatal error:  Uncaught Error: Class 'Yii' not found in /vagrant/MMR/frontend/config/web.php:9
Stack trace:
#0 /vagrant/MMR/vendor/proget-hq/phpstan-yii2/src/ServiceMap.php(31): require()
#1 /tmp/phpstan/cache/nette.configurator/Container_36e5b17f91.php(3264): Proget\PHPStan\Yii2\ServiceMap->__construct('/vagrant/MMR/ve...')
#2 phar:///vagrant/MMR/vendor/phpstan/phpstan/phpstan/vendor/nette/di/src/DI/Container.php(146): Container_36e5b17f91->createService0169()
#3 phar:///vagrant/MMR/vendor/phpstan/phpstan/phpstan/vendor/nette/di/src/DI/Container.php(88): _HumbugBoxa35debbd0202\Nette\DI\Container->createService('0169')
#4 /tmp/phpstan/cache/nette.configurator/Container_36e5b17f91.php(3197): _HumbugBoxa35debbd0202\Nette\DI\Container->getService('0169')
#5 phar:///vagrant/MMR/vendor/phpstan/phpstan/phpstan/vendor/nette/di/src/DI/Container.php(146): Container_36e5b17f91->createService0158()
#6 phar:///vagrant/MMR/vendor/phpstan/phpstan/phpstan/vendor/nette/di/src/DI/Container.php(88): _HumbugBoxa35debbd0202\Nette\DI\Container- in /vagrant/MMR/frontend/config/web.php on line 9
Fatal error: Uncaught Error: Class 'Yii' not found in /vagrant/MMR/frontend/config/web.php:9
Stack trace:
#0 /vagrant/MMR/vendor/proget-hq/phpstan-yii2/src/ServiceMap.php(31): require()
#1 /tmp/phpstan/cache/nette.configurator/Container_36e5b17f91.php(3264): Proget\PHPStan\Yii2\ServiceMap->__construct('/vagrant/MMR/ve...')
#2 phar:///vagrant/MMR/vendor/phpstan/phpstan/phpstan/vendor/nette/di/src/DI/Container.php(146): Container_36e5b17f91->createService0169()
#3 phar:///vagrant/MMR/vendor/phpstan/phpstan/phpstan/vendor/nette/di/src/DI/Container.php(88): _HumbugBoxa35debbd0202\Nette\DI\Container->createService('0169')
#4 /tmp/phpstan/cache/nette.configurator/Container_36e5b17f91.php(3197): _HumbugBoxa35debbd0202\Nette\DI\Container->getService('0169')
#5 phar:///vagrant/MMR/vendor/phpstan/phpstan/phpstan/vendor/nette/di/src/DI/Container.php(146): Container_36e5b17f91->createService0158()
#6 phar:///vagrant/MMR/vendor/phpstan/phpstan/phpstan/vendor/nette/di/src/DI/Container.php(88): _HumbugBoxa35debbd0202\Nette\DI\Container- in /vagrant/MMR/frontend/config/web.php on line 9

➜ MMR git:(PHP-Static-Code-Analysis) ✗

image

@Khartir
Copy link
Contributor

Khartir commented Apr 21, 2020

I had the same problem. I solved it by adding require_once (__DIR__ . '/../vendor/yiisoft/yii2/Yii.php'); to the config file.
This caused a redeclare error at first, because the file was required again in the phpstan bootstrap file. Changing that to a require_once solved it.

It seems to me that this extension tries to load the config file before the phpstan bootstrap file is loaded. Is that possible?

@pappfer pappfer mentioned this issue Jul 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants