php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #67936 The spl_autoload_register() function uses queue but not stack
Submitted: 2014-08-30 06:49 UTC Modified: 2014-09-21 06:50 UTC
From: alegil91 at gmail dot com Assigned: krakjoe (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: Doesn't matter
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: alegil91 at gmail dot com
New email:
PHP Version: OS:

 

 [2014-08-30 06:49 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-09-21 06:50 UTC] krakjoe@php.net
Automatic comment from SVN on behalf of krakjoe
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=334917
Log: fix #67936 (change use of the word &quot;stack&quot; for &quot;queue&quot;)
 [2014-09-21 06:50 UTC] krakjoe@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: krakjoe
 [2014-09-21 06:50 UTC] krakjoe@php.net
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.


 [2014-09-24 19:50 UTC] krakjoe@php.net
Automatic comment from SVN on behalf of krakjoe
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=334980
Log: bring these inline for #67936 (change wording from stack to queue)
 [2020-02-07 06:08 UTC] phpdocbot@php.net
Automatic comment on behalf of krakjoe
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=edffc3f9c473664ca9f105c51ecc640b104d4820
Log: fix #67936 (change use of the word &quot;stack&quot; for &quot;queue&quot;)
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Oct 08 08:00:01 2026 UTC