|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #54207 autoload parameter for class_alias?
Submitted: 2011-03-09 18:44 UTC Modified: 2012-10-08 08:40 UTC
Avg. Score:3.6 ± 1.3
Reproduced:10 of 11 (90.9%)
Same Version:5 (50.0%)
Same OS:1 (10.0%)
From: offshore at aopdg dot ru Assigned: reeze (profile)
Status: Closed Package: Performance problem
PHP Version: 5.3.5 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: offshore at aopdg dot ru
New email:
PHP Version: OS:


 [2011-03-09 18:44 UTC] offshore at aopdg dot ru
While inspecting the class_alias() functionality I discovered that when declaring an alias of a class, it invokes an __autoload routine for all base class tree even if the aliased class not used in code. It may be inappropriate for huge frameworks when them used for quick/small/performance scripts that does not need alias functionality.

Test script:
class A { }
class B extends A { }
class C1 extends B { }
class C2 extends B { }

function __autoload($className) { include($className . '.php'); }
function included_files() { return implode(', ', array_map('basename', get_included_files())) . "\n"; }
    echo included_files();
    class_alias('C1', 'C');
    echo included_files();
    $c = new C();
    echo included_files();

Expected result:
main.php, C1.php, B.php, A.php

Actual result:
main.php, C1.php, B.php, A.php
main.php, C1.php, B.php, A.php


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-10-08 08:40 UTC]
There is a autoload parameter but not documented.

This have been fixed in documentation.
 [2012-10-08 08:40 UTC]
-Status: Open +Status: Closed -Type: Feature/Change Request +Type: Documentation Problem -Assigned To: +Assigned To: reeze
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Mar 29 13:01:26 2020 UTC