filename = $filename; $this->mode = $mode; // unsetting the property forces the first access to go through // __get(). unset($this->stream); } public function __unserialize(array $data): void { $this->stream = new BufferStream(); throw new \LogicException(static::class.' should never be unserialized'); } /** * Creates the underlying stream lazily when required. */ protected function createStream(): StreamInterface { return Utils::streamFor(Utils::tryFopen($this->filename, $this->mode)); } }