|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-07-11 16:01 UTC] jani@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 07:00:02 2025 UTC |
Description: ------------ Like #37138 __autoload tries to load callback'ed self and parent PHP tries to __autoload if callcack is used with self or parent in method name. Please note that this is not a dupe! Reproduce code: --------------- function __autoload($class) { echo __METHOD__, '(', $class, ')', PHP_EOL; } class A { function X() { echo __METHOD__, PHP_EOL; } function Y() { echo __METHOD__, PHP_EOL; call_user_func(array($this, 'self::X')); } } class B extends A { function X() { echo __METHOD__, PHP_EOL; call_user_func(array($this, 'parent::X')); } function Y() { echo __METHOD__, PHP_EOL; call_user_func(array($this, 'parent::Y')); } } // Test $a = new A(); echo '--- Case 1 ---', PHP_EOL; $a->X(); echo '--- Case 2 ---', PHP_EOL; $a->Y(); $b = new B(); echo '--- Case 3 ---', PHP_EOL; $b->X(); echo '--- Case 4 ---', PHP_EOL; $b->Y(); Expected result: ---------------- --- Case 1 --- A::X --- Case 2 --- A::Y A::X --- Case 3 --- B::X A::X --- Case 4 --- B::Y A::Y A::X Actual result: -------------- --- Case 1 --- A::X --- Case 2 --- A::Y __autoload(self) A::X --- Case 3 --- B::X __autoload(parent) A::X --- Case 4 --- B::Y __autoload(parent) A::Y __autoload(self) A::X