|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2012-10-08 08:40 UTC] reeze@php.net
[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
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 23 22:00:01 2025 UTC |
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