Skip to content

Fix various static calls errors in PHPUnit Rectors.#2997

Merged
TomasVotruba merged 1 commit intorectorphp:masterfrom
gnutix:static-call-fixes
Mar 3, 2020
Merged

Fix various static calls errors in PHPUnit Rectors.#2997
TomasVotruba merged 1 commit intorectorphp:masterfrom
gnutix:static-call-fixes

Conversation

@gnutix
Copy link
Copy Markdown
Contributor

@gnutix gnutix commented Mar 3, 2020

Fixes remaining Rectors of #2953 and #2990 (PS: I tried ! $firstArgumentValue instanceof FuncCall but it broke many tests, so I kept $firstArgumentValue instanceof StaticCall and put it in its own if)

@gnutix gnutix requested a review from TomasVotruba March 3, 2020 12:36
}

$firstArgumentValue = $node->args[0]->value;
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.

Again, should be ! $firstArgumentValue instanceof FuncCall
Always go for stricter condition.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I tried and it broke the tests.

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.

How?

Copy link
Copy Markdown
Contributor Author

@gnutix gnutix Mar 3, 2020

Choose a reason for hiding this comment

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

I don't remember by heart and I don't have more time to dedicate to this.

Feel free to try triggering the failing tests yourself (by applying the change you're suggesting) and you can then decide if you want to write this any differently.

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.

Alright. Let's give it a go now, and wait for more issues

Comment on lines +85 to 88
if ($firstArgumentValue instanceof StaticCall) {
return null;
}
if (! $this->isName($firstArgumentValue, 'property_exists')) {
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.

Same with FuncCall

Comment on lines +76 to +78
if ($firstArgumentValue instanceof StaticCall) {
return null;
}
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.

Same

@TomasVotruba
Copy link
Copy Markdown
Member

Good job with right places to fix this 👍

@TomasVotruba TomasVotruba merged commit e9ee423 into rectorphp:master Mar 3, 2020
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