diff --git a/src/NativeWrapper.php b/src/NativeWrapper.php index 6c7fe70..9549503 100644 --- a/src/NativeWrapper.php +++ b/src/NativeWrapper.php @@ -198,14 +198,19 @@ public function unlink(string $path): bool public function url_stat(string $path, int $flags) { + if ($flags & STREAM_URL_STAT_QUIET) { + set_error_handler(static fn(): bool => true); + } try { $func = $flags & STREAM_URL_STAT_LINK ? 'lstat' : 'stat'; - return $flags & STREAM_URL_STAT_QUIET - ? @$this->native($func, $path) - : $this->native($func, $path); + return $this->native($func, $path); } catch (\RuntimeException $e) { // SplFileInfo::isFile throws exception return false; + } finally { + if ($flags & STREAM_URL_STAT_QUIET) { + restore_error_handler(); + } } } diff --git a/tests/BypassFinals/overloaded.exists_check.phpt b/tests/BypassFinals/overloaded.exists_check.phpt new file mode 100644 index 0000000..3a2645c --- /dev/null +++ b/tests/BypassFinals/overloaded.exists_check.phpt @@ -0,0 +1,76 @@ +