Skip to content

Commit a8976aa

Browse files
committed
fix: Static analysis annotations
1 parent ce6247d commit a8976aa

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/ResourceIteratorAggregate.php

+13-3
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,33 @@
1818
*/
1919
final class ResourceIteratorAggregate implements IteratorAggregate
2020
{
21+
/**
22+
* @var Closure(resource): (T|mixed)
23+
*/
24+
private Closure $consumer;
25+
2126
/**
2227
* @var resource
2328
*/
2429
private $resource;
2530

2631
/**
2732
* @param false|resource $resource
28-
* @param Closure(resource): T $consumer
33+
* @param Closure(resource): (T|mixed) $consumer
2934
*/
30-
public function __construct($resource, private bool $closeResource = false, private ?Closure $consumer = null)
35+
public function __construct($resource, private bool $closeResource = false, ?Closure $consumer = null)
3136
{
3237
if (!is_resource($resource) || 'stream' !== get_resource_type($resource)) {
3338
throw new InvalidArgumentException('Invalid resource type.');
3439
}
3540

3641
$this->resource = $resource;
37-
$this->consumer ??= static fn ($resource): bool|string => fgetc($resource);
42+
43+
$this->consumer = $consumer ??
44+
/**
45+
* @param resource $resource
46+
*/
47+
static fn ($resource): bool|string => fgets($resource);
3848
}
3949

4050
/**

0 commit comments

Comments
 (0)