Skip to content

Commit 9c0f54d

Browse files
committed
[Finder] simplified code
1 parent 156368f commit 9c0f54d

File tree

6 files changed

+24
-5
lines changed

6 files changed

+24
-5
lines changed

src/Symfony/Component/Finder/Expression/Expression.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Symfony\Component\Finder\Expression;
1313

14+
@trigger_error('The '.__NAMESPACE__.'\Expression class is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
15+
1416
/**
1517
* @author Jean-François Simon <contact@jfsimon.fr>
1618
*/

src/Symfony/Component/Finder/Expression/Glob.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Symfony\Component\Finder\Expression;
1313

14+
@trigger_error('The '.__NAMESPACE__.'\Glob class is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
15+
1416
use Symfony\Component\Finder\Glob as FinderGlob;
1517

1618
/**

src/Symfony/Component/Finder/Expression/Regex.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Symfony\Component\Finder\Expression;
1313

14+
@trigger_error('The '.__NAMESPACE__.'\Regex class is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
15+
1416
/**
1517
* @author Jean-François Simon <contact@jfsimon.fr>
1618
*/

src/Symfony/Component/Finder/Expression/ValueInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Symfony\Component\Finder\Expression;
1313

14+
@trigger_error('The '.__NAMESPACE__.'\ValueInterface interface is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
15+
1416
/**
1517
* @author Jean-François Simon <contact@jfsimon.fr>
1618
*/

src/Symfony/Component/Finder/Iterator/FilenameFilterIterator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Component\Finder\Iterator;
1313

14-
use Symfony\Component\Finder\Expression\Expression;
14+
use Symfony\Component\Finder\Glob;
1515

1616
/**
1717
* FilenameFilterIterator filters files by patterns (a regexp, a glob, or a string).
@@ -42,6 +42,6 @@ public function accept()
4242
*/
4343
protected function toRegex($str)
4444
{
45-
return Expression::create($str)->getRegex()->render();
45+
return $this->isRegex($str) ? $str : Glob::toRegex($str);
4646
}
4747
}

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
namespace Symfony\Component\Finder\Iterator;
1313

14-
use Symfony\Component\Finder\Expression\Expression;
15-
1614
/**
1715
* MultiplePcreFilterIterator filters files using patterns (regexps, globs or strings).
1816
*
@@ -87,7 +85,20 @@ protected function isAccepted($string)
8785
*/
8886
protected function isRegex($str)
8987
{
90-
return Expression::create($str)->isRegex();
88+
if (preg_match('/^(.{3,}?)[imsxuADU]*$/', $str, $m)) {
89+
$start = substr($m[1], 0, 1);
90+
$end = substr($m[1], -1);
91+
92+
if ($start === $end) {
93+
return !preg_match('/[*?[:alnum:] \\\\]/', $start);
94+
}
95+
96+
if ($start === '{' && $end === '}') {
97+
return true;
98+
}
99+
}
100+
101+
return false;
91102
}
92103

93104
/**

0 commit comments

Comments
 (0)