|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #26739 __call() doesn't work for static methods
Submitted: 2003-12-29 07:50 UTC Modified: 2007-11-09 23:37 UTC
Avg. Score:4.5 ± 0.9
Reproduced:17 of 17 (100.0%)
Same Version:9 (52.9%)
Same OS:12 (70.6%)
From: demiurg at terra dot es Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 5.0.0 OS: *
Private report: No CVE-ID: None
 [2003-12-29 07:50 UTC] demiurg at terra dot es
I'm not sure whether it is a bug or a feature, so I just point this out and you decide.

__class() method works like OK for objects, but completely fails when calling a class method (see Reproduce Code).

P.S. Before sending this report, I did a search on "__call" and have found 11 bugs, none of which describes the issue.


Reproduce code:

class a {
	static function __call($method, $params) {
		echo "Called $method(".implode(', ', $params).")\n";

$c = new a;
$c->test(1, 2, 3);

a::test(3, 2, 1);

Expected result:
Called test(1, 2, 3)

Called test(3, 2, 1)

Actual result:
Called test(1, 2, 3)

Fatal error: Call to undefined method a::test() in a.php on line 12


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-12-29 08:07 UTC]
__call() doesn't offer anything to distinguish between static and dynamic calls. So we'd need a new magic function say __static_call().

For 5.0.0 we have a feature freeze already, so this might take a while.
 [2007-03-16 08:40 UTC] ecentinela at gmail dot com
Have been resolved this issue? There is some workaround?

 [2007-07-29 22:45 UTC] tom at ix dot tc
The last response was 3 years ago but this has yet to be implemented.
Any updates on this? I would really like to have this feature.
 [2007-08-23 01:47 UTC]
Actually AFAIK it's implemented in PHP 6 HEAD and maybe will be also backported to 5.3. 
 [2007-11-05 14:57 UTC] lokrain at gmail dot com
stas, I hope you are right! I think this is a majer issue. I hope someone get soon assigned to that "bug?!".
 [2007-11-09 23:37 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

__callStatic was implemented, I guess it does what you wanted?
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 05 04:01:29 2024 UTC