-
Notifications
You must be signed in to change notification settings - Fork 504
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
Narrow string on *strlen() with positive-int #3407
Conversation
&& count($exprNode->getArgs()) === 1 | ||
&& $exprNode->name instanceof Name | ||
&& in_array(strtolower((string) $exprNode->name), ['strlen', 'mb_strlen'], true) | ||
&& $constantType instanceof ConstantIntegerType |
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.
instead of comparison with ConstantIntegerType
we now support IntegerRangeType
@@ -2192,14 +2195,11 @@ public function resolveIdentical(Expr\BinaryOp\Identical $expr, Scope $scope, Ty | |||
} | |||
} | |||
|
|||
if ($rightType->isInteger()->yes() || $rightType->isString()->yes()) { | |||
if ($rightType->isString()->yes()) { |
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.
as we no longer do ConstantIntegerType
related checks in specifyTypesForConstantBinaryExpression
we can simplify this loop again to what it looked like a few weeks ago.
This pull request has been marked as ready for review. |
@@ -1283,7 +1283,7 @@ public function dataCondition(): iterable | |||
), | |||
), | |||
[ | |||
'$foo' => 'non-empty-string', | |||
'$foo' => "string & ~''", |
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.
Isn't this change weird ?
Shouldn't string & ~''
be considered as non-empty-string ?
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.
I think its the same thing, but just a difference how the type is printed
898d6c9
to
5296a87
Compare
Thank you! |
closes phpstan/phpstan#11558
separated from #3373