Bug #71236 [Opn]: Second call of spl_autoload_register() does nothing if it has no arguments
[email protected] ("php at maisqi dot com")
| Newsgroups | php.bugs |
|---|---|
| Message-ID | <[email protected]> |
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:
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.
Previous Comments:
------------------------------------------------------------------------
[2015-12-29 14:15:59] [email protected]
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