Skip to content

Commit c02c27e

Browse files
committed
normalized callable to Closure
1 parent e197add commit c02c27e

3 files changed

Lines changed: 10 additions & 10 deletions

File tree

src/Iterators/Mapper.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@
1515
*/
1616
class Mapper extends \IteratorIterator
1717
{
18-
/** @var callable */
19-
private $callback;
18+
private \Closure $callback;
2019

2120

2221
public function __construct(\Traversable $iterator, callable $callback)
2322
{
2423
parent::__construct($iterator);
25-
$this->callback = $callback;
24+
$this->callback = $callback(...);
2625
}
2726

2827

src/Utils/Finder.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ class Finder implements \IteratorAggregate
4242
private array $appends = [];
4343
private bool $childFirst = false;
4444

45-
/** @var ?callable */
46-
private $sort;
45+
/** @var ?(\Closure(FileInfo, FileInfo): int) */
46+
private ?\Closure $sort = null;
4747
private int $maxDepth = -1;
4848
private bool $ignoreUnreadableDirs = true;
4949

@@ -184,7 +184,7 @@ public function ignoreUnreadableDirs(bool $state = true): static
184184
*/
185185
public function sortBy(callable $callback): static
186186
{
187-
$this->sort = $callback;
187+
$this->sort = $callback(...);
188188
return $this;
189189
}
190190

@@ -250,7 +250,7 @@ public function exclude(string|array $masks): static
250250
*/
251251
public function filter(callable $callback): static
252252
{
253-
$this->filters[] = \Closure::fromCallable($callback);
253+
$this->filters[] = $callback(...);
254254
return $this;
255255
}
256256

@@ -261,7 +261,7 @@ public function filter(callable $callback): static
261261
*/
262262
public function descentFilter(callable $callback): static
263263
{
264-
$this->descentFilters[] = \Closure::fromCallable($callback);
264+
$this->descentFilters[] = $callback(...);
265265
return $this;
266266
}
267267

src/Utils/Iterables.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,10 @@ public static function mapWithKeys(iterable $iterable, callable $transformer): \
194194
*/
195195
public static function repeatable(callable $factory): \IteratorAggregate
196196
{
197-
return new class ($factory) implements \IteratorAggregate {
197+
return new class ($factory(...)) implements \IteratorAggregate {
198198
public function __construct(
199-
private $factory,
199+
/** @var \Closure(): iterable<mixed, mixed> */
200+
private \Closure $factory,
200201
) {
201202
}
202203

0 commit comments

Comments
 (0)