Skip to content

AssertTrueFalseToSpecificMethodRector: add broken test ('Pick more specific node than PhpParser\Node\Expr\StaticCall')#2990

Merged
TomasVotruba merged 2 commits intorectorphp:masterfrom
gnutix:AssertTrueFalseToSpecificMethodRector/add-broken-test-static-call
Mar 3, 2020
Merged

AssertTrueFalseToSpecificMethodRector: add broken test ('Pick more specific node than PhpParser\Node\Expr\StaticCall')#2990
TomasVotruba merged 2 commits intorectorphp:masterfrom
gnutix:AssertTrueFalseToSpecificMethodRector/add-broken-test-static-call

Conversation

@gnutix
Copy link
Copy Markdown
Contributor

@gnutix gnutix commented Mar 3, 2020

Same as #2953.

…ecific node than PhpParser\Node\Expr\StaticCall').
@TomasVotruba
Copy link
Copy Markdown
Member

If you look at stack trace, you see the problem is here:

if (! $this->isNames($firstArgumentValue, array_keys(self::OLD_TO_NEW_METHODS))) {

The value must be $node->name, not $node. Try it

@gnutix
Copy link
Copy Markdown
Contributor Author

gnutix commented Mar 3, 2020

I did not understood your comment. But looking at the code of this Rector, it makes no sense to apply it on StaticCall methods, as it seems to be meant to replace PHP functions calls to PHPUnit specific assert methods. So I fixed it that way.

@gnutix gnutix requested a review from TomasVotruba March 3, 2020 09:28
@TomasVotruba TomasVotruba merged commit 3d0bf11 into rectorphp:master Mar 3, 2020
@TomasVotruba TomasVotruba deleted the AssertTrueFalseToSpecificMethodRector/add-broken-test-static-call branch March 3, 2020 12:04

$firstArgumentValue = $node->args[0]->value;
if (! $this->isNames($firstArgumentValue, array_keys(self::OLD_TO_NEW_METHODS))) {
if ($firstArgumentValue instanceof StaticCall ||
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What about ! FuncCall and early return null;?

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.

2 participants