Analyzer.php
1 year ago
ClosureContext.php
2 years ago
ClosureScope.php
2 years ago
ClosureStream.php
1 year ago
ISecurityProvider.php
2 years ago
ReflectionClosure.php
1 year ago
SecurityException.php
2 years ago
SecurityProvider.php
1 year ago
SelfReference.php
2 years ago
SerializableClosure.php
1 year ago
ClosureStream.php
83 lines
| 1 | <?php |
| 2 | |
| 3 | /* =========================================================================== |
| 4 | * Copyright (c) 2018-2021 Zindex Software |
| 5 | * |
| 6 | * Licensed under the MIT License |
| 7 | * =========================================================================== */ |
| 8 | namespace Matomo\Dependencies\Opis\Closure; |
| 9 | |
| 10 | /** |
| 11 | * @internal |
| 12 | */ |
| 13 | class ClosureStream |
| 14 | { |
| 15 | const STREAM_PROTO = 'closure'; |
| 16 | protected static $isRegistered = \false; |
| 17 | protected $content; |
| 18 | protected $length; |
| 19 | protected $pointer = 0; |
| 20 | function stream_open($path, $mode, $options, &$opened_path) |
| 21 | { |
| 22 | $this->content = "<?php\nreturn " . substr($path, strlen(static::STREAM_PROTO . '://')) . ";"; |
| 23 | $this->length = strlen($this->content); |
| 24 | return \true; |
| 25 | } |
| 26 | public function stream_read($count) |
| 27 | { |
| 28 | $value = substr($this->content, $this->pointer, $count); |
| 29 | $this->pointer += $count; |
| 30 | return $value; |
| 31 | } |
| 32 | public function stream_eof() |
| 33 | { |
| 34 | return $this->pointer >= $this->length; |
| 35 | } |
| 36 | public function stream_set_option($option, $arg1, $arg2) |
| 37 | { |
| 38 | return \false; |
| 39 | } |
| 40 | public function stream_stat() |
| 41 | { |
| 42 | $stat = stat(__FILE__); |
| 43 | $stat[7] = $stat['size'] = $this->length; |
| 44 | return $stat; |
| 45 | } |
| 46 | public function url_stat($path, $flags) |
| 47 | { |
| 48 | $stat = stat(__FILE__); |
| 49 | $stat[7] = $stat['size'] = $this->length; |
| 50 | return $stat; |
| 51 | } |
| 52 | public function stream_seek($offset, $whence = \SEEK_SET) |
| 53 | { |
| 54 | $crt = $this->pointer; |
| 55 | switch ($whence) { |
| 56 | case \SEEK_SET: |
| 57 | $this->pointer = $offset; |
| 58 | break; |
| 59 | case \SEEK_CUR: |
| 60 | $this->pointer += $offset; |
| 61 | break; |
| 62 | case \SEEK_END: |
| 63 | $this->pointer = $this->length + $offset; |
| 64 | break; |
| 65 | } |
| 66 | if ($this->pointer < 0 || $this->pointer >= $this->length) { |
| 67 | $this->pointer = $crt; |
| 68 | return \false; |
| 69 | } |
| 70 | return \true; |
| 71 | } |
| 72 | public function stream_tell() |
| 73 | { |
| 74 | return $this->pointer; |
| 75 | } |
| 76 | public static function register() |
| 77 | { |
| 78 | if (!static::$isRegistered) { |
| 79 | static::$isRegistered = stream_wrapper_register(static::STREAM_PROTO, __CLASS__); |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 |