1111
1212namespace Symfony \Component \Finder ;
1313
14+ use Symfony \Component \Finder \Comparator \ComparatorFactory ;
1415use Symfony \Component \Finder \Comparator \DateComparator ;
1516use Symfony \Component \Finder \Comparator \NumberComparator ;
1617use Symfony \Component \Finder \Iterator \CustomFilterIterator ;
@@ -107,17 +108,21 @@ public function files()
107108 *
108109 * $finder->depth('> 1') // the Finder will start matching at level 1.
109110 * $finder->depth('< 3') // the Finder will descend at most 3 levels of directories below the starting point.
111+ * $finder->depth(['>= 1', '< 3'])
110112 *
111- * @param string|int $level The depth level expression
113+ * @param string|int|string[]|int[] $levels The depth level expression or an array of depth levels
112114 *
113115 * @return $this
114116 *
115117 * @see DepthRangeFilterIterator
116118 * @see NumberComparator
117119 */
118- public function depth ($ level )
120+ public function depth ($ levels )
119121 {
120- $ this ->depths [] = new Comparator \NumberComparator ($ level );
122+ $ this ->depths = \array_merge (
123+ $ this ->depths ,
124+ ComparatorFactory::createBatch (NumberComparator::class, (array ) $ levels )
125+ );
121126
122127 return $ this ;
123128 }
@@ -131,18 +136,22 @@ public function depth($level)
131136 * $finder->date('until 2 days ago');
132137 * $finder->date('> now - 2 hours');
133138 * $finder->date('>= 2005-10-15');
139+ * $finder->date(['>= 2005-10-15', '>= 2005-05-27']);
134140 *
135- * @param string $date A date range string
141+ * @param string|string[] $dates A date range string or an array of date ranges
136142 *
137143 * @return $this
138144 *
139145 * @see strtotime
140146 * @see DateRangeFilterIterator
141147 * @see DateComparator
142148 */
143- public function date ($ date )
149+ public function date ($ dates )
144150 {
145- $ this ->dates [] = new Comparator \DateComparator ($ date );
151+ $ this ->dates = \array_merge (
152+ $ this ->dates ,
153+ ComparatorFactory::createBatch (DateComparator::class, (array ) $ dates )
154+ );
146155
147156 return $ this ;
148157 }
@@ -155,32 +164,33 @@ public function date($date)
155164 * $finder->name('*.php')
156165 * $finder->name('/\.php$/') // same as above
157166 * $finder->name('test.php')
167+ * $finder->name(['test.py', 'test.php'])
158168 *
159- * @param string $pattern A pattern (a regexp, a glob, or a string)
169+ * @param string|string[] $patterns A pattern (a regexp, a glob, or a string) or an array of patterns
160170 *
161171 * @return $this
162172 *
163173 * @see FilenameFilterIterator
164174 */
165- public function name ($ pattern )
175+ public function name ($ patterns )
166176 {
167- $ this ->names [] = $ pattern ;
177+ $ this ->names = \array_merge ( $ this -> names , ( array ) $ patterns ) ;
168178
169179 return $ this ;
170180 }
171181
172182 /**
173183 * Adds rules that files must not match.
174184 *
175- * @param string $pattern A pattern (a regexp, a glob, or a string)
185+ * @param string|string[] $patterns A pattern (a regexp, a glob, or a string) or an array of patterns
176186 *
177187 * @return $this
178188 *
179189 * @see FilenameFilterIterator
180190 */
181- public function notName ($ pattern )
191+ public function notName ($ patterns )
182192 {
183- $ this ->notNames [] = $ pattern ;
193+ $ this ->notNames = \array_merge ( $ this -> notNames , ( array ) $ patterns ) ;
184194
185195 return $ this ;
186196 }
@@ -192,16 +202,17 @@ public function notName($pattern)
192202 *
193203 * $finder->contains('Lorem ipsum')
194204 * $finder->contains('/Lorem ipsum/i')
205+ * $finder->contains(['dolor', '/ipsum/i'])
195206 *
196- * @param string $pattern A pattern (string or regexp)
207+ * @param string|string[] $patterns A pattern (string or regexp) or an array of patterns
197208 *
198209 * @return $this
199210 *
200211 * @see FilecontentFilterIterator
201212 */
202- public function contains ($ pattern )
213+ public function contains ($ patterns )
203214 {
204- $ this ->contains [] = $ pattern ;
215+ $ this ->contains = \array_merge ( $ this -> contains , ( array ) $ patterns ) ;
205216
206217 return $ this ;
207218 }
@@ -213,16 +224,17 @@ public function contains($pattern)
213224 *
214225 * $finder->notContains('Lorem ipsum')
215226 * $finder->notContains('/Lorem ipsum/i')
227+ * $finder->notContains(['lorem', '/dolor/i'])
216228 *
217- * @param string $pattern A pattern (string or regexp)
229+ * @param string|string[] $patterns A pattern (string or regexp) or an array of patterns
218230 *
219231 * @return $this
220232 *
221233 * @see FilecontentFilterIterator
222234 */
223- public function notContains ($ pattern )
235+ public function notContains ($ patterns )
224236 {
225- $ this ->notContains [] = $ pattern ;
237+ $ this ->notContains = \array_merge ( $ this -> notContains , ( array ) $ patterns ) ;
226238
227239 return $ this ;
228240 }
@@ -234,18 +246,19 @@ public function notContains($pattern)
234246 *
235247 * $finder->path('some/special/dir')
236248 * $finder->path('/some\/special\/dir/') // same as above
249+ * $finder->path(['some dir', 'another/dir'])
237250 *
238251 * Use only / as dirname separator.
239252 *
240- * @param string $pattern A pattern (a regexp or a string)
253+ * @param string|string[] $patterns A pattern (a regexp or a string) or an array of patterns
241254 *
242255 * @return $this
243256 *
244257 * @see FilenameFilterIterator
245258 */
246- public function path ($ pattern )
259+ public function path ($ patterns )
247260 {
248- $ this ->paths [] = $ pattern ;
261+ $ this ->paths = \array_merge ( $ this -> paths , ( array ) $ patterns ) ;
249262
250263 return $ this ;
251264 }
@@ -257,18 +270,19 @@ public function path($pattern)
257270 *
258271 * $finder->notPath('some/special/dir')
259272 * $finder->notPath('/some\/special\/dir/') // same as above
273+ * $finder->notPath(['some/file.txt', 'another/file.log'])
260274 *
261275 * Use only / as dirname separator.
262276 *
263- * @param string $pattern A pattern (a regexp or a string)
277+ * @param string|string[] $patterns A pattern (a regexp or a string) or an array of patterns
264278 *
265279 * @return $this
266280 *
267281 * @see FilenameFilterIterator
268282 */
269- public function notPath ($ pattern )
283+ public function notPath ($ patterns )
270284 {
271- $ this ->notPaths [] = $ pattern ;
285+ $ this ->notPaths = \array_merge ( $ this -> notPaths , ( array ) $ patterns ) ;
272286
273287 return $ this ;
274288 }
@@ -279,17 +293,21 @@ public function notPath($pattern)
279293 * $finder->size('> 10K');
280294 * $finder->size('<= 1Ki');
281295 * $finder->size(4);
296+ * $finder->size(['> 10K', '< 20K'])
282297 *
283- * @param string|int $size A size range string or an integer
298+ * @param string|int|string[]|int[] $sizes A size range string or an integer or an array of size ranges
284299 *
285300 * @return $this
286301 *
287302 * @see SizeRangeFilterIterator
288303 * @see NumberComparator
289304 */
290- public function size ($ size )
305+ public function size ($ sizes )
291306 {
292- $ this ->sizes [] = new Comparator \NumberComparator ($ size );
307+ $ this ->sizes = \array_merge (
308+ $ this ->sizes ,
309+ ComparatorFactory::createBatch (NumberComparator::class, (array ) $ sizes )
310+ );
293311
294312 return $ this ;
295313 }
0 commit comments