@@ -51,9 +51,8 @@ class Finder implements \IteratorAggregate, \Countable
51
51
/**
52
52
* Begins search for files and directories matching mask.
53
53
* @param string|string[] $masks
54
- * @return static
55
54
*/
56
- public static function find (...$ masks ): self
55
+ public static function find (...$ masks ): static
57
56
{
58
57
$ masks = $ masks && is_array ($ masks [0 ]) ? $ masks [0 ] : $ masks ;
59
58
return (new static )->select ($ masks , 'isDir ' )->select ($ masks , 'isFile ' );
@@ -63,9 +62,8 @@ public static function find(...$masks): self
63
62
/**
64
63
* Begins search for files matching mask.
65
64
* @param string|string[] $masks
66
- * @return static
67
65
*/
68
- public static function findFiles (...$ masks ): self
66
+ public static function findFiles (...$ masks ): static
69
67
{
70
68
$ masks = $ masks && is_array ($ masks [0 ]) ? $ masks [0 ] : $ masks ;
71
69
return (new static )->select ($ masks , 'isFile ' );
@@ -75,9 +73,8 @@ public static function findFiles(...$masks): self
75
73
/**
76
74
* Begins search for directories matching mask.
77
75
* @param string|string[] $masks
78
- * @return static
79
76
*/
80
- public static function findDirectories (...$ masks ): self
77
+ public static function findDirectories (...$ masks ): static
81
78
{
82
79
$ masks = $ masks && is_array ($ masks [0 ]) ? $ masks [0 ] : $ masks ;
83
80
return (new static )->select ($ masks , 'isDir ' );
@@ -86,9 +83,8 @@ public static function findDirectories(...$masks): self
86
83
87
84
/**
88
85
* Creates filtering group by mask & type selector.
89
- * @return static
90
86
*/
91
- private function select (array $ masks , string $ type ): self
87
+ private function select (array $ masks , string $ type ): static
92
88
{
93
89
$ this ->cursor = &$ this ->groups [];
94
90
$ pattern = self ::buildPattern ($ masks );
@@ -102,9 +98,8 @@ private function select(array $masks, string $type): self
102
98
/**
103
99
* Searches in the given folder(s).
104
100
* @param string|string[] $paths
105
- * @return static
106
101
*/
107
- public function in (...$ paths ): self
102
+ public function in (...$ paths ): static
108
103
{
109
104
$ this ->maxDepth = 0 ;
110
105
return $ this ->from (...$ paths );
@@ -114,9 +109,8 @@ public function in(...$paths): self
114
109
/**
115
110
* Searches recursively from the given folder(s).
116
111
* @param string|string[] $paths
117
- * @return static
118
112
*/
119
- public function from (...$ paths ): self
113
+ public function from (...$ paths ): static
120
114
{
121
115
if ($ this ->paths ) {
122
116
throw new Nette \InvalidStateException ('Directory to search has already been specified. ' );
@@ -130,9 +124,8 @@ public function from(...$paths): self
130
124
131
125
/**
132
126
* Shows folder content prior to the folder.
133
- * @return static
134
127
*/
135
- public function childFirst (): self
128
+ public function childFirst (): static
136
129
{
137
130
$ this ->order = RecursiveIteratorIterator::CHILD_FIRST ;
138
131
return $ this ;
@@ -257,9 +250,8 @@ private function buildIterator(string $path): \Iterator
257
250
* Restricts the search using mask.
258
251
* Excludes directories from recursive traversing.
259
252
* @param string|string[] $masks
260
- * @return static
261
253
*/
262
- public function exclude (...$ masks ): self
254
+ public function exclude (...$ masks ): static
263
255
{
264
256
$ masks = $ masks && is_array ($ masks [0 ]) ? $ masks [0 ] : $ masks ;
265
257
$ pattern = self ::buildPattern ($ masks );
@@ -274,9 +266,8 @@ public function exclude(...$masks): self
274
266
/**
275
267
* Restricts the search using callback.
276
268
* @param callable $callback function (RecursiveDirectoryIterator $file): bool
277
- * @return static
278
269
*/
279
- public function filter (callable $ callback ): self
270
+ public function filter (callable $ callback ): static
280
271
{
281
272
$ this ->cursor [] = $ callback ;
282
273
return $ this ;
@@ -285,9 +276,8 @@ public function filter(callable $callback): self
285
276
286
277
/**
287
278
* Limits recursion level.
288
- * @return static
289
279
*/
290
- public function limitDepth (int $ depth ): self
280
+ public function limitDepth (int $ depth ): static
291
281
{
292
282
$ this ->maxDepth = $ depth ;
293
283
return $ this ;
@@ -297,9 +287,8 @@ public function limitDepth(int $depth): self
297
287
/**
298
288
* Restricts the search by size.
299
289
* @param string $operator "[operator] [size] [unit]" example: >=10kB
300
- * @return static
301
290
*/
302
- public function size (string $ operator , int $ size = null ): self
291
+ public function size (string $ operator , int $ size = null ): static
303
292
{
304
293
if (func_num_args () === 1 ) { // in $operator is predicate
305
294
if (!preg_match ('#^(?:([=<>!]=?|<>)\s*)?((?:\d*\.)?\d+)\s*(K|M|G|)B?$#Di ' , $ operator , $ matches )) {
@@ -319,10 +308,8 @@ public function size(string $operator, int $size = null): self
319
308
/**
320
309
* Restricts the search by modified time.
321
310
* @param string $operator "[operator] [date]" example: >1978-01-23
322
- * @param string|int|\DateTimeInterface $date
323
- * @return static
324
311
*/
325
- public function date (string $ operator , $ date = null ): self
312
+ public function date (string $ operator , string | int | \ DateTimeInterface $ date = null ): static
326
313
{
327
314
if (func_num_args () === 1 ) { // in $operator is predicate
328
315
if (!preg_match ('#^(?:([=<>!]=?|<>)\s*)?(.+)$#Di ' , $ operator , $ matches )) {
@@ -368,7 +355,7 @@ public static function compare($l, string $operator, $r): bool
368
355
/********************* extension methods ****************d*g**/
369
356
370
357
371
- public function __call (string $ name , array $ args )
358
+ public function __call (string $ name , array $ args ): mixed
372
359
{
373
360
return isset (self ::$ extMethods [$ name ])
374
361
? (self ::$ extMethods [$ name ])($ this , ...$ args )
0 commit comments