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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
26 + 46 = ?
Subscribe to this entry?

 
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 16:01:28 2024 UTC