rector: Call to undefined function Symfony\Component\DependencyInjection\Loader\Configurator\service()

Bug Report

Subject Details
Rector version rector/rector:latest
Installed as dockerimage
λ docker run -it --rm --entrypoint bash -v %CD%:/project rector/rector:latest
root@440c45a4a3fb:/project# cd legacy-app
root@440c45a4a3fb:/project/legacy-app# which rector
/rector/bin/rector
root@440c45a4a3fb:/project/legacy-app# rector process . --dry-run -vvvv


 [ERROR] Call to undefined function Symfony\Component\DependencyInjection\Loader\Configurator\service()


root@440c45a4a3fb:/project/legacy-app# rector --version


 [ERROR] Call to undefined function Symfony\Component\DependencyInjection\Loader\Configurator\service()

<?php

declare(strict_types=1);

use Rector\Core\Configuration\Option;
use Rector\Php74\Rector\Property\TypedPropertyRector;
use Rector\Set\ValueObject\SetList;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

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

    // Define what rule sets will be applied
    $parameters->set(Option::SETS, [
        'php72',
    ]);

    // get services (needed for register a single rule)
    // $services = $containerConfigurator->services();

    // register a single rule
    // $services->set(TypedPropertyRector::class);
};

Minimal PHP Code Causing Issue

No idea where to start the debug. It seems that rector does not output stacktrace for its exceptions even with -vvv

Expected Behaviour

This does not happen 😃

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 17 (16 by maintainers)

Commits related to this issue

Most upvoted comments

Tried it, I guess the 7.1 version would need to be scoped as well to work 😢

Although for reasons yet unknown it breaks on symfony iself:

PHP Fatal error:  Declaration of Symfony\Component\Cache\CacheItem::tag($tags): Symfony\Component\Cache\CacheItem must be compatible with Symfony\Contracts\Cache\ItemInterface::tag($tags): Symfony\Contracts\Cache\ItemInterface in /var/www/html/legacy-app/vendor/rector/rector-php71/vendor/symfony/cache/CacheItem.php on line 22

IMHO scoping + docker is a way to go. There would be no conflicts whatsoever.

Tried it, I guess the 7.1 version would need to be scoped as well to work 😢

Oh, I forgot about that 😕 @leoloso Could you incorporate that into the build process? It’s not helpful without that.

  Package rector/rector-prefixed at version  has a PHP requirement incompatible with your PHP version (7.1.30)

Intention was to use it to migrate from 7.1.30 to something of late 😃 It’s why I went with docker in the first place.

root@cfd7f4f3afdb:/project/legacy-app# rector --debug


 [ERROR] Call to undefined function Symfony\Component\DependencyInjection\Loader\Configurator\service()