Skip to content

Rector stuck on Rector\PostRector\Rector\NodeToReplacePostRector #6840

@bmovi

Description

@bmovi

Hello, when I try to run rector on my code it gets stuck on Rector\PostRector\Rector\NodeToReplacePostRector.

I can't make a link to getrector demo since I get a timeout after 60s.

My config:

<?php

declare(strict_types=1);

use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector;
use Rector\CodingStyle\Rector\Encapsed\WrapEncapsedVariableInCurlyBracesRector;
use Rector\Core\Configuration\Option;
use Rector\Doctrine\Set\DoctrineSetList;
use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector;
use Rector\Set\ValueObject\SetList;
use Rector\Symfony\Set\SymfonySetList;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

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

    $parameters->set(
        Option::SYMFONY_CONTAINER_XML_PATH_PARAMETER,
        __DIR__ . '/var/cache/dev/App_KernelDevDebugContainer.xml'
    );

    $parameters->set(Option::SKIP, [
        EncapsedStringsToSprintfRector::class,
        WrapEncapsedVariableInCurlyBracesRector::class,
    ]);

    // Replace anonymous function by arrow function
    $services->set(ClosureToArrowFunctionRector::class);

    $containerConfigurator->import(SetList::PHP_80);
    $containerConfigurator->import(SymfonySetList::SYMFONY_52);
    $containerConfigurator->import(SymfonySetList::SYMFONY_CODE_QUALITY);
    $containerConfigurator->import(SymfonySetList::SYMFONY_CONSTRUCTOR_INJECTION);
    $containerConfigurator->import(DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES);
    $containerConfigurator->import(SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES);
    $containerConfigurator->import(SetList::CODING_STYLE_ADVANCED);
    $containerConfigurator->import(SetList::CODING_STYLE);
};

My file:

<?php

namespace App\Entity;

use App\Response\Exception\MethodNotImplementedException;
use Doctrine\Common\Collections\ArrayCollection;
use JsonSerializable;

use function Symfony\Component\DependencyInjection\Loader\Configurator\env;

abstract class Image implements JsonSerializable
{
    protected string $imageId;
    protected ArrayCollection $imageSize;

    public function __construct($imageId)
    {
        $this->imageId = $imageId;
        $this->imageSize = new ArrayCollection();

        if (!method_exists($this, 'generateImageUrl')) {
            throw new MethodNotImplementedException();
        }

        $this->generateImageUrl();
    }

    protected function getServerName(): string
    {
        $servers = explode(',', $_ENV["IMG_HOST"]);

        return $servers[ord(strrev($this->imageId)) % count($servers)];
    }

    abstract public function generateImageUrl();
    abstract public function jsonSerialize();
}

My terminal output:

