You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<pclass="message-warning">A <code>SplFileObject</code> does not expose its context. If it was created with one, you must pass it explicitly to the <code>$context</code> argument.
54
+
Alternatively, you can use the <code>fromStream</code> method.</p>
55
+
56
+
### Loading from stream
57
+
58
+
<divclass="message-info">Since version <code>9.29.0</code></div>
59
+
<divclass="message-notice">Since version <code>9.27.0</code> the <code>createFromStream()</code> and <code>createFromFileObject()</code> methods are <strong>deprecated</strong></div>
60
+
61
+
```php
62
+
public static AbstractCsv::fromStream(SplFileObject|resource $stream): self
63
+
```
64
+
Creates a new object from a stream resource or a streaming object.
@@ -129,8 +108,8 @@ public static function fromPath(SplFileInfo|string $path, string $mode = 'r', $c
129
108
publicstaticfunctionfromStream($stream): static
130
109
{
131
110
if (!$streaminstanceof SplFileObject) {
132
-
is_resource($stream) || thrownewTypeError('Argument passed must be a stream resource, '.gettype($stream).' given.');
133
-
'stream' === ($type = get_resource_type($stream)) || thrownewTypeError('Argument passed must be a stream resource, '.$type.' resource given');
111
+
is_resource($stream) || thrownewTypeError('Argument passed must be a stream resource or an SplFileObject instance, '.gettype($stream).' given.');
112
+
'stream' === ($type = get_resource_type($stream)) || thrownewTypeError('Argument passed must be a stream resource or an SplFileObject instance, '.$type.' resource given');
134
113
}
135
114
136
115
returnstatic::from(filename: $stream);
@@ -144,6 +123,23 @@ public static function fromString(Stringable|string $content = ''): static
0 commit comments