Closed alexander-schranz closed 1 year ago
Rector 0.17.3 no longer magically load phpstan extension, that's on PR:
by @TomasVotruba , the services need to be loaded on phpstan config, and you may can configure:
$rectorConfig->phpstanConfig(__DIR__ . '/phpstan-for-rector.neon');
@alexander-schranz I checked, you need to add includes
in your phpstan.neon:
includes:
- vendor/phpstan/phpstan-doctrine/extension.neon
- vendor/phpstan/phpstan-symfony/extension.neon
I created PR to sulu/skeleton repo:
Thx for the detailed and fast response. I understand the internal issue, but currently from outside it feels really strange. Is there any way to hook into this from the rector.php
config file so my phpstan.neon don't need to handle that?
Something like:
$rectorConfig->phpstanConfig(__DIR__ . '/phpstan.neon');
$rectorConfig->phpstanConfigs([
'vendor/phpstan/phpstan-doctrine/extension.neon',
'vendor/phpstan/phpstan-symfony/extension.neon',
]);
Want to avoid have to define some extensions in the phpstan.neon file and some are autoloaded and not really a fan of phpstan-for-rector.neon file.
phpstanConfigs()
currently only allow string param, feel free to create feature request for that :)
Move it into an own feature request where the details can be discussed: https://github.com/rectorphp/rector/issues/8141
Thanks for the config improvement :+1:
Closing as explicit extension including is the solution now: https://github.com/rectorphp/rector/issues/8140#issuecomment-1680376683
Bug Report
Run into the following issue:
Full Stacktrace
> @php vendor/bin/rector process PHP Fatal error: Uncaught _PHPStan_7c8075089\Nette\Schema\ValidationException: Unexpected item 'parameters › doctrine'. in phar:///Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/schema/src/Schema/Processor.php:75 Stack trace: #0 phar:///Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/schema/src/Schema/Processor.php(38): _PHPStan_7c8075089\Nette\Schema\Processor->throwsErrors() #1 phar:///Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/DependencyInjection/ContainerFactory.php(269): _PHPStan_7c8075089\Nette\Schema\Processor->process(Object(_PHPStan_7c8075089\Nette\Schema\Elements\Structure), NULL) #2 phar:///Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/DependencyInjection/ContainerFactory.php(122): PHPStan\DependencyInjection\ContainerFactory->validateParameters(Array, Array) #3 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/packages/NodeTypeResolver/DependencyInjection/PHPStanServicesFactory.php(45): PHPStan\DependencyInjection\ContainerFactory->create('/var/folders/fh...', Array, Array) #4 [internal function]: Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory->__construct(Object(Rector\NodeTypeResolver\DependencyInjection\BleedingEdgeIncludePurifier)) #5 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/symfony/dependency-injection/ContainerBuilder.php(915): ReflectionClass->newInstanceArgs(Array) #6 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/symfony/dependency-injection/ContainerBuilder.php(490): RectorPrefix202308\Symfony\Component\DependencyInjection\ContainerBuilder->createService(Object(RectorPrefix202308\Symfony\Component\DependencyInjection\Definition), Array, false, 'Rector\\NodeType...') #7 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/symfony/dependency-injection/ContainerBuilder.php(1023): RectorPrefix202308\Symfony\Component\DependencyInjection\ContainerBuilder->doGet('Rector\\NodeType...', 1, Array, false) #8 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/symfony/dependency-injection/ContainerBuilder.php(870): RectorPrefix202308\Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices(Object(RectorPrefix202308\Symfony\Component\DependencyInjection\Reference), Array, false) #9 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/symfony/dependency-injection/ContainerBuilder.php(490): RectorPrefix202308\Symfony\Component\DependencyInjection\ContainerBuilder->createService(Object(RectorPrefix202308\Symfony\Component\DependencyInjection\Definition), Array, false, 'PHPStan\\Reflect...') #10 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/symfony/dependency-injection/ContainerBuilder.php(1023): RectorPrefix202308\Symfony\Component\DependencyInjection\ContainerBuilder->doGet('PHPStan\\Reflect...', 1, Array, false) #11 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/symfony/dependency-injection/ContainerBuilder.php(976): RectorPrefix202308\Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices(Object(RectorPrefix202308\Symfony\Component\DependencyInjection\TypedReference), Array, false) #12 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/symfony/dependency-injection/ContainerBuilder.php(880): RectorPrefix202308\Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices(Array, Array, false) #13 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/symfony/dependency-injection/ContainerBuilder.php(490): RectorPrefix202308\Symfony\Component\DependencyInjection\ContainerBuilder->createService(Object(RectorPrefix202308\Symfony\Component\DependencyInjection\Definition), Array, false, 'Rector\\Skipper\\...') #14 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/symfony/dependency-injection/ContainerBuilder.php(1023): RectorPrefix202308\Symfony\Component\DependencyInjection\ContainerBuilder->doGet('Rector\\Skipper\\...', 1, Array, false) #15 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/symfony/dependency-injection/ContainerBuilder.php(976): RectorPrefix202308\Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices(Object(RectorPrefix202308\Symfony\Component\DependencyInjection\TypedReference), Array, false) #16 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/symfony/dependency-injection/ContainerBuilder.php(880): RectorPrefix202308\Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices(Array, Array, false) #17 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/symfony/dependency-injection/ContainerBuilder.php(490): RectorPrefix202308\Symfony\Component\DependencyInjection\ContainerBuilder->createService(Object(RectorPrefix202308\Symfony\Component\DependencyInjection\Definition), Array, false, 'Rector\\Core\\Con...') #18 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/symfony/dependency-injection/ContainerBuilder.php(1023): RectorPrefix202308\Symfony\Component\DependencyInjection\ContainerBuilder->doGet('Rector\\Core\\Con...', 1, Array, false) #19 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/symfony/dependency-injection/ContainerBuilder.php(996): RectorPrefix202308\Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices(Object(RectorPrefix202308\Symfony\Component\DependencyInjection\Reference), Array) #20 [internal function]: RectorPrefix202308\Symfony\Component\DependencyInjection\ContainerBuilder->RectorPrefix202308\Symfony\Component\DependencyInjection\{closure}() #21 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/src/Console/ConsoleApplication.php(32): iterator_to_array(Object(Generator)) #22 [internal function]: Rector\Core\Console\ConsoleApplication->__construct(Object(RectorPrefix202308\Symfony\Component\DependencyInjection\Argument\RewindableGenerator)) #23 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/symfony/dependency-injection/ContainerBuilder.php(915): ReflectionClass->newInstanceArgs(Array) #24 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/symfony/dependency-injection/ContainerBuilder.php(490): RectorPrefix202308\Symfony\Component\DependencyInjection\ContainerBuilder->createService(Object(RectorPrefix202308\Symfony\Component\DependencyInjection\Definition), Array, true, 'Rector\\Core\\Con...') #25 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/symfony/dependency-injection/ContainerBuilder.php(441): RectorPrefix202308\Symfony\Component\DependencyInjection\ContainerBuilder->doGet('Rector\\Core\\Con...', 1) #26 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/bin/rector.php(131): RectorPrefix202308\Symfony\Component\DependencyInjection\ContainerBuilder->get('Rector\\Core\\Con...') #27 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/bin/rector(5): require_once('/Users/alexande...') #28 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/bin/rector(119): include('/Users/alexande...') #29 {main} thrown in phar:///Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/schema/src/Schema/Processor.php on line 75 Fatal error: Uncaught _PHPStan_7c8075089\Nette\Schema\ValidationException: Unexpected item 'parameters › doctrine'. in phar:///Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/schema/src/Schema/Processor.php:75 Stack trace: #0 phar:///Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/schema/src/Schema/Processor.php(38): _PHPStan_7c8075089\Nette\Schema\Processor->throwsErrors() #1 phar:///Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/DependencyInjection/ContainerFactory.php(269): _PHPStan_7c8075089\Nette\Schema\Processor->process(Object(_PHPStan_7c8075089\Nette\Schema\Elements\Structure), NULL) #2 phar:///Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/DependencyInjection/ContainerFactory.php(122): PHPStan\DependencyInjection\ContainerFactory->validateParameters(Array, Array) #3 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/packages/NodeTypeResolver/DependencyInjection/PHPStanServicesFactory.php(45): PHPStan\DependencyInjection\ContainerFactory->create('/var/folders/fh...', Array, Array) #4 [internal function]: Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory->__construct(Object(Rector\NodeTypeResolver\DependencyInjection\BleedingEdgeIncludePurifier)) #5 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/symfony/dependency-injection/ContainerBuilder.php(915): ReflectionClass->newInstanceArgs(Array) #6 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/symfony/dependency-injection/ContainerBuilder.php(490): RectorPrefix202308\Symfony\Component\DependencyInjection\ContainerBuilder->createService(Object(RectorPrefix202308\Symfony\Component\DependencyInjection\Definition), Array, false, 'Rector\\NodeType...') #7 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/symfony/dependency-injection/ContainerBuilder.php(1023): RectorPrefix202308\Symfony\Component\DependencyInjection\ContainerBuilder->doGet('Rector\\NodeType...', 1, Array, false) #8 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/symfony/dependency-injection/ContainerBuilder.php(870): RectorPrefix202308\Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices(Object(RectorPrefix202308\Symfony\Component\DependencyInjection\Reference), Array, false) #9 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/symfony/dependency-injection/ContainerBuilder.php(490): RectorPrefix202308\Symfony\Component\DependencyInjection\ContainerBuilder->createService(Object(RectorPrefix202308\Symfony\Component\DependencyInjection\Definition), Array, false, 'PHPStan\\Reflect...') #10 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/symfony/dependency-injection/ContainerBuilder.php(1023): RectorPrefix202308\Symfony\Component\DependencyInjection\ContainerBuilder->doGet('PHPStan\\Reflect...', 1, Array, false) #11 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/symfony/dependency-injection/ContainerBuilder.php(976): RectorPrefix202308\Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices(Object(RectorPrefix202308\Symfony\Component\DependencyInjection\TypedReference), Array, false) #12 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/symfony/dependency-injection/ContainerBuilder.php(880): RectorPrefix202308\Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices(Array, Array, false) #13 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/symfony/dependency-injection/ContainerBuilder.php(490): RectorPrefix202308\Symfony\Component\DependencyInjection\ContainerBuilder->createService(Object(RectorPrefix202308\Symfony\Component\DependencyInjection\Definition), Array, false, 'Rector\\Skipper\\...') #14 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/symfony/dependency-injection/ContainerBuilder.php(1023): RectorPrefix202308\Symfony\Component\DependencyInjection\ContainerBuilder->doGet('Rector\\Skipper\\...', 1, Array, false) #15 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/symfony/dependency-injection/ContainerBuilder.php(976): RectorPrefix202308\Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices(Object(RectorPrefix202308\Symfony\Component\DependencyInjection\TypedReference), Array, false) #16 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/symfony/dependency-injection/ContainerBuilder.php(880): RectorPrefix202308\Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices(Array, Array, false) #17 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/symfony/dependency-injection/ContainerBuilder.php(490): RectorPrefix202308\Symfony\Component\DependencyInjection\ContainerBuilder->createService(Object(RectorPrefix202308\Symfony\Component\DependencyInjection\Definition), Array, false, 'Rector\\Core\\Con...') #18 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/symfony/dependency-injection/ContainerBuilder.php(1023): RectorPrefix202308\Symfony\Component\DependencyInjection\ContainerBuilder->doGet('Rector\\Core\\Con...', 1, Array, false) #19 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/symfony/dependency-injection/ContainerBuilder.php(996): RectorPrefix202308\Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices(Object(RectorPrefix202308\Symfony\Component\DependencyInjection\Reference), Array) #20 [internal function]: RectorPrefix202308\Symfony\Component\DependencyInjection\ContainerBuilder->RectorPrefix202308\Symfony\Component\DependencyInjection\{closure}() #21 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/src/Console/ConsoleApplication.php(32): iterator_to_array(Object(Generator)) #22 [internal function]: Rector\Core\Console\ConsoleApplication->__construct(Object(RectorPrefix202308\Symfony\Component\DependencyInjection\Argument\RewindableGenerator)) #23 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/symfony/dependency-injection/ContainerBuilder.php(915): ReflectionClass->newInstanceArgs(Array) #24 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/symfony/dependency-injection/ContainerBuilder.php(490): RectorPrefix202308\Symfony\Component\DependencyInjection\ContainerBuilder->createService(Object(RectorPrefix202308\Symfony\Component\DependencyInjection\Definition), Array, true, 'Rector\\Core\\Con...') #25 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/symfony/dependency-injection/ContainerBuilder.php(441): RectorPrefix202308\Symfony\Component\DependencyInjection\ContainerBuilder->doGet('Rector\\Core\\Con...', 1) #26 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/bin/rector.php(131): RectorPrefix202308\Symfony\Component\DependencyInjection\ContainerBuilder->get('Rector\\Core\\Con...') #27 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/bin/rector(5): require_once('/Users/alexande...') #28 /Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/bin/rector(119): include('/Users/alexande...') #29 {main} thrown in phar:///Users/alexanderschranz/Documents/Projects/sulu-develop.localhost/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/schema/src/Schema/Processor.php on line 75The version 0.17.2 seems not to run into this issue.
Minimal PHP Code Causing Issue
As the error appears it seems to be related to the
phpstan-doctrine
extension. A repository to reproduce is sulu/skeleton where doctrine and other plugins are installed:Expected Behaviour
Same as 0.17.2 it should not error with phpstan exensions.