Skip to content

Commit 2b97b2f

Browse files
committed
Lower buffer size, and use it in the getContents
This is mainly to avoid too much nested call to the read method, as if we got a stream where the reads provide too few bytes (like 100) it will make a nested call to the read method for each part of the messages and will stop on a too muche nested call exception with xdebug. Also there is no need to have more than 8192 as PHP already have a buffer with this size, so no performance issue.
1 parent 0e4361f commit 2b97b2f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Encoding/FilteredStream.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*/
1414
abstract class FilteredStream implements StreamInterface
1515
{
16-
const BUFFER_SIZE = 65536;
16+
const BUFFER_SIZE = 8192;
1717

1818
use StreamDecorator;
1919

@@ -115,7 +115,7 @@ public function getContents()
115115
$buffer = '';
116116

117117
while (!$this->eof()) {
118-
$buf = $this->read(1048576);
118+
$buf = $this->read(self::BUFFER_SIZE);
119119
// Using a loose equality here to match on '' and false.
120120
if ($buf == null) {
121121
break;

0 commit comments

Comments
 (0)