|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2012-11-26 06:10 UTC] laruence@php.net
-Status: Open
+Status: Not a bug
[2012-11-26 06:10 UTC] laruence@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 16:00:01 2025 UTC |
Description: ------------ When we call the method foo() of some class A in a static context inside the object B, the method can see $this as an object B. However, when method doesn't exist and __callStatic is triggered, $this is undefined. Why is that so? Test script: --------------- abstract class A { function foo() { # non-static on purpose var_dump($this); } static function __callStatic($method, $args) { var_dump($this); } } class B { function test() { A::foo(); A::someMethod(); } } $o = new B(); $o->test(); Expected result: ---------------- object(B)[4] object(B)[4] Actual result: -------------- object(B)[4] null