11
11
12
12
namespace Symfony \Component \Finder ;
13
13
14
+ use Symfony \Component \Finder \Comparator \ComparatorFactory ;
14
15
use Symfony \Component \Finder \Comparator \DateComparator ;
15
16
use Symfony \Component \Finder \Comparator \NumberComparator ;
16
17
use Symfony \Component \Finder \Iterator \CustomFilterIterator ;
@@ -107,17 +108,21 @@ public function files()
107
108
*
108
109
* $finder->depth('> 1') // the Finder will start matching at level 1.
109
110
* $finder->depth('< 3') // the Finder will descend at most 3 levels of directories below the starting point.
111
+ * $finder->depth(['>= 1', '< 3'])
110
112
*
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
112
114
*
113
115
* @return $this
114
116
*
115
117
* @see DepthRangeFilterIterator
116
118
* @see NumberComparator
117
119
*/
118
- public function depth ($ level )
120
+ public function depth ($ levels )
119
121
{
120
- $ this ->depths [] = new Comparator \NumberComparator ($ level );
122
+ $ this ->depths = \array_merge (
123
+ $ this ->depths ,
124
+ ComparatorFactory::createBatch (NumberComparator::class, (array ) $ levels )
125
+ );
121
126
122
127
return $ this ;
123
128
}
@@ -131,18 +136,22 @@ public function depth($level)
131
136
* $finder->date('until 2 days ago');
132
137
* $finder->date('> now - 2 hours');
133
138
* $finder->date('>= 2005-10-15');
139
+ * $finder->date(['>= 2005-10-15', '>= 2005-05-27']);
134
140
*
135
- * @param string $date A date range string
141
+ * @param string|string[] $dates A date range string or an array of date ranges
136
142
*
137
143
* @return $this
138
144
*
139
145
* @see strtotime
140
146
* @see DateRangeFilterIterator
141
147
* @see DateComparator
142
148
*/
143
- public function date ($ date )
149
+ public function date ($ dates )
144
150
{
145
- $ this ->dates [] = new Comparator \DateComparator ($ date );
151
+ $ this ->dates = \array_merge (
152
+ $ this ->dates ,
153
+ ComparatorFactory::createBatch (DateComparator::class, (array ) $ dates )
154
+ );
146
155
147
156
return $ this ;
148
157
}
@@ -155,32 +164,33 @@ public function date($date)
155
164
* $finder->name('*.php')
156
165
* $finder->name('/\.php$/') // same as above
157
166
* $finder->name('test.php')
167
+ * $finder->name(['test.py', 'test.php'])
158
168
*
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
160
170
*
161
171
* @return $this
162
172
*
163
173
* @see FilenameFilterIterator
164
174
*/
165
- public function name ($ pattern )
175
+ public function name ($ patterns )
166
176
{
167
- $ this ->names [] = $ pattern ;
177
+ $ this ->names = \array_merge ( $ this -> names , ( array ) $ patterns ) ;
168
178
169
179
return $ this ;
170
180
}
171
181
172
182
/**
173
183
* Adds rules that files must not match.
174
184
*
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
176
186
*
177
187
* @return $this
178
188
*
179
189
* @see FilenameFilterIterator
180
190
*/
181
- public function notName ($ pattern )
191
+ public function notName ($ patterns )
182
192
{
183
- $ this ->notNames [] = $ pattern ;
193
+ $ this ->notNames = \array_merge ( $ this -> notNames , ( array ) $ patterns ) ;
184
194
185
195
return $ this ;
186
196
}
@@ -192,16 +202,17 @@ public function notName($pattern)
192
202
*
193
203
* $finder->contains('Lorem ipsum')
194
204
* $finder->contains('/Lorem ipsum/i')
205
+ * $finder->contains(['dolor', '/ipsum/i'])
195
206
*
196
- * @param string $pattern A pattern (string or regexp)
207
+ * @param string|string[] $patterns A pattern (string or regexp) or an array of patterns
197
208
*
198
209
* @return $this
199
210
*
200
211
* @see FilecontentFilterIterator
201
212
*/
202
- public function contains ($ pattern )
213
+ public function contains ($ patterns )
203
214
{
204
- $ this ->contains [] = $ pattern ;
215
+ $ this ->contains = \array_merge ( $ this -> contains , ( array ) $ patterns ) ;
205
216
206
217
return $ this ;
207
218
}
@@ -213,16 +224,17 @@ public function contains($pattern)
213
224
*
214
225
* $finder->notContains('Lorem ipsum')
215
226
* $finder->notContains('/Lorem ipsum/i')
227
+ * $finder->notContains(['lorem', '/dolor/i'])
216
228
*
217
- * @param string $pattern A pattern (string or regexp)
229
+ * @param string|string[] $patterns A pattern (string or regexp) or an array of patterns
218
230
*
219
231
* @return $this
220
232
*
221
233
* @see FilecontentFilterIterator
222
234
*/
223
- public function notContains ($ pattern )
235
+ public function notContains ($ patterns )
224
236
{
225
- $ this ->notContains [] = $ pattern ;
237
+ $ this ->notContains = \array_merge ( $ this -> notContains , ( array ) $ patterns ) ;
226
238
227
239
return $ this ;
228
240
}
@@ -234,18 +246,19 @@ public function notContains($pattern)
234
246
*
235
247
* $finder->path('some/special/di
A377
r')
236
248
* $finder->path('/some\/special\/dir/') // same as above
249
+ * $finder->path(['some dir', 'another/dir'])
237
250
*
238
251
* Use only / as dirname separator.
239
252
*
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
241
254
*
242
255
* @return $this
243
256
*
244
257
* @see FilenameFilterIterator
245
258
*/
246
- public function path ($ pattern )
259
+ public function path ($ patterns )
247
260
{
248
- $ this ->paths [] = $ pattern ;
261
+ $ this ->paths = \array_merge ( $ this -> paths , ( array ) $ patterns ) ;
249
262
250
263
return $ this ;
251
264
}
@@ -257,18 +270,19 @@ public function path($pattern)
257
270
*
258
271
* $finder->notPath('some/special/dir')
259
272
* $finder->notPath('/some\/special\/dir/') // same as above
273
+ * $finder->notPath(['some/file.txt', 'another/file.log'])
260
274
*
261
275
* Use only / as dirname separator.
262
276
*
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
264
278
*
265
279
* @return $this
266
280
*
267
281
* @see FilenameFilterIterator
268
282
*/
269
- public function notPath ($ pattern )
283
+ public function notPath ($ patterns )
270
284
{
271
- $ this ->notPaths [] = $ pattern ;
285
+ $ this ->notPaths = \array_merge ( $ this -> notPaths , ( array ) $ patterns ) ;
272
286
273
287
return $ this ;
274
288
}
@@ -279,17 +293,21 @@ public function notPath($pattern)
279
293
* $finder->size('> 10K');
280
294
* $finder->size('<= 1Ki');
281
295
* $finder->size(4);
296
+ * $finder->size(['> 10K', '< 20K'])
282
297
*
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
284
299
*
285
300
* @return $this
286
301
*
287
302
* @see SizeRangeFilterIterator
288
303
* @see NumberComparator
289
304
*/
290
- public function size ($ size )
305
+ public function size ($ sizes )
291
306
{
292
- $ this ->sizes [] = new Comparator \NumberComparator ($ size );
307
+ $ this ->sizes = \array_merge (
308
+ $ this ->sizes ,
309
+ ComparatorFactory::createBatch (NumberComparator::class, (array ) $ sizes )
310
+ );
293
311
294
312
return $ this ;
295
313
}
0 commit comments