-
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 - trailling groups are not optional when PREG_UNMATCHED_AS_NULL #3219
Conversation
…UNMATCHED_AS_NULL
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. |
@@ -116,13 +116,6 @@ function doOffsetCapture(string $s): void { | |||
assertType('array{}|array{array{string, int<0, max>}, array{string, int<0, max>}, array{string, int<0, max>}, array{string, int<0, max>}}', $matches); | |||
} | |||
|
|||
function doUnmatchedAsNull(string $s): 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.
this pre-existing test no longer has the same expectations across all php versions.
therefore I moved it into the bug-11311 tests and adjusted expectations accordingly
function doFoo(string $s) { | ||
if (1 === preg_match('/(?<major>\d+)\.(?<minor>\d+)(?:\.(?<patch>\d+))?/', $s, $matches, PREG_UNMATCHED_AS_NULL)) { | ||
|
||
assertType('array{0: string, major: string, 1: string, minor: string, 2: string, patch: string|null, 3: string|null}', $matches); |
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.
another fix this PR provides: a non-optional group cannot be null
even when PREG_UNMATCHED_AS_NULL
is given
This pull request has been marked as ready for review. |
Thank you! |
closes phpstan/phpstan#11311