Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit961e4d0

Browse files
committed
bug#45980 [Finder] Add support of no-capture regex modifier in MultiplePcreFilterIterator (available from PHP 8.2) (alexandre-daubois)
This PR was merged into the 4.4 branch.Discussion----------[Finder] Add support of no-capture regex modifier in MultiplePcreFilterIterator (available from PHP 8.2)| Q | A| ------------- | ---| Branch? | 4.4| Bug fix? | yes (new language feature)| New feature? | no| Deprecations? | no| Tickets | _NA_| License | MIT| Doc PR | _NA_The no-capture regex modifier has been implemented in PHP 8.2. `MultiplePcreFilterIterator` should support it, if available.- PHP Core PR:php/php-src@e089a50- Human Readable article about it:https://php.watch/versions/8.2/preg-n-no-capture-modifierCommits-------4ca973f [Finder] Add support of no-capture regex modifier in MultiplePcreFilterIterator (available from PHP 8.2)
2 parentsa90648c +4ca973f commit961e4d0

File tree

2 files changed

+27
-19
lines changed

2 files changed

+27
-19
lines changed

‎src/Symfony/Component/Finder/Iterator/MultiplePcreFilterIterator.php‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,13 @@ protected function isAccepted($string)
8383
*/
8484
protectedfunctionisRegex($str)
8585
{
86-
if (preg_match('/^(.{3,}?)[imsxuADU]*$/',$str,$m)) {
86+
$availableModifiers ='imsxuADU';
87+
88+
if (\PHP_VERSION_ID >=80200) {
89+
$availableModifiers .='n';
90+
}
91+
92+
if (preg_match('/^(.{3,}?)['.$availableModifiers.']*$/',$str,$m)) {
8793
$start =substr($m[1],0,1);
8894
$end =substr($m[1], -1);
8995

‎src/Symfony/Component/Finder/Tests/Iterator/MultiplePcreFilterIteratorTest.php‎

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,26 @@ public function testIsRegex($string, $isRegex, $message)
2727

2828
publicfunctiongetIsRegexFixtures()
2929
{
30-
return [
31-
['foo',false,'string'],
32-
[' foo',false,'" " is not a valid delimiter'],
33-
['\\foo\\',false,'"\\" is not a valid delimiter'],
34-
['afooa',false,'"a" is not a valid delimiter'],
35-
['//',false,'the pattern should contain at least 1 character'],
36-
['/a/',true,'valid regex'],
37-
['/foo/',true,'valid regex'],
38-
['/foo/i',true,'valid regex with a single modifier'],
39-
['/foo/imsxu',true,'valid regex with multiple modifiers'],
40-
['#foo#',true,'"#" is a valid delimiter'],
41-
['{foo}',true,'"{,}" is a valid delimiter pair'],
42-
['[foo]',true,'"[,]" is a valid delimiter pair'],
43-
['(foo)',true,'"(,)" is a valid delimiter pair'],
44-
['<foo>',true,'"<,>" is a valid delimiter pair'],
45-
['*foo.*',false,'"*" is not considered as a valid delimiter'],
46-
['?foo.?',false,'"?" is not considered as a valid delimiter'],
47-
];
30+
yield ['foo',false,'string'];
31+
yield [' foo',false,'" " is not a valid delimiter'];
32+
yield ['\\foo\\',false,'"\\" is not a valid delimiter'];
33+
yield ['afooa',false,'"a" is not a valid delimiter'];
34+
yield ['//',false,'the pattern should contain at least 1 character'];
35+
yield ['/a/',true,'valid regex'];
36+
yield ['/foo/',true,'valid regex'];
37+
yield ['/foo/i',true,'valid regex with a single modifier'];
38+
yield ['/foo/imsxu',true,'valid regex with multiple modifiers'];
39+
yield ['#foo#',true,'"#" is a valid delimiter'];
40+
yield ['{foo}',true,'"{,}" is a valid delimiter pair'];
41+
yield ['[foo]',true,'"[,]" is a valid delimiter pair'];
42+
yield ['(foo)',true,'"(,)" is a valid delimiter pair'];
43+
yield ['<foo>',true,'"<,>" is a valid delimiter pair'];
44+
yield ['*foo.*',false,'"*" is not considered as a valid delimiter'];
45+
yield ['?foo.?',false,'"?" is not considered as a valid delimiter'];
46+
47+
if (\PHP_VERSION_ID >=80200) {
48+
yield ['/foo/n',true,'valid regex with the no-capture modifier'];
49+
}
4850
}
4951
}
5052

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp