Bug #77205 [Opn->Nab]: No E_ERROR level output from a recursive autoloading call

From: Date: Mon, 26 Nov 2018 18:05:56 +0000
Subject: Bug #77205 [Opn->Nab]: No E_ERROR level output from a recursive autoloading call
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-218139@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77205&edit=1 ID: 77205 Updated by: requinix@php.net Reported by: claudio dot luis at aptoide dot com Summary: No E_ERROR level output from a recursive autoloading call -Status: Open +Status: Not a bug Type: Bug Package: SPL related Operating System: Linux (Ubuntu) PHP Version: 7.2.12 Block user comment: N Private report: N New Comment: So the bug you're reporting is that when you use @ to suppress errors, you don't see errors? Previous Comments: ------------------------------------------------------------------------ [2018-11-26 18:00:44] claudio dot luis at aptoide dot com Description: ------------ Whenever a class or interface is autoloaded through the autoload of another class (internally recursive autoload), if such class or interface file is not found in the end (no file loaded/found), no E_ERROR level error is output to the screen (be it console or browser), namely the error reporting a class or interface to not have been found. In other words, in cases such as: class A extends B and class A implements B if neither A and B have been loaded yet, once A is autoloaded, so is B, but if the autoloading of B fails, no error is output and the program execution simply halts silently, while if the autoloading of A fails, then the expected error is shown, such as: "PHP Fatal error: Class 'A' not found in ..." However, if the file containing class A is explicitly loaded beforehand, like so for example: include_once 'A.php'; then the same test results in a visible error, such as: "PHP Fatal error: Interface 'B' not found in ..." Also, while not shown, in all cases the error is still registered internally and can be fetched with error_get_last(). Test script: --------------- //A.php (B.php does not exist) class A implements B { public function doStuff(): void { echo "Hello World!"; } } //------------------------------------------------------------------ //test.php //load class and interface files residing in the same directory spl_autoload_register(function (string $class): void { @include_once __DIR__ . '/' . $class . '.php'; }, true); (new A)->doStuff(); Expected result: ---------------- The following error output to the console or browser: PHP Fatal error: Interface 'B' not found in /test.php on line 6 Actual result: -------------- No error at all is output, but the program execution is halted. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=77205&edit=1

« previous php.bugs (#218139) next »