|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63602 __callStatic does not see $this
Submitted: 2012-11-26 03:39 UTC Modified: 2012-11-26 06:10 UTC
From: stealz at op dot pl Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.4.9 OS: Windows 7
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
39 + 46 = ?
Subscribe to this entry?

 [2012-11-26 03:39 UTC] stealz at op dot pl
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
	static function __callStatic($method, $args) {

class B {
	function test() {

$o = new B();

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-11-26 06:10 UTC]
-Status: Open +Status: Not a bug
 [2012-11-26 06:10 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

you should not use $this in a static method.

you should see a strict warning for this like:
PHP Strict Standards:  Non-static method A::foo() should not be called statically, 
assuming $this from incompatible context

for your question:
__callStatic does not parse the this_ptr for static calls
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Wed Jun 07 16:03:41 2023 UTC