Skip to content

Conversation

@TomasVotruba
Copy link
Member

No description provided.

@TomasVotruba TomasVotruba changed the title remove beforeTraverse() from DowngradeNullsafeToTernaryOperatorRector remove @final beforeTraverse() override from DowngradeNullsafeToTernaryOperatorRector Dec 20, 2025
@TomasVotruba TomasVotruba force-pushed the tv-remove-before-traverser branch from a39a4dc to 928e111 Compare December 20, 2025 09:17
@TomasVotruba TomasVotruba changed the title remove @final beforeTraverse() override from DowngradeNullsafeToTernaryOperatorRector Remove @final beforeTraverse() override from DowngradeNullsafeToTernaryOperatorRector Dec 20, 2025
@TomasVotruba TomasVotruba merged commit bdbd022 into main Dec 20, 2025
8 checks passed
@TomasVotruba TomasVotruba deleted the tv-remove-before-traverser branch December 20, 2025 09:17
public function run($value)
{
return ($nullsafeVariable1 = $this->extractArrayItemByKey($value)) ? $nullsafeVariable1->value : null;
return ($nullsafeVariable6 = $this->extractArrayItemByKey($value)) ? $nullsafeVariable6->value : null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The NamedVariableFactory::createVariable() should make increment variable name consistent per file

public function createVariable(string $variableName, Expression $expression): Variable

, I will create PR for it.

Copy link
Member

@samsonasik samsonasik Dec 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scope seems can't detect variable exists on new just created variable node so the counter seems need on file level, so static flag may needed, something like:

        static $currentFile = $this->file;

        if ($currentFile !== $this->file) {
            $this->counter = 0;
            $currentFile = $this->file;
        }

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants