Skip to content

Conversation

@staabm
Copy link
Contributor

@staabm staabm commented Dec 3, 2022

closes phpstan/phpstan#3633

see https://3v4l.org/LalXd

test fails without the src change:

1) PHPStan\Rules\Comparison\StrictComparisonOfDifferentTypesRuleTest::testBug3633
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'23: Strict comparison using === between class-string<Bug3633\HelloWorld> and 'Bug3633\\OtherClass' will always evaluate to false.
+'10: Strict comparison using === between class-string<Bug3633\HelloWorld> and 'Bug3633\\OtherClass' will always evaluate to false.
+23: Strict comparison using === between class-string<Bug3633\HelloWorld> and 'Bug3633\\OtherClass' will always evaluate to false.
+07: Strict comparison using === between class-string<Bug3633\OtherClass> and 'Bug3633\\HelloWorld' will always evaluate to false.
 35: Strict comparison using === between class-string<Bug3633\OtherClass> and 'Bug3633\\HelloWorld' will always evaluate to false.
+07: Strict comparison using === between class-string<Bug3633\FinalClass> and 'Bug3633\\HelloWorld' will always evaluate to false.
+10: Strict comparison using === between class-string<Bug3633\FinalClass> and 'Bug3633\\OtherClass' will always evaluate to false.
 50: Strict comparison using === between class-string<Bug3633\FinalClass> and 'Bug3633\\HelloWorld' will always evaluate to false.
 53: Strict comparison using === between class-string<Bug3633\FinalClass> and 'Bug3633\\OtherClass' will always evaluate to false.
 59: Strict comparison using === between 'Bug3633\\FinalClass' and 'Bug3633\\FinalClass' will always evaluate to true.
 '

@staabm staabm marked this pull request as ready for review December 3, 2022 16:05
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

@staabm staabm force-pushed the trait-get-class branch 2 times, most recently from ac100bc to c36760f Compare December 19, 2022 20:59
Copy link
Member

Choose a reason for hiding this comment

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

We can at least say that it's going to be ClassStringType.

Copy link
Member

@ondrejmirtes ondrejmirtes left a comment

Choose a reason for hiding this comment

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

Oh, I just realized this PR is more wrong than right.

  1. We need to cover the same scenario for get_class() without arguments.
  2. We can still return correct specific result for an argument that isn't $this.

@ondrejmirtes ondrejmirtes merged commit 503e820 into phpstan:1.9.x Jan 8, 2023
@ondrejmirtes
Copy link
Member

Thank you.

@staabm staabm deleted the trait-get-class branch January 8, 2023 20:53
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.

Strict comparison using === between class-string<XXX> and 'YYY' will always evaluate to false.

3 participants