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

[DeadCode] Ensure no stmts check on RemovePhpVersionIdCheckRector #2260

Merged
merged 5 commits into from
May 7, 2022

Conversation

samsonasik
Copy link
Member

@samsonasik samsonasik commented May 7, 2022

@samsonasik
Copy link
Member Author

Fixed 🎉

@samsonasik samsonasik enabled auto-merge (squash) May 7, 2022 18:39
return null;
if ($if->stmts === []) {
$this->removeNode($if);
return $if;
Copy link
Member Author

Choose a reason for hiding this comment

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

@TomasVotruba return $if is needed to avoid "applied rules" not shown in the list, ref

// nothing to change → continue
if ($node === null) {
return null;
}

which it only shows when it has node or array of stmts returns:

/** @var Node $originalNode */
$rectorWithLineChange = new RectorWithLineChange($this::class, $originalNode->getLine());
$this->file->addRectorClassWithLine($rectorWithLineChange);

Copy link
Member

Choose a reason for hiding this comment

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

The changed should be included for removed nodes too. The AbstractRector should be updated instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, I created PR #2261 for it.

Copy link
Member Author

Choose a reason for hiding this comment

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

@TomasVotruba that seems not doable by only move up the RectorWithLineChange as the information of Node removed is against original node, which if it returns null, it fallback to clone $node, which the information is for object before refactor, ref

$originalNode = $node->getAttribute(AttributeKey::ORIGINAL_NODE) ?? clone $node;

it also cause errors in other e2e tests by move it up, ref PR #2261 (comment)

@TomasVotruba
Copy link
Member

Thanks 👏

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