Skip to content
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

Falsey scope of BooleanOr left expr not considered for NotIdentical right expr #6696

Closed
herndlm opened this issue Feb 25, 2022 · 4 comments
Closed
Labels
Milestone

Comments

@herndlm
Copy link
Contributor

herndlm commented Feb 25, 2022

Bug report

This is just the bug that is behind phpstan/phpstan-webmozart-assert#33 as Ondrej mentioned there.

Fyi I know where to look and I think the fix should be trivial (at least I hope so), will try to open a PR for this soon.

Code snippet that reproduces the problem

https://phpstan.org/r/6485efa1-485c-4abb-8611-155ce3a05e74

Expected output

No errors.

Did PHPStan help you today? Did it make you happy in any way?

Just updated PHPStan in some projects, which resulted in 2 baseline error removals. yay :)

@herndlm
Copy link
Contributor Author

herndlm commented Feb 25, 2022

Ah okay, this is a bit different than I thought.. Looks like the problem is the SpecifiedTypes intersection again. The left part creates a null sureType, the right part a '' sureNotType and those cannot be intersected like that. It would work if both parts have a sureType or a sureNotType for $s. I'm thinking about my weird SubtractedType solution again which could work somehow by transforming between those types if needed in e.g. the normalization, but it is, well, weird :D And I assume there will be some edge cases again where it won't work and needs workarounds..

An alternative might be to somehow use the current type via scope in the Identical specification, but that one is quite complex with many different paths, need to take a deeper look later.

@ondrejmirtes ondrejmirtes added this to the Easy fixes milestone Feb 25, 2022
@ondrejmirtes
Copy link
Member

Solved it, hopefully it makes sense: phpstan/phpstan-src@cc6655f

@herndlm
Copy link
Contributor Author

herndlm commented Feb 25, 2022

Makes sense to me, my solution was already pretty close to yours too :)

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants