19 declare(strict_types=1);
    36         'r' => self::MASK_ACCESS_READ,
    37         'w+' => self::MASK_ACCESS_READ_WRITE,
    38         'r+' => self::MASK_ACCESS_READ_WRITE,
    39         'x+' => self::MASK_ACCESS_READ_WRITE,
    40         'c+' => self::MASK_ACCESS_READ_WRITE,
    41         'rb' => self::MASK_ACCESS_READ,
    42         'w+b' => self::MASK_ACCESS_READ_WRITE,
    43         'r+b' => self::MASK_ACCESS_READ_WRITE,
    44         'x+b' => self::MASK_ACCESS_READ_WRITE,
    45         'c+b' => self::MASK_ACCESS_READ_WRITE,
    46         'rt' => self::MASK_ACCESS_READ,
    47         'w+t' => self::MASK_ACCESS_READ_WRITE,
    48         'r+t' => self::MASK_ACCESS_READ_WRITE,
    49         'x+t' => self::MASK_ACCESS_READ_WRITE,
    50         'c+t' => self::MASK_ACCESS_READ_WRITE,
    51         'a+' => self::MASK_ACCESS_READ_WRITE,
    52         'w' => self::MASK_ACCESS_WRITE,
    53         'rw' => self::MASK_ACCESS_WRITE,
    54         'wb' => self::MASK_ACCESS_WRITE,
    55         'a' => self::MASK_ACCESS_WRITE
    67     protected ?
string $uri = null;
    82             throw new \InvalidArgumentException(
    83                 'Stream must be a valid resource but "' . gettype(
$stream) . 
'" was given.'    87         if ($options !== null) {
    88             $this->customMetadata = $options->getMetadata();
    89             $this->size = ($options->getSize() !== -1) ? $options->getSize() : null;
    91             $this->customMetadata = [];
    96         $meta = stream_get_meta_data($this->stream);
    97         $this->_mode = $mode = $meta[
'mode'];
    99         $this->readable = array_key_exists(
   102         ) && (bool) (self::$accessMap[$mode] & self::MASK_ACCESS_READ);
   103         $this->writeable = array_key_exists(
   106         ) && (bool) (self::$accessMap[$mode] & self::MASK_ACCESS_WRITE);
   107         $this->seekable = $meta[
'seekable'];
   116         if (is_resource($this->stream)) {
   129         $this->stream = $this->size = $this->uri = null;
   140         if ($this->size !== null) {
   145         if ($this->stream === null) {
   150         if ($this->uri !== null) {
   151             clearstatcache(
true, $this->uri);
   154         $stats = fstat($this->stream) ?: [];
   155         if (array_key_exists(
'size', $stats)) {
   156             $this->size = $stats[
'size'];
   173         if ($result === 
false) {
   174             throw new \RuntimeException(
'Unable to determine stream position');
   183     public function eof(): bool
   187         return feof($this->stream);
   201     public function seek($offset, $whence = SEEK_SET): void
   206             throw new \RuntimeException(
'Stream is not seekable');
   210             throw new \RuntimeException(
"Unable to seek to stream position \"$offset\" with whence \"$whence\"");
   238             throw new \RuntimeException(
'Can not write to a non-writable stream');
   245         if ($result === 
false) {
   246             throw new \RuntimeException(
'Unable to write to stream');
   263     public function read($length): string
   268             throw new \RuntimeException(
'Can not read from non-readable stream');
   272             throw new \RuntimeException(
'Length parameter must not be negative');
   280         if ($junk === 
false) {
   281             throw new \RuntimeException(
'Unable to read from stream');
   296         if ($content === 
false) {
   297             throw new \RuntimeException(
'Unable to read stream contents');
   309         if ($this->stream === null) {
   315             return array_merge(stream_get_meta_data($this->stream), $this->customMetadata);
   321         if (array_key_exists($key, $this->customMetadata)) {
   322             return $this->customMetadata[$key];
   326         $meta = stream_get_meta_data($this->stream);
   327         if (array_key_exists($key, $meta)) {
   355         if (!is_null($this->stream)) {
   368         if ($this->stream === null) {
   369             throw new \RuntimeException(
'Stream is detached');
 
static ftell($handle)
ftell wrapper 
 
static fseek($stream, int $offset, int $whence)
 
static fread($handle, int $length)
 
seek($offset, $whence=SEEK_SET)
 
assertStreamAttached()
Checks if the stream is attached to the wrapper. 
 
static array string $_mode
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
__construct($stream, StreamOptions $options=null)
Stream constructor. 
 
const MASK_ACCESS_READ_WRITE
 
static fwrite($handle, string $string, ?int $length=null)
 
static stream_get_contents($handle, $length=-1)
 
The base interface for all filesystem streams. 
 
The streaming options are used by the stream implementation.