| Subject | Details |
| :------------- | :---------------------------------------------------------------|
| Rector version | e.g. v0.7.41 |
PHP Warning: file_get_contents(/path/to/app/vendor/phpstan/phpstan/../../../var/cache/dev/srcApp_KernelDevDebugContainer.xml): failed to open stream: No such file or directory in /path/to/app/vendor/phpstan/phpstan-symfony/src/Symfony/XmlServiceMapFactory.php on line 27
Trying to run Rector in CI we get the above error, caused by PHPStan that cannot find the container compiled in dev: in fact we are in test env, and so the dev container doesn't exist.
In a Symfony app:
var/cache/devtest env running bin/console cache:clear --env testrector.yaml (see below for the contents of the file)rector.test.yaml (see below for the content of the file)test config file: vendor/bin/rector process src --dry-run --config=rector.test.yamlrector.yamlparameters:
php_version_features: '7.2'
sets:
- 'php52'
- 'php53'
- 'php54'
- 'php56'
- 'php70'
- 'php71'
- 'php72'
- 'code-quality'
- 'coding-style'
- 'doctrine'
- 'phpstan'
- 'framework-extra-bundle-30'
- 'framework-extra-bundle-40'
- 'framework-extra-bundle-50'
- 'symfony-code-quality'
- 'symfony-constructor-injection'
- 'symfony42'
autoload_paths:
- 'config/bootstrap.php'
exclude_paths:
- '*/Migrations/*'
rector.test.yamlimports:
- { resource: 'rector.yaml'}
parameters:
symfony_container_xml_path: 'var/cache/test/srcApp_KernelTestDebugContainer.xml'
Rector is able to pass to PHPStan the correct config file, depending on the environment.
This issue was already addressed (but not solved) in
How would you fix it?
@TomasVotruba I have no idea: I don't know how the file is loaded nor how it is involved in Rector.
In PHPStan I pass it directly to the command line this way:
./vendor/bin/phpstan analyse src -c phpstan.test.neon --level max
So I think Rector should accept the same:
--phpstan-config phpstan.test.neon)rector.test.yaml with a key like phpstan_config_file_path.This way it is possible to pass to PHPStan the correct config file.
--phpstan-config
Sound good. Coul you add such feature here?
I don't know how the file is loaded nor how it is involved in Rector.
If you search for phpstan.neon, it's the first file:
https://github.com/rectorphp/rector/search?q=phpstan.neon&unscoped_q=phpstan.neon
@TomasVotruba , I will try to find time to work on this, but I cannot guarantee nothing.
The quarantine was very hard for me and now I can dedicate less than one hour a day (when I can) to development.
Closing for lack of feedback for last 4 months.