for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace HttpSoft\ServerRequest;
use HttpSoft\Message\StreamTrait;
use Psr\Http\Message\StreamInterface;
final class PhpInputStream implements StreamInterface
{
use StreamTrait {
read as private readInternal;
getContents as private getContentsInternal;
}
/**
* @var string
*/
private string $cache = '';
* @var bool
private bool $isEof = false;
* @param string|resource $stream
public function __construct($stream = 'php://input')
$this->init($stream, 'r');
* {@inheritdoc}
public function __toString(): string
if (!$this->isEof) {
$this->getContents();
return $this->cache;
public function isWritable(): bool
return false;
public function read($length): string
$result = $this->readInternal($length);
$this->cache .= $result;
if ($this->eof()) {
$this->isEof = true;
return $result;
public function getContents(): string
if ($this->isEof) {
$result = $this->getContentsInternal();