File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change 18
18
*/
19
19
final class ResourceIteratorAggregate implements IteratorAggregate
20
20
{
21
+ /**
22
+ * @var Closure(resource): (T|mixed)
23
+ */
24
+ private Closure $ consumer ;
25
+
21
26
/**
22
27
* @var resource
23
28
*/
24
29
private $ resource ;
25
30
26
31
/**
27
32
* @param false|resource $resource
28
- * @param Closure(resource): T $consumer
33
+ * @param Closure(resource): (T|mixed) $consumer
29
34
*/
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 )
31
36
{
32
37
if (!is_resource ($ resource ) || 'stream ' !== get_resource_type ($ resource )) {
33
38
throw new InvalidArgumentException ('Invalid resource type. ' );
34
39
}
35
40
36
41
$ 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 );
38
48
}
39
49
40
50
/**
You can’t perform that action at this time.
0 commit comments