❯ vendor/bin/rector process src/Entity/Image.php --dry-run --debug
[parsing] src/Entity/Image.php
[refactoring] src/Entity/Image.php
    [applying] Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector
    [applying] Rector\CodingStyle\Rector\Use_\SeparateMultiUseImportsRector
    [applying] Rector\Php80\Rector\Class_\StringableForToStringRector
    [applying] Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector
    [applying] Rector\Php80\Rector\Class_\AnnotationToAttributeRector
    [applying] Rector\Renaming\Rector\PropertyFetch\RenamePropertyRector
    [applying] Rector\Symfony\Rector\Class_\MakeCommandLazyRector
    [applying] Rector\Symfony\Rector\Class_\EventListenerToEventSubscriberRector
    [applying] Rector\CodingStyle\Rector\Class_\AddArrayDefaultToArrayPropertyRector
    [applying] Rector\CodingStyle\Rector\ClassConst\SplitGroupedConstantsAndPropertiesRector
    [applying] Rector\CodingStyle\Rector\Property\AddFalseDefaultToBoolPropertyRector
    [applying] Rector\Php80\Rector\FunctionLike\UnionTypesRector
    [applying] Rector\Arguments\Rector\ClassMethod\ArgumentAdderRector
    [applying] Rector\Php80\Rector\ClassMethod\SetStateToStaticRector
    [applying] Rector\Php80\Rector\ClassMethod\FinalPrivateToPrivateVisibilityRector
    [applying] Rector\Php80\Rector\ClassMethod\OptionalParametersAfterRequiredRector
    [applying] Rector\Renaming\Rector\MethodCall\RenameMethodRector
    [applying] Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector
    [applying] Rector\CodingStyle\Rector\ClassMethod\NewlineBeforeNewAssignSetRector
    [applying] Rector\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector
    [applying] Rector\CodingStyle\Rector\ClassMethod\RemoveDoubleUnderscoreInMethodNameRector
    [applying] Rector\CodingStyle\Rector\ClassMethod\UnSpreadOperatorRector
    [applying] Rector\CodingStyle\Rector\Assign\PHPStormVarAnnotationRector
    [applying] Rector\CodingStyle\Rector\Assign\SplitDoubleAssignRector
    [applying] Rector\CodingStyle\Rector\Assign\ManualJsonStringToJsonEncodeArrayRector
    [applying] Rector\Symfony\Rector\New_\PropertyPathMapperToDataMapperRector
    [applying] Rector\Symfony\Rector\New_\PropertyAccessorCreationBooleanToFlagsRector
    [applying] Rector\CodingStyle\Rector\If_\NullableCompareToNullRector
    [applying] Rector\Php80\Rector\FuncCall\ClassOnObjectRector
    [applying] Rector\Php80\Rector\FuncCall\TokenGetAllToObjectRector
    [applying] Rector\Renaming\Rector\FuncCall\RenameFunctionRector
    [applying] Rector\Arguments\Rector\FuncCall\FunctionArgumentDefaultValueReplacerRector
    [applying] Rector\Php80\Rector\FuncCall\Php8ResourceReturnToObjectRector
    [applying] Rector\CodingStyle\Rector\FuncCall\ConsistentImplodeRector
    [applying] Rector\CodingStyle\Rector\FuncCall\ConsistentPregDelimiterRector
    [applying] Rector\CodingStyle\Rector\FuncCall\CallUserFuncArrayToVariadicRector
    [applying] Rector\CodingStyle\Rector\FuncCall\VersionCompareFuncCallToConstantRector
    [applying] Rector\Transform\Rector\FuncCall\FuncCallToConstFetchRector
    [applying] Rector\CodingStyle\Rector\String_\SymplifyQuoteEscapeRector
    [applying] Rector\CodingStyle\Rector\String_\SplitStringClassConstantToClassConstFetchRector
    [applying] Rector\Php55\Rector\String_\StringClassNameToClassConstantRector
    [applying] Rector\Symfony\Rector\MethodCall\ReflectionExtractorEnableMagicCallExtractorRector
    [applying] Rector\Symfony\Rector\MethodCall\DefinitionAliasSetPrivateToSetPublicRector
    [applying] Rector\Symfony\Rector\MethodCall\FormBuilderSetDataMapperRector
    [applying] Rector\Symfony\Rector\MethodCall\ValidatorBuilderEnableAnnotationMappingRector
    [applying] Rector\Symfony\Rector\BinaryOp\ResponseStatusCodeRector
    [applying] Rector\Symfony\Rector\MethodCall\ContainerGetToConstructorInjectionRector
    [applying] Rector\Symfony\Rector\MethodCall\GetParameterToConstructorInjectionRector
    [applying] Rector\Symfony\Rector\MethodCall\GetToConstructorInjectionRector
    [applying] Rector\CodingStyle\Rector\MethodCall\UseMessageVariableForSprintfInSymfonyStyleRector
[post rectors] src/Entity/Image.php
    [post rector] Rector\PostRector\Rector\NodeToReplacePostRector

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions