Skip to content
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

Merged
merged 1 commit into from
Aug 19, 2024

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Aug 2, 2024

@staabm staabm marked this pull request as ready for review August 4, 2024 07:45
@@ -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);
Copy link
Member

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?

Copy link
Contributor Author

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);
Copy link
Member

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.

Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Seldaek Seldaek merged commit f07280d into composer:2.x Aug 19, 2024
11 of 12 checks passed
@staabm staabm deleted the stan branch August 19, 2024 15:22
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.

2 participants