@@ -206,16 +206,16 @@ public function stream_open(string $path, string $mode, int $options, ?string &$
206206 $ isInclude = ($ options & self ::STREAM_OPEN_FOR_INCLUDE ) !== 0 ;
207207
208208 if (! $ isInclude || ($ mode !== 'r ' && $ mode !== 'rb ' && $ mode !== 'rt ' ) || ! str_ends_with (strtolower ($ path ), '.php ' ) || ! Config ::isEnabled ()) {
209- return $ this ->openDirectHandle ($ path , $ mode );
209+ return $ this ->openDirectHandle ($ path , $ mode, $ options );
210210 }
211211
212212 $ normalizedRaw = str_replace ('\\' , '/ ' , $ path );
213213 if (! PathMatcher ::mayPathBeIncluded ($ normalizedRaw )) {
214- return $ this ->openDirectHandle ($ path , $ mode );
214+ return $ this ->openDirectHandle ($ path , $ mode, $ options );
215215 }
216216
217217 if (self ::isReadOnlyCall ()) {
218- return $ this ->openDirectHandle ($ path , $ mode );
218+ return $ this ->openDirectHandle ($ path , $ mode, $ options );
219219 }
220220
221221 self ::unregister ();
@@ -257,16 +257,22 @@ private static function isReadOnlyCall(): bool
257257 }
258258
259259 /**
260- * Opens an underlying filesystem handle directly with error handler suppression .
260+ * Opens an underlying filesystem handle directly with error reporting options .
261261 */
262- private function openDirectHandle (string $ targetFile , string $ mode ): bool
262+ private function openDirectHandle (string $ targetFile , string $ mode, int $ options ): bool
263263 {
264+ $ isInclude = ($ options & self ::STREAM_OPEN_FOR_INCLUDE ) !== 0 ;
265+
264266 self ::unregister ();
265267 /** @var resource|false $handle */
266268 $ handle = self ::silent (fn () => fopen ($ targetFile , $ mode ));
267269 $ this ->handle = $ handle !== false ? $ handle : null ;
268270 self ::register ();
269271
272+ if ($ this ->handle === null && ! $ isInclude ) {
273+ trigger_error ("fopen( {$ targetFile }): Failed to open stream: No such file or directory " , E_USER_WARNING );
274+ }
275+
270276 return $ this ->handle !== null ;
271277 }
272278
0 commit comments