Skip to content

Support eq and notEq #126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 10, 2022
Merged

Conversation

herndlm
Copy link
Contributor

@herndlm herndlm commented Mar 8, 2022

I don't think they add much value, but why not.
Maybe that loosely type narrowing helps prevent errors somewhere :)

@ondrejmirtes
Copy link
Member

Please add some tests that might trick the current implementation and the problems we're trying to solve, like $a == $a (always true) and also createStdClass() == createStdClass() (not always true). Thanks 😊

@herndlm
Copy link
Contributor Author

herndlm commented Mar 9, 2022

added some more tests, but I'm not entirely sure what I'm finding here and what is expected and what not. I think this needs a double-check from you :)
== is quite tricky for me compared to === where things are pretty clear

And while looking at https://www.php.net/manual/en/language.operators.comparison.php I think we could come up with more weird constant comparisons where type-juggling is involved, like 100 == "1e2" which always evaluates to equal, but I'm not sure if this is still relevant here.

@herndlm
Copy link
Contributor Author

herndlm commented Mar 9, 2022

Btw. I'm going to add more impossible-check tests for === in a similar fashion in another PR

@ondrejmirtes ondrejmirtes force-pushed the support-eq-and-not-eq branch from 3cb2670 to d3c0d4d Compare March 9, 2022 19:54
@ondrejmirtes
Copy link
Member

There's still one failure and I have no idea why.

@ondrejmirtes
Copy link
Member

Alright ,the error "+54: Call to static method Webmozart\Assert\Assert::eq() with stdClass and mixed will always evaluate to true." should not be reported, but the root issue here is that PHPStan actually doesn't see the function declaration, because it's not loaded.

Please rewrite these tests to use classes+methods, it's more reliable (and you don't have to require_once those files).

@herndlm herndlm requested a review from ondrejmirtes March 10, 2022 08:37
@ondrejmirtes ondrejmirtes merged commit c293bf4 into phpstan:master Mar 10, 2022
@ondrejmirtes
Copy link
Member

Thank you!

@herndlm herndlm deleted the support-eq-and-not-eq branch March 10, 2022 08:45
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