Skip to content

Commit a1feb1c

Browse files
committed
added PHP 8 typehints
1 parent 35e9b30 commit a1feb1c

File tree

1 file changed

+13
-26
lines changed

1 file changed

+13
-26
lines changed

src/Utils/Finder.php

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,8 @@ class Finder implements \IteratorAggregate, \Countable
5151
/**
5252
* Begins search for files and directories matching mask.
5353
* @param string|string[] $masks
54-
* @return static
5554
*/
56-
public static function find(...$masks): self
55+
public static function find(...$masks): static
5756
{
5857
$masks = $masks && is_array($masks[0]) ? $masks[0] : $masks;
5958
return (new static)->select($masks, 'isDir')->select($masks, 'isFile');
@@ -63,9 +62,8 @@ public static function find(...$masks): self
6362
/**
6463
* Begins search for files matching mask.
6564
* @param string|string[] $masks
66-
* @return static
6765
*/
68-
public static function findFiles(...$masks): self
66+
public static function findFiles(...$masks): static
6967
{
7068
$masks = $masks && is_array($masks[0]) ? $masks[0] : $masks;
7169
return (new static)->select($masks, 'isFile');
@@ -75,9 +73,8 @@ public static function findFiles(...$masks): self
7573
/**
7674
* Begins search for directories matching mask.
7775
* @param string|string[] $masks
78-
* @return static
7976
*/
80-
public static function findDirectories(...$masks): self
77+
public static function findDirectories(...$masks): static
8178
{
8279
$masks = $masks && is_array($masks[0]) ? $masks[0] : $masks;
8380
return (new static)->select($masks, 'isDir');
@@ -86,9 +83,8 @@ public static function findDirectories(...$masks): self
8683

8784
/**
8885
* Creates filtering group by mask & type selector.
89-
* @return static
9086
*/
91-
private function select(array $masks, string $type): self
87+
private function select(array $masks, string $type): static
9288
{
9389
$this->cursor = &$this->groups[];
9490
$pattern = self::buildPattern($masks);
@@ -102,9 +98,8 @@ private function select(array $masks, string $type): self
10298
/**
10399
* Searches in the given folder(s).
104100
* @param string|string[] $paths
105-
* @return static
106101
*/
107-
public function in(...$paths): self
102+
public function in(...$paths): static
108103
{
109104
$this->maxDepth = 0;
110105
return $this->from(...$paths);
@@ -114,9 +109,8 @@ public function in(...$paths): self
114109
/**
115110
* Searches recursively from the given folder(s).
116111
* @param string|string[] $paths
117-
* @return static
118112
*/
119-
public function from(...$paths): self
113+
public function from(...$paths): static
120114
{
121115
if ($this->paths) {
122116
throw new Nette\InvalidStateException('Directory to search has already been specified.');
@@ -130,9 +124,8 @@ public function from(...$paths): self
130124

131125
/**
132126
* Shows folder content prior to the folder.
133-
* @return static
134127
*/
135-
public function childFirst(): self
128+
public function childFirst(): static
136129
{
137130
$this->order = RecursiveIteratorIterator::CHILD_FIRST;
138131
return $this;
@@ -257,9 +250,8 @@ private function buildIterator(string $path): \Iterator
257250
* Restricts the search using mask.
258251
* Excludes directories from recursive traversing.
259252
* @param string|string[] $masks
260-
* @return static
261253
*/
262-
public function exclude(...$masks): self
254+
public function exclude(...$masks): static
263255
{
264256
$masks = $masks && is_array($masks[0]) ? $masks[0] : $masks;
265257
$pattern = self::buildPattern($masks);
@@ -274,9 +266,8 @@ public function exclude(...$masks): self
274266
/**
275267
* Restricts the search using callback.
276268
* @param callable $callback function (RecursiveDirectoryIterator $file): bool
277-
* @return static
278269
*/
279-
public function filter(callable $callback): self
270+
public function filter(callable $callback): static
280271
{
281272
$this->cursor[] = $callback;
282273
return $this;
@@ -285,9 +276,8 @@ public function filter(callable $callback): self
285276

286277
/**
287278
* Limits recursion level.
288-
* @return static
289279
*/
290-
public function limitDepth(int $depth): self
280+
public function limitDepth(int $depth): static
291281
{
292282
$this->maxDepth = $depth;
293283
return $this;
@@ -297,9 +287,8 @@ public function limitDepth(int $depth): self
297287
/**
298288
* Restricts the search by size.
299289
* @param string $operator "[operator] [size] [unit]" example: >=10kB
300-
* @return static
301290
*/
302-
public function size(string $operator, int $size = null): self
291+
public function size(string $operator, int $size = null): static
303292
{
304293
if (func_num_args() === 1) { // in $operator is predicate
305294
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
319308
/**
320309
* Restricts the search by modified time.
321310
* @param string $operator "[operator] [date]" example: >1978-01-23
322-
* @param string|int|\DateTimeInterface $date
323-
* @return static
324311
*/
325-
public function date(string $operator, $date = null): self
312+
public function date(string $operator, string|int|\DateTimeInterface $date = null): static
326313
{
327314
if (func_num_args() === 1) { // in $operator is predicate
328315
if (!preg_match('#^(?:([=<>!]=?|<>)\s*)?(.+)$#Di', $operator, $matches)) {
@@ -368,7 +355,7 @@ public static function compare($l, string $operator, $r): bool
368355
/********************* extension methods ****************d*g**/
369356

370357

371-
public function __call(string $name, array $args)
358+
public function __call(string $name, array $args): mixed
372359
{
373360
return isset(self::$extMethods[$name])
374361
? (self::$extMethods[$name])($this, ...$args)

0 commit comments

Comments
 (0)