Lines Matching defs:stream

5  * PHP stream implementation
9 private $stream;
17 /** @var array Hash of readable and writable stream types */
34 * Create a new stream based on the input type.
50 $stream = fopen('php://temp', 'r+');
52 fwrite($stream, $resource);
53 fseek($stream, 0);
55 return new self($stream, $options);
91 * - size: (int) If a read stream would otherwise have an indeterminate
95 * of the stream is accessed.
97 * @param resource $stream Stream resource to wrap.
100 * @throws \InvalidArgumentException if the stream is not a stream resource
102 public function __construct($stream, $options = [])
104 if (!is_resource($stream)) {
116 $this->attach($stream);
120 * Closes the stream when the destructed
129 if (!$this->stream) {
135 return (string) stream_get_contents($this->stream);
140 return $this->stream ? stream_get_contents($this->stream) : '';
145 if (is_resource($this->stream)) {
146 fclose($this->stream);
154 $result = $this->stream;
155 $this->stream = $this->size = $this->uri = null;
161 public function attach($stream)
163 $this->stream = $stream;
164 $meta = stream_get_meta_data($this->stream);
177 if (!$this->stream) {
181 // Clear the stat cache if the stream has a URI
186 $stats = fstat($this->stream);
212 return !$this->stream || feof($this->stream);
217 return $this->stream ? ftell($this->stream) : false;
230 ? fseek($this->stream, $offset, $whence) === 0
236 return $this->readable ? fread($this->stream, $length) : false;
244 return $this->writable ? fwrite($this->stream, $string) : false;
249 if (!$this->stream) {
252 return $this->customMetadata + stream_get_meta_data($this->stream);
257 $meta = stream_get_meta_data($this->stream);