Bug #71236 [Opn]: Second call of spl_autoload_register() does nothing if it has no arguments

From: Date: Tue, 29 Dec 2015 20:02:43 +0000
Subject: Bug #71236 [Opn]: Second call of spl_autoload_register() does nothing if it has no arguments
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-198286@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71236&edit=1 ID: 71236 User updated by: php at maisqi dot com Reported by: php at maisqi dot com Summary: Second call of spl_autoload_register() does nothing if it has no arguments Status: Open Type: Bug Package: SPL related Operating System: Windows and Linux PHP Version: Irrelevant Block user comment: N Private report: N New Comment: "The autoload function being registered. If no parameter is provided, then the default implementation of spl_autoload() will be registered." Previous Comments: ------------------------------------------------------------------------ [2015-12-29 19:59:58] php at maisqi dot com Sorry, I don't understand what you mean. Are you suggesting issuing a warning for this? Reading the docs, I get the idea that the order of the spl_autoload_register() calls is irrelevant -- it uses a queue, after all -- so, I don't see where a warning could fit. ------------------------------------------------------------------------ [2015-12-29 14:15:59] laruence@php.net maybe a warning? ------------------------------------------------------------------------ [2015-12-29 12:41:12] php at maisqi dot com In "Actual results" should be: The first block prints one entry; the others print two blocks. ------------------------------------------------------------------------ [2015-12-29 12:39:21] php at maisqi dot com Description: ------------ spl_autoload_register() with no arguments registers spl_autoload(). But if we call spl_autoload_register() with a custom function before, it does nothing. Nothing in the documentation seems to support this behaviour as valid. Tested on PHP 5.5 Linux, 5.6 Win64 and 7.01 Win64. Test script: --------------- <?php echo '<pre>'; /** * Every one of these code blocks must be run in separated. */ // Custom function first; spl_autoload after. spl_autoload_register(function ($class) {}); spl_autoload_register(); print_r(spl_autoload_functions()); // Prints only one entry. /* // Custom function first; spl_autoload after. spl_autoload_register(function ($class) {}); spl_autoload_register('spl_autoload'); print_r(spl_autoload_functions()); // Prints two entries, as expected. // spl_autoload first; custom function after. spl_autoload_register(); spl_autoload_register(function ($class) {}); print_r(spl_autoload_functions()); // Prints two entries, as expected. */ Expected result: ---------------- All blocks should print two entries. Actual result: -------------- All blocks should print two entries, except the first that only prints one. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=71236&edit=1

« previous php.bugs (#198286) next »