-
Notifications
You must be signed in to change notification settings - Fork 473
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 - Narrow types in alternation of top level capturing groups #3202
Conversation
This pull request has been marked as ready for review. |
src/Type/Php/RegexCapturingGroup.php
Outdated
private bool $inOptionalQuantification, | ||
private RegexCapturingGroup|RegexNonCapturingGroup|null $parent, | ||
) | ||
{ | ||
$this->id = self::$idGenerator; | ||
self::$idGenerator++; |
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 don't like global state like that. This should be passed as a plain number from the outside and counted in the instance that creates objects of this class.
} | ||
assertType('array{0: string, 1: string, 2: string, 3?: string, 4?: string}', $matches); | ||
|
||
if (preg_match('~^(?:(\\d+)x(\\d+)|(\\d+)|x(\\d+))?$~', $size, $matches) !== 1) { |
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.
Better to divide this in multiple functions, reusing the $matches
variable like that seems dirty to me.
feedback addressed - thank you |
Thank you! |
fixes the 2 repros of phpstan/phpstan#11221 (comment)