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
infer non-empty-string on literal-string and strlen() #1260
Conversation
memory related errors are also present on latest 1.6.x branch, therefore feel unrelated |
@@ -235,9 +237,19 @@ public function specifyTypesInCondition( | |||
$newContext = $newContext->negate(); | |||
} | |||
$argType = $scope->getType($exprNode->getArgs()[0]->value); | |||
if ($argType instanceof StringType) { |
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.
primary motivation was killing instanceof StringType
checks
I am on holiday for a few days. Will investigate the webmozart/assert error after coming back... |
You actually fixed something see comment in test file there ;) I overdid it with some of the tests.. |
Even better :-) |
Just added a commit here: 2821732 The takeaway is - if something already is something, you don't need to tell TypeSpecifier to narrow it down again. So if you have strlen($literalString), TypeSpecifier doesn't need to say "add literal-string again". |
So the useful thing is: - if ($argType instanceof StringType) {
+ if ($argType->isString()->yes()) { Which is great and should be done in more relevant places. |
Thank you. |
Yep, I am on it - after holiday :-) |
No description provided.