rector: Argument 1 passed to ContainerConfigurator must be an instance of RectorPrefix20210909\...\ContainerBuilder, instance of Symfony\...\MergeExtensionConfigurationContainerBuilder given
Bug Report
| Subject | Details |
|---|---|
| Rector version | v0.11.53 (ae25b721b3193e6da82b711c2401a8c309c6b8b7) |
| phpstan/phpstan | v0.12.98 |
| phpstan/phpstan-symfony | v0.12.44 |
| symfony | v4.4.27 |
I started getting this error after I added console_application_loader: tests/console-application.php to phpstan.neon.
Here is the error:
vendor/bin/rector process --ansi -vvv
[parsing] src/Command/CreateUserCommand.php
PHP Fatal error: Uncaught TypeError: Argument 1 passed to RectorPrefix20210909\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator::__construct() must be an instance of RectorPrefix20210909\Symfony\Component\DependencyInjection\ContainerBuilder, instance of Symfony\Component\DependencyInjection\Compiler\MergeExtensionConfigurationContainerBuilder given, called in /vendor/symfony/dependency-injection/Loader/PhpFileLoader.php on line 67 and defined in /vendor/rector/rector/vendor/symfony/dependency-injection/Loader/Configurator/ContainerConfigurator.php:37
Stack trace:
#0 /vendor/symfony/dependency-injection/Loader/PhpFileLoader.php(67): RectorPrefix20210909\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator->__construct()
#1 /vendor/twig/extra-bundle/DependencyInjection/TwigExtraExtension.php(32): Symfony\Component\De in /vendor/rector/rector/vendor/symfony/dependency-injection/Loader/Configurator/ContainerConfigurator.php on line 37
Fatal error: Uncaught TypeError: Argument 1 passed to RectorPrefix20210909\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator::__construct() must be an instance of RectorPrefix20210909\Symfony\Component\DependencyInjection\ContainerBuilder, instance of Symfony\Component\DependencyInjection\Compiler\MergeExtensionConfigurationContainerBuilder given, called in /vendor/symfony/dependency-injection/Loader/PhpFileLoader.php on line 67 and defined in /vendor/rector/rector/vendor/symfony/dependency-injection/Loader/Configurator/ContainerConfigurator.php:37
Stack trace:
#0 /vendor/symfony/dependency-injection/Loader/PhpFileLoader.php(67): RectorPrefix20210909\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator->__construct()
#1 /vendor/twig/extra-bundle/DependencyInjection/TwigExtraExtension.php(32): Symfony\Component\De in /vendor/rector/rector/vendor/symfony/dependency-injection/Loader/Configurator/ContainerConfigurator.php on line 37
Minimal PHP Code Causing Issue
phpstan.neon (only relevant stuff)
includes:
- vendor/symplify/phpstan-extensions/config/config.neon
- vendor/phpstan/phpstan-symfony/extension.neon
parameters:
symfony:
container_xml_path: var/cache/dev/srcApp_KernelDevDebugContainer.xml
# if I comment out the next line the error is gone
console_application_loader: tests/console-application.php
tests/console-application.php
<?php
use App\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;
require __DIR__ . '/../config/bootstrap.php';
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
return new Application($kernel);
Expected Behaviour
vendor/bin/rector process completes without fatal error
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (10 by maintainers)
Hey guys, I have good news 🙂
This PR might help to fix this soon: https://github.com/rectorphp/rector-src/pull/2019
I just stumbled on this issue, but the cause was pretty dumb on my side: I was upgrading Rector (0.12) to newer versions (0.14-0.15) without upgrading the config to the new
RectorConfigformat. That forced the “unprefixing” issue.Hope this will help someone stuck on the same error.
Hi, thanks for sharing the approach and setup for your project. Let’s keep this issue open until the bad news is solved 😃
The solution has 3 steps:
RectorConfig✔️ (WIP 😃)Now we’re in a process of upgrading to
RectorConfig. The next step will follow in ~month what I expect to be.The
RectorConfigis now solved and migration is proposed on every Rector run. In next version this will throw an exceptoin to inform users about migration.Next steps is to prefix the
ContainerConfiguratorof Symfony, as proposed in https://github.com/rectorphp/rector-src/pull/2104This should be resolved by using new RectorConfig on latest 0.12.21.
I am closing it.
The config container has to be build first, to be albe to use the dumped
*.xml. That’s the way Symfony works and we build the rule around it.Yet, this might help with the autoloading race condition: https://github.com/rectorphp/rector-src/pull/1891
I am closing it, feel free to provide sample repository when you have a chance so it can be covered, thank you.
Could you create sample repository that reproduce the issue? Thank you.