php.net |  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
Votes:12
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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: offshore at aopdg dot ru
New email:
PHP Version: OS:

 

 [2011-03-09 18:44 UTC] offshore at aopdg dot ru
Description:
------------
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:
---------------
A.php:
class A { }
B.php:
class B extends A { }
C1.php:
class C1 extends B { }
C2.php:
class C2 extends B { }

main.php:
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
main.php
main.php, C1.php, B.php, A.php

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


Patches

Pull Requests

History

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

This have been fixed in documentation.
 [2012-10-08 08:40 UTC] reeze@php.net
-Status: Open +Status: Closed -Type: Feature/Change Request +Type: Documentation Problem -Assigned To: +Assigned To: reeze
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 17:01:34 2025 UTC