Skip to content

Conversation

@jiripudil
Copy link
Contributor

follow-up of #460

@jiripudil jiripudil force-pushed the invalid-type-alias-check branch from bde92c7 to 730f4bd Compare April 18, 2021 19:40
Copy link
Member

Choose a reason for hiding this comment

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

  1. The parentheses around instanceof aren't necessary, !$foo instanceof Foo works
  2. But I'd like parentheses disambiguating $foo && $bar || $baz, I honestly don't know what happens :) So there should be either ($foo && $bar) || $baz or $foo && ($bar || $baz)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ha, I guess that's some quirk of codesniffer then. When I had the disambiguating parentheses there, it reported "Useless parentheses" and since removing them helped, I didn't know it meant those parentheses around instanceof.

@ondrejmirtes
Copy link
Member

BTW do we have covered also @phpstan-import-type UserAddress from User as int?

@jiripudil
Copy link
Contributor Author

BTW do we have covered also @phpstan-import-type UserAddress from User as int?

Now we do :) it also helped make the parentheses less messy

@jiripudil jiripudil force-pushed the invalid-type-alias-check branch from b9fffc8 to ea781c7 Compare April 19, 2021 07:03
@jiripudil
Copy link
Contributor Author

I had to add back the behaviour removed in e381f0b: the resolution in the rule here actually has to bypass type aliases, otherwise it would report false positives for every alias which references a non-ObjectType 😟

@jiripudil jiripudil requested a review from ondrejmirtes April 19, 2021 11:28
@ondrejmirtes ondrejmirtes merged commit 592d3d1 into phpstan:master Apr 19, 2021
@ondrejmirtes
Copy link
Member

Thank you!

@jiripudil jiripudil deleted the invalid-type-alias-check branch April 19, 2021 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants