diff --git a/src/Utils/Finder.php b/src/Utils/Finder.php index cd92b39..1bda094 100644 --- a/src/Utils/Finder.php +++ b/src/Utils/Finder.php @@ -49,9 +49,8 @@ class Finder implements \IteratorAggregate, \Countable /** * Begins search for files matching mask and all directories. * @param string|string[] $masks - * @return static */ - public static function find(...$masks): self + public static function find(...$masks): static { $masks = $masks && is_array($masks[0]) ? $masks[0] : $masks; return (new static)->select($masks, 'isDir')->select($masks, 'isFile'); @@ -61,9 +60,8 @@ public static function find(...$masks): self /** * Begins search for files matching mask. * @param string|string[] $masks - * @return static */ - public static function findFiles(...$masks): self + public static function findFiles(...$masks): static { $masks = $masks && is_array($masks[0]) ? $masks[0] : $masks; return (new static)->select($masks, 'isFile'); @@ -73,9 +71,8 @@ public static function findFiles(...$masks): self /** * Begins search for directories matching mask. * @param string|string[] $masks - * @return static */ - public static function findDirectories(...$masks): self + public static function findDirectories(...$masks): static { $masks = $masks && is_array($masks[0]) ? $masks[0] : $masks; return (new static)->select($masks, 'isDir'); @@ -84,9 +81,8 @@ public static function findDirectories(...$masks): self /** * Creates filtering group by mask & type selector. - * @return static */ - private function select(array $masks, string $type): self + private function select(array $masks, string $type): static { $this->cursor = &$this->groups[]; $pattern = self::buildPattern($masks); @@ -100,9 +96,8 @@ private function select(array $masks, string $type): self /** * Searches in the given folder(s). * @param string|string[] $paths - * @return static */ - public function in(...$paths): self + public function in(...$paths): static { $this->maxDepth = 0; return $this->from(...$paths); @@ -112,9 +107,8 @@ public function in(...$paths): self /** * Searches recursively from the given folder(s). * @param string|string[] $paths - * @return static */ - public function from(...$paths): self + public function from(...$paths): static { if ($this->paths) { throw new Nette\InvalidStateException('Directory to search has already been specified.'); @@ -127,9 +121,8 @@ public function from(...$paths): self /** * Shows folder content prior to the folder. - * @return static */ - public function childFirst(): self + public function childFirst(): static { $this->order = RecursiveIteratorIterator::CHILD_FIRST; return $this; @@ -248,9 +241,8 @@ private function buildIterator(string $path): \Iterator * Restricts the search using mask. * Excludes directories from recursive traversing. * @param string|string[] $masks - * @return static */ - public function exclude(...$masks): self + public function exclude(...$masks): static { $masks = $masks && is_array($masks[0]) ? $masks[0] : $masks; $pattern = self::buildPattern($masks); @@ -264,9 +256,8 @@ public function exclude(...$masks): self /** * Restricts the search using callback. * @param callable $callback function (RecursiveDirectoryIterator $file): bool - * @return static */ - public function filter(callable $callback): self + public function filter(callable $callback): static { $this->cursor[] = $callback; return $this; @@ -275,9 +266,8 @@ public function filter(callable $callback): self /** * Limits recursion level. - * @return static */ - public function limitDepth(int $depth): self + public function limitDepth(int $depth): static { $this->maxDepth = $depth; return $this; @@ -287,9 +277,8 @@ public function limitDepth(int $depth): self /** * Restricts the search by size. * @param string $operator "[operator] [size] [unit]" example: >=10kB - * @return static */ - public function size(string $operator, int $size = null): self + public function size(string $operator, int $size = null): static { if (func_num_args() === 1) { // in $operator is predicate 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 /** * Restricts the search by modified time. * @param string $operator "[operator] [date]" example: >1978-01-23 - * @param string|int|\DateTimeInterface $date - * @return static */ - public function date(string $operator, $date = null): self + public function date(string $operator, string|int|\DateTimeInterface $date = null): static { if (func_num_args() === 1) { // in $operator is predicate if (!preg_match('#^(?:([=<>!]=?|<>)\s*)?(.+)$#Di', $operator, $matches)) {