Skip to content

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Sep 2, 2024

Before this PR we only narrowed in comparisons with constant strings.

After this PR it works for any type of string

$argType = $scope->getType($unwrappedLeftExpr->getArgs()[0]->value);

if ($argType->isString()->yes()) {
if ($rightType->isNonFalsyString()->yes()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

instead of if ($constantStringValue !== '0') { we now rely on the type-system

@staabm staabm marked this pull request as ready for review September 2, 2024 18:46
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

@staabm staabm force-pushed the nones branch 2 times, most recently from 46481ac to 8cb61a6 Compare September 3, 2024 07:33
@ondrejmirtes ondrejmirtes merged commit 08dc679 into phpstan:1.12.x Sep 5, 2024
488 of 499 checks passed
@ondrejmirtes
Copy link
Member

Thank you!

@staabm staabm deleted the nones branch September 5, 2024 16:12
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.

3 participants