Improved preg_match()
output param type inference
#7027
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a stub for
preg_match()
that takes flags into account.Fixes #6914
For reference:
Return Values
1
if the pattern matches given subject0
if the pattern does not match given subjectfalse
on failure$matches with flag: 0
$matches:
➡️
array<array-key, string>
$matches with flag: PREG_OFFSET_CAPTURE = 256
$matches:
➡️
array<array-key, array{string, 0|positive-int}|array{'', -1}>
↪️
array<array-key, array{string, int}>
$matches with flag: PREG_UNMATCHED_AS_NULL = 512
$matches:
➡️
array<array-key, string|null>
$matches with flag: PREG_OFFSET_CAPTURE | PREG_UNMATCHED_AS_NULL = 768
$matches:
➡️
array<array-key, array{string, 0|positive-int}|array{null, -1}>
↪️
array<array-key, array{null|string, int}>
$matches on error
On error an
E_WARNING
is emitted.$matches
is not altered then. This case is not handled in this PR.Legend:
↪️ = expression simplified by Psalm