-
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: fix nested capturing counting #3184
Conversation
Will have another look later |
887cc67
to
778bdb3
Compare
// add one capturing group to the end so all capture group keys | ||
// are present in the $matches | ||
// see https://3v4l.org/sOXbn, https://3v4l.org/3SdDM | ||
$captureGroupsRegex = Strings::replace($regex, '~.[a-z\s]*$~i', '|(?<phpstanNamedCaptureGroupLast>)$0'); |
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.
reworked the matcher to be AST only -> no more php version differences
@@ -172,10 +172,6 @@ public function dataFileAsserts(): iterable | |||
yield from $this->gatherAssertTypes(__DIR__ . '/../Rules/Comparison/data/bug-9499.php'); | |||
} | |||
|
|||
if (PHP_VERSION_ID >= 70300 && PHP_VERSION_ID < 70400) { | |||
yield from $this->gatherAssertTypes(__DIR__ . '/data/preg_match_shapes_php73.php'); |
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 test is contained in preg_match_shapes_php.php
with proper expectations across all php versions. we no longer need separate expectations for 7.2/7.3
I did not yet figure out, how/why the result of the last failling test-case can be different on 7.2/7.3 |
I now know what the cause of the problem is:
in PHP 7.2/7.3 the parameter is named "subpatterns" and in 7.4+ its "matches" |
ae1c954
to
7ebf48c
Compare
@@ -485,3 +485,20 @@ function ($s, $t): void { | |||
assertType('string', $s); | |||
assertType('string', $t); | |||
}; | |||
|
|||
function fooMatch(string $input): void { |
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.
expectations have been harmonized across php versions, therefore the 2 variants above removed and the tests moved with same expectations in this common file
@ondrejmirtes would be great to get this one merged, as it is now php version independent and in turn would also allow to fix the phpstan-nette build. it fixes all currently known problems ( |
Thank you! |
closes phpstan/phpstan#11221