PluginProbe
WindPress – Tailwind CSS integration for WordPress / 3.0.13
WindPress – Tailwind CSS integration for WordPress v3.0.13
3.2.90 3.2.89 3.2.88 3.2.87 3.2.86 3.2.85 3.2.84 3.2.83 3.2.82 3.2.81 trunk 3.0.0 3.0.1 3.0.10 3.0.11 3.0.12 3.0.13 3.0.14 3.0.15 3.0.16 3.0.17 3.0.2 3.0.3 3.0.4 3.0.5 All 144 releases
windpress / vendor / symfony / finder / Glob.php

Glob.php in WindPress – Tailwind CSS integration for WordPress 3.0.13, at vendor/symfony/finder/Glob.php

103 lines 3.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11 namespace WindPressDeps\Symfony\Component\Finder;
12
13 /**
14 * Glob matches globbing patterns against text.
15 *
16 * if match_glob("foo.*", "foo.bar") echo "matched\n";
17 *
18 * // prints foo.bar and foo.baz
19 * $regex = glob_to_regex("foo.*");
20 * for (['foo.bar', 'foo.baz', 'foo', 'bar'] as $t)
21 * {
22 * if (/$regex/) echo "matched: $car\n";
23 * }
24 *
25 * Glob implements glob(3) style matching that can be used to match
26 * against text, rather than fetching names from a filesystem.
27 *
28 * Based on the Perl Text::Glob module.
29 *
30 * @author Fabien Potencier <fabien@symfony.com> PHP port
31 * @author Richard Clamp <richardc@unixbeard.net> Perl version
32 * @copyright 2004-2005 Fabien Potencier <fabien@symfony.com>
33 * @copyright 2002 Richard Clamp <richardc@unixbeard.net>
34 */
35 class Glob
36 {
37 /**
38 * Returns a regexp which is the equivalent of the glob pattern.
39 *
40 * @return string
41 */
42 public static function toRegex(string $glob, bool $strictLeadingDot = \true, bool $strictWildcardSlash = \true, string $delimiter = '#')
43 {
44 $firstByte = \true;
45 $escaping = \false;
46 $inCurlies = 0;
47 $regex = '';
48 $sizeGlob = \strlen($glob);
49 for ($i = 0; $i < $sizeGlob; ++$i) {
50 $car = $glob[$i];
51 if ($firstByte && $strictLeadingDot && '.' !== $car) {
52 $regex .= '(?=[^\\.])';
53 }
54 $firstByte = '/' === $car;
55 if ($firstByte && $strictWildcardSlash && isset($glob[$i + 2]) && '**' === $glob[$i + 1] . $glob[$i + 2] && (!isset($glob[$i + 3]) || '/' === $glob[$i + 3])) {
56 $car = '[^/]++/';
57 if (!isset($glob[$i + 3])) {
58 $car .= '?';
59 }
60 if ($strictLeadingDot) {
61 $car = '(?=[^\\.])' . $car;
62 }
63 $car = '/(?:' . $car . ')*';
64 $i += 2 + isset($glob[$i + 3]);
65 if ('/' === $delimiter) {
66 $car = \str_replace('/', '\\/', $car);
67 }
68 }
69 if ($delimiter === $car || '.' === $car || '(' === $car || ')' === $car || '|' === $car || '+' === $car || '^' === $car || '$' === $car) {
70 $regex .= "\\{$car}";
71 } elseif ('*' === $car) {
72 $regex .= $escaping ? '\\*' : ($strictWildcardSlash ? '[^/]*' : '.*');
73 } elseif ('?' === $car) {
74 $regex .= $escaping ? '\\?' : ($strictWildcardSlash ? '[^/]' : '.');
75 } elseif ('{' === $car) {
76 $regex .= $escaping ? '\\{' : '(';
77 if (!$escaping) {
78 ++$inCurlies;
79 }
80 } elseif ('}' === $car && $inCurlies) {
81 $regex .= $escaping ? '}' : ')';
82 if (!$escaping) {
83 --$inCurlies;
84 }
85 } elseif (',' === $car && $inCurlies) {
86 $regex .= $escaping ? ',' : '|';
87 } elseif ('\\' === $car) {
88 if ($escaping) {
89 $regex .= '\\\\';
90 $escaping = \false;
91 } else {
92 $escaping = \true;
93 }
94 continue;
95 } else {
96 $regex .= $car;
97 }
98 $escaping = \false;
99 }
100 return $delimiter . '^' . $regex . '$' . $delimiter;
101 }
102 }
103