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

Can't use phpstan-yii2 if there are helper functions in config #12

Open
ddinchev opened this issue Jan 8, 2019 · 4 comments
Open

Can't use phpstan-yii2 if there are helper functions in config #12

ddinchev opened this issue Jan 8, 2019 · 4 comments

Comments

@ddinchev
Copy link

ddinchev commented Jan 8, 2019

This is my phpstan.neon.

includes:
	- vendor/proget-hq/phpstan-yii2/extension.neon
parameters:
    autoload_files:
        - %rootDir%/../../../common/helpers.php
    yii2:
        config_path: %rootDir%/../../../config/web.php

I use functions defined in %rootDir%/../../../common/helpers.php in my config file, however phpstan-yii2's services seem to be executed before that file is included and it fails with a message that no such function exists.

@akondas
Copy link
Contributor

akondas commented Jan 8, 2019

Thanks for issue, this should be easy to fix, maybe @marmichalski have some time :D

@ddinchev
Copy link
Author

Hey @akondas I just tried to use phpstan-yii2 again and hit the same issue. Can you take a look if it's not too much trouble?

@akondas
Copy link
Contributor

akondas commented May 24, 2019

Have you try to add it to composer.json to autoload files?:

{
    "autoload": {
        "files": ["src/MyLibrary/functions.php"]
    }
}

@senguttuvang
Copy link

Guys, for me, even the core Yii class itself is unable to load. Any idea?

➜  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

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

3 participants