filehandle = fopen($path, $mode); return $this->filehandle !== false; } /** * @return array */ public function stream_stat() { return []; } /** * @param int $count * * @return string */ public function stream_read($count) { return fgets($this->filehandle, $count); } /** * @return bool */ public function stream_eof() { return feof($this->filehandle); } /** * @return bool */ public function stream_close() { return fclose($this->filehandle); } } stream_wrapper_register('test', TestStream::class) || die('Failed to register protocol');