Skip to content

Fix type specification of various string functions with constant strings in a falsey context#1488

Merged
ondrejmirtes merged 1 commit intophpstan:1.8.xfrom
herndlm:fix-7555
Jun 30, 2022
Merged

Fix type specification of various string functions with constant strings in a falsey context#1488
ondrejmirtes merged 1 commit intophpstan:1.8.xfrom
herndlm:fix-7555

Conversation

@herndlm
Copy link
Copy Markdown
Contributor

@herndlm herndlm commented Jun 30, 2022

Closes phpstan/phpstan#7555

Apparently this would return that some constant string is surely not e.g. 'ab' in a falsey scope but at the same time the scope has the info that it surely is 'ab' in a truthy scope. And that seams lead to a *NEVER* type.

The blocks before this one, that deal with a related thing, do it a bit different but very similar, e.g. https://github.com/phpstan/phpstan-src/blob/1.8.0/src/Analyser/TypeSpecifier.php#L237

@herndlm herndlm marked this pull request as ready for review June 30, 2022 20:57
@ondrejmirtes ondrejmirtes merged commit cd7f82c into phpstan:1.8.x Jun 30, 2022
@ondrejmirtes
Copy link
Copy Markdown
Member

Thank you!

@staabm
Copy link
Copy Markdown
Contributor

staabm commented Jul 1, 2022

Thx Martin!

@herndlm herndlm deleted the fix-7555 branch July 1, 2022 08:13
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.

False positive when comparing strlen($string) after testing substr($string)

3 participants