-
Notifications
You must be signed in to change notification settings - Fork 473
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
Bleeding edge: stricter ++/-- operator check #3255
Bleeding edge: stricter ++/-- operator check #3255
Conversation
$a = $simpleXMLElement; | ||
$a++; | ||
$a = $simpleXMLElement; | ||
--$a; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was allowed by the previous version of the rule as well (due to ObjectType::toNumber
). And it does seem to work in PHP 8.3, but not in earlier versions. However, I don't see this change mentioned in the documentation. I'm not entirely sure how best to handle it, so I kept it allowed.
$classWithToString = new ClassWithToString(); | ||
$classWithToString++; | ||
$classWithToString = new ClassWithToString(); | ||
--$classWithToString; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: This does work in PHP 7: https://3v4l.org/oXvs8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It actually works even without __toString()
, but I'm not sure whether it can be used for anything useful with custom classes: https://3v4l.org/uXLrP I'd prefer to keep it disabled even for PHP 7 unless there is a use-case for it.
This pull request has been marked as ready for review. |
Thank you! |
The goal of this PR was to check mixed in
++
/--
, but while I was at it I also fixed several other cases which were not previously reported (pretty much the same as the binary/unary operator PRs).Current behavior: https://phpstan.org/r/974fc0d6-90ba-4b72-8d83-edff03ac3482