Skip to content

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

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

staabm merged 9 commits into
phpstan:2.1.xfrom
staabm:lower-upper

Conversation

@staabm

@staabm staabm commented Feb 3, 2026

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Collaborator

This pull request has been marked as ready for review.

@staabm

staabm commented Feb 3, 2026

Copy link
Copy Markdown
Contributor Author

@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
Copy Markdown
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
Copy Markdown
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