Skip to content

Commit 600c25b

Browse files
committed
added PHP 8 typehints
1 parent 7cd65aa commit 600c25b

File tree

1 file changed

+12
-25
lines changed

1 file changed

+12
-25
lines changed

src/Utils/Finder.php

+12-25
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,8 @@ class Finder implements \IteratorAggregate, \Countable
4949
/**
5050
* Begins search for files matching mask and all directories.
5151
* @param string|string[] $masks
52-
* @return static
5352
*/
54-
public static function find(...$masks): self
53+
public static function find(...$masks): static
5554
{
5655
$masks = $masks && is_array($masks[0]) ? $masks[0] : $masks;
5756
return (new static)->select($masks, 'isDir')->select($masks, 'isFile');
@@ -61,9 +60,8 @@ public static function find(...$masks): self
6160
/**
6261
* Begins search for files matching mask.
6362
* @param string|string[] $masks
64-
* @return static
6563
*/
66-
public static function findFiles(...$masks): self
64+
public static function findFiles(...$masks): static
6765
{
6866
$masks = $masks && is_array($masks[0]) ? $masks[0] : $masks;
6967
return (new static)->select($masks, 'isFile');
@@ -73,9 +71,8 @@ public static function findFiles(...$masks): self
7371
/**
7472
* Begins search for directories matching mask.
7573
* @param string|string[] $masks
76-
* @return static
7774
*/
78-
public static function findDirectories(...$masks): self
75+
public static function findDirectories(...$masks): static
7976
{
8077
$masks = $masks && is_array($masks[0]) ? $masks[0] : $masks;
8178
return (new static)->select($masks, 'isDir');
@@ -84,9 +81,8 @@ public static function findDirectories(...$masks): self
8481

8582
/**
8683
* Creates filtering group by mask & type selector.
87-
* @return static
8884
*/
89-
private function select(array $masks, string $type): self
85+
private function select(array $masks, string $type): static
9086
{
9187
$this->cursor = &$this->groups[];
9288
$pattern = self::buildPattern($masks);
@@ -100,9 +96,8 @@ private function select(array $masks, string $type): self
10096
/**
10197
* Searches in the given folder(s).
10298
* @param string|string[] $paths
103-
* @return static
10499
*/
105-
public function in(...$paths): self
100+
public function in(...$paths): static
106101
{
107102
$this->maxDepth = 0;
108103
return $this->from(...$paths);
@@ -112,9 +107,8 @@ public function in(...$paths): self
112107
/**
113108
* Searches recursively from the given folder(s).
114109
* @param string|string[] $paths
115-
* @return static
116110
*/
117-
public function from(...$paths): self
111+
public function from(...$paths): static
118112
{
119113
if ($this->paths) {
120114
throw new Nette\InvalidStateException('Directory to search has already been specified.');
@@ -127,9 +121,8 @@ public function from(...$paths): self
127121

128122
/**
129123
* Shows folder content prior to the folder.
130-
* @return static
131124
*/
132-
public function childFirst(): self
125+
public function childFirst(): static
133126
{
134127
$this->order = RecursiveIteratorIterator::CHILD_FIRST;
135128
return $this;
@@ -248,9 +241,8 @@ private function buildIterator(string $path): \Iterator
248241
* Restricts the search using mask.
249242
* Excludes directories from recursive traversing.
250243
* @param string|string[] $masks
251-
* @return static
252244
*/
253-
public function exclude(...$masks): self
245+
public function exclude(...$masks): static
254246
{
255247
$masks = $masks && is_array($masks[0]) ? $masks[0] : $masks;
256248
$pattern = self::buildPattern($masks);
@@ -264,9 +256,8 @@ public function exclude(...$masks): self
264256
/**
265257
* Restricts the search using callback.
266258
* @param callable $callback function (RecursiveDirectoryIterator $file): bool
267-
* @return static
268259
*/
269-
public function filter(callable $callback): self
260+
public function filter(callable $callback): static
270261
{
271262
$this->cursor[] = $callback;
272263
return $this;
@@ -275,9 +266,8 @@ public function filter(callable $callback): self
275266

276267
/**
277268
* Limits recursion level.
278-
* @return static
279269
*/
280-
public function limitDepth(int $depth): self
270+
public function limitDepth(int $depth): static
281271
{
282272
$this->maxDepth = $depth;
283273
return $this;
@@ -287,9 +277,8 @@ public function limitDepth(int $depth): self
287277
/**
288278
* Restricts the search by size.
289279
* @param string $operator "[operator] [size] [unit]" example: >=10kB
290-
* @return static
291280
*/
292-
public function size(string $operator, int $size = null): self
281+
public function size(string $operator, int $size = null): static
293282
{
294283
if (func_num_args() === 1) { // in $operator is predicate
295284
if (!preg_match('#^(?:([=<>!]=?|<>)\s*)?((?:\d*\.)?\d+)\s*(K|M|G|)B?$#Di', $operator, $matches)) {
@@ -307,10 +296,8 @@ public function size(string $operator, int $size = null): self
307296
/**
308297
* Restricts the search by modified time.
309298
* @param string $operator "[operator] [date]" example: >1978-01-23
310-
* @param string|int|\DateTimeInterface $date
311-
* @return static
312299
*/
313-
public function date(string $operator, $date = null): self
300+
public function date(string $operator, string|int|\DateTimeInterface $date = null): static
314301
{
315302
if (func_num_args() === 1) { // in $operator is predicate
316303
if (!preg_match('#^(?:([=<>!]=?|<>)\s*)?(.+)$#Di', $operator, $matches)) {

0 commit comments

Comments
 (0)