phpstan-src icon indicating copy to clipboard operation
phpstan-src copied to clipboard

Fix `class-string<*>` being supertype of any string literal

Open jrmajor opened this issue 2 years ago • 6 comments

Fixes phpstan/phpstan#10076.

jrmajor avatar Oct 31 '23 15:10 jrmajor

You've opened the pull request against the latest branch 1.11.x. If your code is relevant on 1.10.x and you want it to be released sooner, please rebase your pull request and change its target to 1.10.x.

phpstan-bot avatar Oct 31 '23 15:10 phpstan-bot

Hi, changes to isSuperTypeOf need to be verified in TypeCombinatorTest::testUnion and testIntersect. So please add some cases to the data providers there.

You need to test expectations with different types that should hit different branches in that method.

Thank you.

ondrejmirtes avatar Oct 31 '23 15:10 ondrejmirtes

This pull request has been marked as ready for review.

phpstan-bot avatar Oct 31 '23 15:10 phpstan-bot

Hi, thank you for such a quick reply :)

You need to test expectations with different types that should hit different branches in that method.

Are the tests that I've added sufficient, or do I need to add some for the branches that I didn't touch too?

jrmajor avatar Oct 31 '23 15:10 jrmajor

This broke the test for phpstan/phpstan#6697. Not sure what to do here. Fixing phpstan/phpstan#10076 requires assuming that constant string is not a class-string unless PHPStan knows about that class, while phpstan/phpstan#6697 relies on the assumption that constant string may be a name of a class that PHPStan doesn't know about.

jrmajor avatar Oct 31 '23 20:10 jrmajor

@ondrejmirtes Friendly ping, I need your decision here.

jrmajor avatar Dec 15 '23 20:12 jrmajor