|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-03-11 07:18 UTC] olemarkus dot with at student-media dot no
Description: ------------ When using static:: in a parent class to refer to the child class that was called, the keyword is resolved to the caller class instead. Reproduce code: --------------- http://olemarkus.com/issue.txt Expected result: ---------------- I expect both calls to \C\C::getName() to yield the same result: C C Actual result: -------------- The second one gives the following output: C Fatal error: Access to undeclared static property: A\A::$name in issue.php on line 13 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 07 02:00:01 2025 UTC |
And here is the code: <?php namespace A { class A { function __construct() { echo \C\C::getName() . "\n"; } } } namespace B { abstract class B { static protected $name = ''; function getName() { return static::$name; } } } namespace C { class C extends \B\B { static protected $name = 'C'; } } namespace { echo \C\C::getName() . "\n"; $a = new \A\A(); } ?>