Conversation
Member
Author
|
Ugh, I forgot we are still targetting 7.2, not 7.4. |
90ac9cf to
9a3ca60
Compare
Merged
When a regex contains a capture group within another capture group followed by `?`, and the outer group is not matched, the resulting matched text for both groups will be an empty string. (1) Or, if there are no further matched capture groups, the indices for the groups will be simply omitted from the `$matches` array. (2) We want missing components of the URI to be `null` so we had a conditionals for the aforementioned matches. As of PHP 7.2, we can just use `PREG_UNMATCHED_AS_NULL` to get `null`s in the case (1): https://www.php.net/manual/en/function.preg-match.php#refsect1-function.preg-match-parameters If we raised minimum PHP version to 7.4, we would not even need the `isset` to handle (2) because from that version onward, the flag also disables the omission of tail unmatched groups: https://www.php.net/manual/en/migration74.incompatible.php#migration74.incompatible.pcre Switch the optional outer capture groups (1, 3, 6 and 8) to anonymous ones now that we are no longer using them for anything.
9a3ca60 to
176abc4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When a regex contains a capture group within another capture group followed by
?,and the outer group is not matched, the resulting matched text for both groups will be an empty string. (1)
Or, if there are no further matched capture groups, the indices for the groups will be simply omitted from the
$matchesarray. (2)We want missing components of the URI to be
nullso we had a conditionals for the aforementioned matches.As of PHP 7.2, we can just use
PREG_UNMATCHED_AS_NULLto getnulls in the case (1):https://www.php.net/manual/en/function.preg-match.php#refsect1-function.preg-match-parameters
If we raised minimum PHP version to 7.4, we would not even need the
issetto handle (2) because from that version onward, the flag also disables the omission of tail unmatched groups:https://www.php.net/manual/en/migration74.incompatible.php#migration74.incompatible.pcre
Switch the optional outer capture groups (1, 3, 6 and 8) to anonymous ones now that we are no longer using them for anything.
This is follow up to #878 and should fix the type issue in #857