1--TEST-- 2Dom\HTMLDocument::createFromFile() with failing stream wrapper 3--EXTENSIONS-- 4dom 5--FILE-- 6<?php 7 8class FailingWrapper { 9 public $context; 10 public $fail = false; 11 12 public function stream_open($path, $mode, $options, &$opened_path) { 13 return true; 14 } 15 16 public function stream_read($count) { 17 if ($this->fail) { 18 throw new Error("fail"); 19 } 20 $this->fail = true; 21 return str_repeat("X", $count); 22 } 23 24 public function stream_eof() { 25 return false; 26 } 27 28 public function stream_close() { 29 return true; 30 } 31} 32 33stream_wrapper_register("fail", FailingWrapper::class, 0); 34 35Dom\HTMLDocument::createFromFile("fail://x"); 36 37?> 38--EXPECTF-- 39Fatal error: Uncaught Error: fail in %s:%d 40Stack trace: 41#0 [internal function]: FailingWrapper->stream_read(8192) 42#1 %s(%d): Dom\HTMLDocument::createFromFile('fail://x') 43#2 {main} 44 thrown in %s on line %d 45