Distinguish between unmatched subpatterns and empty matches in preg_*()#1303
Merged
php-pulls merged 4 commits intophp:masterfrom Jan 6, 2017
Merged
Distinguish between unmatched subpatterns and empty matches in preg_*()#1303php-pulls merged 4 commits intophp:masterfrom
php-pulls merged 4 commits intophp:masterfrom
Conversation
Contributor
|
I think this makes sense. |
php-pulls
pushed a commit
that referenced
this pull request
Jan 6, 2017
* pull-request/1303: Distinguish between unmatched subpatterns and empty matches in preg_*() news entry for PR #1303
Member
|
Thanks :) |
Member
|
This needs a note in UPGRADING, as it's BC breaking. |
Member
Author
Done with commit c832ab4. |
Member
gsherwood
added a commit
to squizlabs/PHP_CodeSniffer
that referenced
this pull request
Jan 11, 2017
photodude
added a commit
to photodude/coding-standards
that referenced
this pull request
Feb 20, 2017
wilsonge
added a commit
to joomla/coding-standards
that referenced
this pull request
Feb 20, 2017
Fixed bug introduced by preg_match change from php/php-src#1303
photodude
added a commit
to photodude/coding-standards
that referenced
this pull request
Mar 7, 2017
Contributor
|
BC break, but why? Seriously, not again. |
|
Documenting BC breaks is not enough - the policy is not to have them outside major versions. Why not add a flag that controls this behaviour? |
Contributor
|
Agreed, another useless BC break in minor version. Please rather introduce something opt-in like PREG_SUBPATTERN_UNMATCHED_NULL (or whatever better) that could be turned on by default in next major version. |
|
Is this behaviour going to stay? or will it change to something BC? |
Contributor
|
This already breaks Symfony: symfony/symfony#22667 |
Contributor
|
See #2526 to make this opt-in, removing the BC break. |
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.
Currently it is not easily possible to distinguish between unmatched subpatterns (i.e. unset substrings) and empty matches in preg_match(_all); in both cases an empty string is yielded. Using PREG_OFFSET_CAPTURE makes that possible (negative offset indicate unmatched subpatterns), but that seems to be unnecessarily clumsy.
In bug #61780 it has been proposed not to set the respective keys in $matches, but that might be too big a BC break even for PHP 7.0.0. Setting those to NULL, however, might be acceptable, and would still allow to distinguish between the two cases (even with isset). Therefore I think this PR would resolve bug #61780.