@@ -84,11 +84,7 @@ public function isSatisfiedBy(array $value) : bool
8484 return false ;
8585 }
8686
87- if (preg_match ($ this ->regex , $ path )) {
88- return true ;
89- }
90-
91- return false ;
87+ return preg_match ($ this ->regex , $ path ) === 1 ;
9288 }
9389
9490 /**
@@ -118,6 +114,7 @@ private static function getStaticPrefix(string $glob) : string
118114 if (self ::isRecursiveWildcard ($ glob , $ i )) {
119115 break 2 ;
120116 }
117+
121118 break ;
122119 case '* ' :
123120 case '? ' :
@@ -134,6 +131,7 @@ private static function getStaticPrefix(string $glob) : string
134131 break ;
135132 }
136133 }
134+
137135 return $ prefix ;
138136 }
139137
@@ -151,6 +149,7 @@ private static function getBoundedPrefix(string $glob) : string
151149 if (self ::isRecursiveWildcard ($ glob , $ i )) {
152150 break 2 ;
153151 }
152+
154153 break ;
155154 case '\\' :
156155 [$ unescaped , $ consumedChars ] = self ::scanBackslashSequence ($ glob , $ i );
@@ -162,13 +161,15 @@ private static function getBoundedPrefix(string $glob) : string
162161 break ;
163162 }
164163 }
164+
165165 return $ prefix ;
166166 }
167167
168168 private static function getTotalPrefix (string $ glob ) : ?string
169169 {
170170 self ::assertValidGlob ($ glob );
171171 $ matches = [];
172+
172173 return preg_match ('~(?<! \\\\)/ \\* \\*(?:/ \\* \\*?)+$~ ' , $ glob , $ matches )
173174 ? substr ($ glob , 0 , strlen ($ glob )-strlen ($ matches [0 ]))
174175 : null ;
@@ -202,6 +203,7 @@ private static function scanBackslashSequence(string $glob, int $offset) : array
202203 default :
203204 $ result .= '\\' ;
204205 }
206+
205207 return [$ result , $ offset - $ startOffset ];
206208 }
207209
@@ -268,6 +270,7 @@ private static function toRegEx(string $glob) : string
268270 } else {
269271 $ regex .= '/ ' ;
270272 }
273+
271274 break ;
272275 case '* ' :
273276 $ regex .= '[^/]* ' ;
@@ -286,6 +289,7 @@ private static function toRegEx(string $glob) : string
286289 } else {
287290 $ regex .= '} ' ;
288291 }
292+
289293 break ;
290294 case ', ' :
291295 $ regex .= $ curlyLevels > 0 ? '| ' : ', ' ;
@@ -297,6 +301,7 @@ private static function toRegEx(string $glob) : string
297301 $ regex .= '^ ' ;
298302 ++$ i ;
299303 }
304+
300305 break ;
301306 case '] ' :
302307 $ regex .= $ inSquare ? '] ' : '\\] ' ;
@@ -326,24 +331,28 @@ private static function toRegEx(string $glob) : string
326331 $ regex .= '\\\\' ;
327332 }
328333 }
334+
329335 break ;
330336 default :
331337 $ regex .= $ c ;
332338 break ;
333339 }
334340 }
341+
335342 if ($ inSquare ) {
336343 throw new InvalidArgumentException (sprintf (
337344 'Invalid glob: missing ] in %s ' ,
338345 $ glob
339346 ));
340347 }
348+
341349 if ($ curlyLevels > 0 ) {
342350 throw new InvalidArgumentException (sprintf (
343351 'Invalid glob: missing } in %s ' ,
344352 $ glob
345353 ));
346354 }
355+
347356 return $ delimiter . '^ ' . $ regex . '$ ' . $ delimiter ;
348357 }
349358
@@ -358,6 +367,7 @@ public function canBeSatisfiedBySomethingBelow(array $value) : bool
358367 $ prefixValue = $ value ;
359368 $ prefixValue ['path ' ] = $ valuePathPrefix ;
360369 $ spec = new Glob ($ boundedPrefixGlob );
370+
361371 return $ spec ->isSatisfiedBy ($ prefixValue );
362372 }
363373
@@ -367,9 +377,11 @@ public function willBeSatisfiedByEverythingBelow(array $value) : bool
367377 if ($ this ->totalPrefix === null ) {
368378 return false ;
369379 }
380+
370381 $ spec = new Glob (rtrim ($ this ->totalPrefix , '/ ' ) . '/**/* ' );
371382 $ terminatedValue = $ value ;
372383 $ terminatedValue ['path ' ] = rtrim ($ terminatedValue ['path ' ], '/ ' ) . '/x/x ' ;
384+
373385 return $ spec ->isSatisfiedBy ($ terminatedValue );
374386 }
375387}
0 commit comments