blob: b973488537a207bfad75fe4edc5ebfb3e7e17740 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
diff -up ./src/WritableResourceStream.php.php8 ./src/WritableResourceStream.php
--- ./src/WritableResourceStream.php.php8 2021-04-07 16:22:09.048553209 +0200
+++ ./src/WritableResourceStream.php 2021-04-07 16:22:14.797526978 +0200
@@ -117,10 +117,15 @@ final class WritableResourceStream exten
$error = $errstr;
});
- if ($this->writeChunkSize === -1) {
- $sent = \fwrite($this->stream, $this->data);
+ if (is_resource($this->stream)) {
+ if ($this->writeChunkSize === -1) {
+ $sent = \fwrite($this->stream, $this->data);
+ } else {
+ $sent = \fwrite($this->stream, $this->data, $this->writeChunkSize);
+ }
} else {
- $sent = \fwrite($this->stream, $this->data, $this->writeChunkSize);
+ $sent = 0;
+ $error = 'this is not a valid stream resource';
}
\restore_error_handler();
diff -up ./tests/WritableStreamResourceTest.php.php8 ./tests/WritableStreamResourceTest.php
--- ./tests/WritableStreamResourceTest.php.php8 2021-04-07 16:18:25.234574523 +0200
+++ ./tests/WritableStreamResourceTest.php 2021-04-07 16:18:44.985484393 +0200
@@ -508,7 +508,7 @@ class WritableResourceStreamTest extends
$buffer->handleWrite();
$this->assertInstanceOf('Exception', $error);
- $this->assertSame('Unable to write to stream: fwrite(): send of 3 bytes failed with errno=32 Broken pipe', $error->getMessage());
+ $this->assertEqualsIgnoringCase('Unable to write to stream: fwrite(): send of 3 bytes failed with errno=32 Broken pipe', $error->getMessage());
}
private function createWriteableLoopMock()
|