18 private static $slots = [
'__toString',
'close',
'detach',
'rewind',
19 'getSize',
'tell',
'eof',
'isSeekable',
'seek',
'isWritable',
'write',
20 'isReadable',
'read',
'getContents',
'getMetadata'];
27 $this->methods = $methods;
30 foreach ($methods as $name => $fn) {
31 $this->{
'_fn_' . $name} = $fn;
39 public function __get($name)
41 throw new \BadMethodCallException(str_replace(
'_fn_',
'', $name)
42 .
'() is not implemented in the FnStream');
50 if (isset($this->_fn_close)) {
51 call_user_func($this->_fn_close);
61 throw new \LogicException(
'FnStream should never be unserialized');
77 foreach (array_diff(self::$slots, array_keys($methods)) as $diff) {
78 $methods[$diff] = [$stream, $diff];
81 return new self($methods);
86 return call_user_func($this->_fn___toString);
89 public function close()
91 return call_user_func($this->_fn_close);
96 return call_user_func($this->_fn_detach);
101 return call_user_func($this->_fn_getSize);
104 public function tell()
106 return call_user_func($this->_fn_tell);
109 public function eof()
111 return call_user_func($this->_fn_eof);
116 return call_user_func($this->_fn_isSeekable);
121 call_user_func($this->_fn_rewind);
124 public function seek($offset, $whence = SEEK_SET)
126 call_user_func($this->_fn_seek, $offset, $whence);
131 return call_user_func($this->_fn_isWritable);
134 public function write($string)
136 return call_user_func($this->_fn_write, $string);
141 return call_user_func($this->_fn_isReadable);
144 public function read($length)
146 return call_user_func($this->_fn_read, $length);
151 return call_user_func($this->_fn_getContents);
156 return call_user_func($this->_fn_getMetadata, $key);