|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-02-01 10:40 UTC] felipe@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 02:00:01 2025 UTC |
Description: ------------ When I call Bar::aaa(); I expect the self keyword to refer to the Bar class, even if aaa() is defined in a class which Bar extends. The behavior I observe is that, if aaa() is defined in a class Foo which Bar extends, even when I call Bar::aaa(), self refers to Foo. In this case the self keyword is not actually that much use, since if I type "self" in the definition of the Foo class, I know the class name and might as well type "Foo". I had hoped that the self keyword would enable me to override some static functions from a parent class, without forcing me to override the static functions which call them. Reproduce code: --------------- <?php class Foo { public static function aaa() { return self::bbb(); } public static function bbb() { return 'Foo'; } } class Bar extends Foo { public static function bbb() { return 'Bar'; } } var_dump(Bar::aaa()); Expected result: ---------------- string(3) "Bar" Actual result: -------------- string(3) "Foo"