Skip to content

Comparison with strtolower() etc. leads lower/upper-case-string#4857

Merged
staabm merged 9 commits intophpstan:2.1.xfrom
staabm:lower-upper
Feb 7, 2026
Merged

Comparison with strtolower() etc. leads lower/upper-case-string#4857
staabm merged 9 commits intophpstan:2.1.xfrom
staabm:lower-upper

Conversation

@staabm
Copy link
Contributor

@staabm staabm commented Feb 3, 2026

@staabm staabm marked this pull request as ready for review February 3, 2026 16:38
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

@staabm
Copy link
Contributor Author

staabm commented Feb 3, 2026

@VincentLanglet would love your feedback, as you implemented lowser/upper case handling IIRC

{
if (strtolower($s) === 'hallo') {
assertType('non-falsy-string', $s);
assertType('lowercase-string&non-falsy-string', $s);
Copy link
Contributor

Choose a reason for hiding this comment

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

This is wrong, it's not because strtolower($s) is a lowerstring than $s is a lowercase string.

It's only the case if $s === strtolower($something)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you are right. I mixed up the operands 🫣

@staabm staabm merged commit 386da24 into phpstan:2.1.x Feb 7, 2026
633 of 639 checks passed
@staabm staabm deleted the lower-upper branch February 7, 2026 18:57
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.

non-empty-string swallows other accessory string types if narrowed first

3 participants