24 'r' => self::MASK_ACCESS_READ,
25 'w+' => self::MASK_ACCESS_READ_WRITE,
26 'r+' => self::MASK_ACCESS_READ_WRITE,
27 'x+' => self::MASK_ACCESS_READ_WRITE,
28 'c+' => self::MASK_ACCESS_READ_WRITE,
29 'rb' => self::MASK_ACCESS_READ,
30 'w+b' => self::MASK_ACCESS_READ_WRITE,
31 'r+b' => self::MASK_ACCESS_READ_WRITE,
32 'x+b' => self::MASK_ACCESS_READ_WRITE,
33 'c+b' => self::MASK_ACCESS_READ_WRITE,
34 'rt' => self::MASK_ACCESS_READ,
35 'w+t' => self::MASK_ACCESS_READ_WRITE,
36 'r+t' => self::MASK_ACCESS_READ_WRITE,
37 'x+t' => self::MASK_ACCESS_READ_WRITE,
38 'c+t' => self::MASK_ACCESS_READ_WRITE,
39 'a+' => self::MASK_ACCESS_READ_WRITE,
40 'w' => self::MASK_ACCESS_WRITE,
41 'rw' => self::MASK_ACCESS_WRITE,
42 'wb' => self::MASK_ACCESS_WRITE,
43 'a' => self::MASK_ACCESS_WRITE
85 throw new \InvalidArgumentException(
'Stream must be a valid resource but "' . gettype(
$stream) .
'" was given.');
89 $this->customMetadata =
$options->getMetadata();
92 $this->customMetadata = [];
97 $meta = stream_get_meta_data($this->stream);
98 $mode = $meta[
'mode'];
100 $this->readable = array_key_exists($mode, self::$accessMap) && boolval(self::$accessMap[$mode] & self::MASK_ACCESS_READ);
101 $this->writeable = array_key_exists($mode, self::$accessMap) && boolval(self::$accessMap[$mode] & self::MASK_ACCESS_WRITE);
102 $this->seekable = boolval($meta[
'seekable']);
112 if ($this->stream !== null && is_resource($this->stream)) {
126 $this->stream = $this->
size = $this->uri = null;
139 if ($this->
size !== null) {
144 if ($this->stream === null) {
149 if ($this->uri !== null) {
150 clearstatcache(
true, $this->uri);
153 $stats = fstat($this->stream);
154 if (array_key_exists(
'size',
$stats)) {
174 throw new \RuntimeException(
'Unable to determine stream position');
188 return feof($this->stream);
204 public function seek($offset, $whence = SEEK_SET)
209 throw new \RuntimeException(
'Stream is not seekable');
213 throw new \RuntimeException(
"Unable to seek to stream position \"$offset\" with whence \"$whence\"");
244 throw new \RuntimeException(
'Can not write to a non-writable stream');
252 throw new \RuntimeException(
'Unable to write to stream');
276 throw new \RuntimeException(
'Can not read from non-readable stream');
280 throw new \RuntimeException(
'Length parameter must not be negative');
288 if ($junk ===
false) {
289 throw new \RuntimeException(
'Unable to read from stream');
305 if ($content ===
false) {
306 throw new \RuntimeException(
'Unable to read stream contents');
320 if ($this->stream === null) {
326 return array_merge(stream_get_meta_data($this->stream), $this->customMetadata);
332 if (array_key_exists(
$key, $this->customMetadata)) {
333 return $this->customMetadata[
$key];
337 $meta = stream_get_meta_data($this->stream);
338 if (array_key_exists(
$key, $meta)) {
368 if (!is_null($this->stream)) {
382 if ($this->stream === null) {
383 throw new \RuntimeException(
'Stream is detached');
static ftell($handle)
ftell wrapper
seek($offset, $whence=SEEK_SET)
assertStreamAttached()
Checks if the stream is attached to the wrapper.
static fseek($stream, $offset, $whence)
fseek wrapper.
static fread($handle, $length)
fread wrapper
static fclose($handle)
fclose wrapper
__construct($stream, StreamOptions $options=null)
Stream constructor.
const MASK_ACCESS_READ_WRITE
static fwrite($handle, $string, $length=null)
fwrite wrapper
static stream_get_contents($handle, $length=-1)
stream_get_contents wrapper
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Set page orientation and size