-
Notifications
You must be signed in to change notification settings - Fork 479
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
RegexArrayShapeMatcher: Support resolving of constants in patterns #3265
Conversation
Refactors RegexArrayShapeMatcher to re-use InitializerExprTypeResolver
You've opened the pull request against the latest branch 1.12.x. If your code is relevant on 1.11.x and you want it to be released sooner, please rebase your pull request and change its target to 1.11.x. |
I think I now have a better understand how the |
This pull request has been marked as ready for review. |
Cool, less code and less bugs :D |
} else { | ||
$right = $scope->getType($concat->right); | ||
} | ||
$resolveConcat = static function (Expr $expr) use (&$resolveConcat, $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.
These are usually memory leaks. It'd be nicer to have this as a private method.
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 went with a inline class, hopefully that works for you.
didn't have a better idea on how to get the lexical $scope variable into the callable
return TypeCombinator::union(...$strings); | ||
}; | ||
|
||
return $this->initializerExprTypeResolver->getConcatType($concat->left, $concat->right, static fn (Expr $expr): Type => $resolver->resolve($expr)); |
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.
Not sure if this is supported by the php8.1=>7.2 transpile but hopefully :)
return $this->initializerExprTypeResolver->getConcatType($concat->left, $concat->right, static fn (Expr $expr): Type => $resolver->resolve($expr)); | |
return $this->initializerExprTypeResolver->getConcatType($concat->left, $concat->right, $resolver->resolve(...)); |
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.
It's not :)
Thank you. |
Refactors RegexArrayShapeMatcher to re-use InitializerExprTypeResolver
closes phpstan/phpstan#11384