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

Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator::__construct (): Argument #1 ($container) must be of type Symfony\Component\DependencyInjection\ContainerBuilder, RectorPrefix202209\Symfony\Component\DependencyInjection\ContainerBuilder given, called in /var/www/php-application/vendor/rector/rector/vendor/symfony/dependency-injection/Loader/Php FileLoader.php on line 67 #7455

Closed
ahmedesa opened this issue Sep 5, 2022 · 3 comments
Labels

Comments

@ahmedesa
Copy link

ahmedesa commented Sep 5, 2022

Bug Report

| Rector version | 0.14.2
| php version | 8.1.9
| phpstan version | 1.8.3

when run : vendor/bin/rector p --ansi

error :

[ERROR] Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator::__construct
(): Argument #1 ($container) must be of type
Symfony\Component\DependencyInjection\ContainerBuilder,
RectorPrefix202209\Symfony\Component\DependencyInjection\ContainerBuilder given, called in
/var/www/php-application/vendor/rector/rector/vendor/symfony/dependency-injection/Loader/Php
FileLoader.php on line 67

@ahmedesa ahmedesa added the bug label Sep 5, 2022
@TomasVotruba
Copy link
Member

How does your rector.php look like?
It should use aRectorConfig class

@ahmedesa
Copy link
Author

ahmedesa commented Sep 6, 2022

this is my rector file
`<?php

declare(strict_types=1);

use Rector\Core\Configuration\Option;
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
use Rector\Set\ValueObject\SetList;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
// get parameters
$parameters = $containerConfigurator->parameters();

$parameters->set(Option::AUTO_IMPORT_NAMES, true);
$parameters->set(Option::PHPSTAN_FOR_RECTOR_PATH, __DIR__ . './phpstan.neon');
$parameters->set(Option::PATHS, [
    __DIR__ . '/src',
    __DIR__ . '/tests'
]);

// Define what rule sets will be applied, run one by one, commit each time, makes reverting changes a lot easier
$containerConfigurator->import(SetList::CODE_QUALITY);
$containerConfigurator->import(SetList::PHP_80);
$containerConfigurator->import(SetList::DEAD_CODE);
$containerConfigurator->import(SetList::TYPE_DECLARATION);

};
`

@samsonasik
Copy link
Member

You need to update config to use RectorConfig class:

<?php

declare(strict_types=1);

use Rector\Set\ValueObject\SetList;
use Rector\Config\RectorConfig;

return static function (RectorConfig $rectorConfig): void {
    $rectorConfig->importNames();
    $rectorConfig->phpstanConfig(__DIR__ . './phpstan.neon');
    $rectorConfig->paths([
        __DIR__ . '/src',
        __DIR__ . '/tests',        
    ]);

    $rectorConfig->sets([
        SetList::CODE_QUALITY,
        SetList::PHP_80,
        SetList::DEAD_CODE,
        SetList::TYPE_DECLARATION
    ]);
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants