File tree 2 files changed +18
-2
lines changed
2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -136,10 +136,14 @@ public function stream_cast(int $cast_as)
136
136
* ctime: int,
137
137
* blksize: int,
138
138
* blocks: int
139
- * }
139
+ * }|false
140
140
*/
141
- public function stream_stat (): array
141
+ public function stream_stat ()
142
142
{
143
+ if ($ this ->stream ->getSize () === null ) {
144
+ return false ;
145
+ }
146
+
143
147
static $ modeMap = [
144
148
'r ' => 33060 ,
145
149
'rb ' => 33060 ,
Original file line number Diff line number Diff line change 6
6
7
7
use GuzzleHttp \Psr7 ;
8
8
use GuzzleHttp \Psr7 \StreamWrapper ;
9
+ use GuzzleHttp \Psr7 \Utils ;
9
10
use PHPUnit \Framework \TestCase ;
10
11
use Psr \Http \Message \StreamInterface ;
11
12
@@ -187,4 +188,15 @@ public function testXmlWriterWithStream(): void
187
188
$ stream ->rewind ();
188
189
self ::assertXmlStringEqualsXmlString ('<?xml version="1.0"?><foo /> ' , (string ) $ stream );
189
190
}
191
+
192
+ public function testWrappedNullSizedStreamStaysNullSized (): void
193
+ {
194
+ $ nullSizedStream = new Psr7 \PumpStream (function () { return '' ; });
195
+ $ this ->assertNull ($ nullSizedStream ->getSize ());
196
+
197
+ $ resource = StreamWrapper::getResource ($ nullSizedStream );
198
+ $ stream = Utils::streamFor ($ resource );
199
+
200
+ $ this ->assertNull ($ stream ->getSize ());
201
+ }
190
202
}
You can’t perform that action at this time.
0 commit comments