-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
Support matchAll* variants in PHPStan extensions #32
Conversation
@@ -52,6 +55,10 @@ public function getParameterOutTypeFromStaticMethodCall(MethodReflection $method | |||
return null; | |||
} | |||
|
|||
if (stripos($methodReflection->getName(), 'matchAll') !== false) { | |||
return $this->regexShapeMatcher->matchAllExpr($patternArg->value, $flagsType, TrinaryLogic::createMaybe(), $scope); |
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.
This probably should be conditional on the matchAllExpr method existing, otherwise older phpstan version will break.. So either that or we need to bump the phpstan/phpstan conflict rule?
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.
Agree.
I am on vacation atm - cannot work on it now
@@ -67,7 +71,12 @@ public function specifyTypes(MethodReflection $methodReflection, StaticCall $nod | |||
return new SpecifiedTypes(); | |||
} | |||
|
|||
$matchedType = $this->regexShapeMatcher->matchExpr($patternArg->value, $flagsType, TrinaryLogic::createFromBoolean($context->true()), $scope); | |||
if (stripos($methodReflection->getName(), 'matchAll') !== false) { | |||
$matchedType = $this->regexShapeMatcher->matchAllExpr($patternArg->value, $flagsType, TrinaryLogic::createFromBoolean($context->true()), $scope); |
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.
Same here.. Probably easiest to bump the conflict rule tbh, not worth having ugly code here.
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.
Ok I did this myself in a follow-up commit. Thanks for the PR! I guess preg_replace_callback could also be done now with phpstan 1.11.10?
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.
analog phpstan/phpstan-src#3256