private function Stream::setStream in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/zendframework/zend-diactoros/src/Stream.php \Zend\Diactoros\Stream::setStream()
Set the internal stream resource.
Parameters
string|resource $stream String stream target or stream resource.:
string $mode Resource mode for stream target.:
Throws
InvalidArgumentException for invalid streams or resources.
2 calls to Stream::setStream()
- Stream::attach in vendor/
zendframework/ zend-diactoros/ src/ Stream.php - Attach a new stream/resource to the instance.
- Stream::__construct in vendor/
zendframework/ zend-diactoros/ src/ Stream.php
File
- vendor/
zendframework/ zend-diactoros/ src/ Stream.php, line 299
Class
- Stream
- Implementation of PSR HTTP streams
Namespace
Zend\DiactorosCode
private function setStream($stream, $mode = 'r') {
$error = null;
$resource = $stream;
if (is_string($stream)) {
set_error_handler(function ($e) use (&$error) {
$error = $e;
}, E_WARNING);
$resource = fopen($stream, $mode);
restore_error_handler();
}
if ($error) {
throw new InvalidArgumentException('Invalid stream reference provided');
}
if (!is_resource($resource) || 'stream' !== get_resource_type($resource)) {
throw new InvalidArgumentException('Invalid stream provided; must be a string stream identifier or stream resource');
}
if ($stream !== $resource) {
$this->stream = $stream;
}
$this->resource = $resource;
}