Doc #67936 [Opn->Csd]: The spl_autoload_register() function uses queue but not stack
| From: | krakjoe@php.net | Date: | Sun, 21 Sep 2014 06:50:56 +0000 |
| Subject: | Doc #67936 [Opn->Csd]: The spl_autoload_register() function uses queue but not stack | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-11496@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=67936&edit=1
ID: 67936
Updated by: krakjoe@php.net
Reported by: alegil91 at gmail dot com
Summary: The spl_autoload_register() function uses queue but
not stack
-Status: Open
+Status: Closed
Type: Documentation Problem
Package: Documentation problem
Operating System: Doesn't matter
PHP Version: Irrelevant
-Assigned To:
+Assigned To: krakjoe
Block user comment: N
Private report: N
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation better.
Previous Comments:
------------------------------------------------------------------------
[2014-09-21 06:50:51] krakjoe@php.net
Automatic comment from SVN on behalf of krakjoe
Revision: http://svn.php.net/viewvc/?view=revision&revision=334917
Log: fix #67936 (change use of the word "stack" for "queue")
------------------------------------------------------------------------
[2014-08-30 06:49:16] alegil91 at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.spl-autoload-register
---
Why do you call the "stack" what spl_autoload_register function uses? I was really really
embarassed when I was debugging my script. Correct me if I'm wrong but the stack is a data
structure that uses LIFO mechanism to store its entities. That means that what you added last is
gonna to be pulled out of the stack first (Last In - First out).
And what php uses is just a list, that can be appended or prepended depending on what your arguments
are. By default, the $prepend argument is false. I suppose it's more a queue rather than stack.
Test script:
---------------
<?php
function register_other1() {
echo "\nreg1";
spl_autoload_register(function ($className) {
echo "\nCan not load class with other autoload 1: " . $className;
});
}
register_other1();
function register_other2() {
echo "\nreg2";
spl_autoload_register(function ($className) {
echo "\nCan not load class with other autoload 2: " . $className;
});
}
register_other2();
function register_other3() {
echo "\nreg3";
spl_autoload_register(function ($className) {
echo "\nCan not load class with other autoload 3: " . $className;
});
}
register_other3();
var_dump(spl_autoload_functions());
new \Sasa\Lol\Prol();
Expected result:
----------------
reg1
reg2
reg3
Can not load class with other autoload 3: Sasa\Lol\Prol
Can not load class with other autoload 2: Sasa\Lol\Prol
Can not load class with other autoload 1: Sasa\Lol\Prol
Actual result:
--------------
reg1
reg2
reg3
array (size=3)
0 =>
object(Closure)[1]
1 =>
object(Closure)[2]
2 =>
object(Closure)[3]
Can not load class with other autoload 1: Sasa\Lol\Prol
Can not load class with other autoload 2: Sasa\Lol\Prol
Can not load class with other autoload 3: Sasa\Lol\Prol
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=67936&edit=1