|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65466 forward_static_call doesn't trigger __callStatic for non-existing methods
Submitted: 2013-08-17 14:13 UTC Modified: 2014-07-16 03:10 UTC
Avg. Score:1.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: daniel dot ruthardt at zoesolutions dot eu Assigned:
Status: Verified Package: Scripting Engine problem
PHP Version: 5.4.18 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: daniel dot ruthardt at zoesolutions dot eu
New email:
PHP Version: OS:


 [2013-08-17 14:13 UTC] daniel dot ruthardt at zoesolutions dot eu
From manual page:

The manual page makes you think that this function can be used to force a static method 
call, it however doesn't. Essentially, this functions just does the same thing as does 
the :: operator, which heavily depends on the current context - as unfortunately does 

One might expect, that using a function which says in its name and description, that it 
will call static methods, that calling non-existing static methods will end up in 
__callStatic and not in __call.

Test script:

class A {

	public function __call($name, $arguments) {
		echo("i don't want to be in here :-(");

	public static function __callStatic($name, $arguments) {
		echo('i want to be in here, but how?');

	public function instanceMethod() {
		// objective: call a non-existing static method,
		// so that eventually __callStatic is called and
		// can take care of things
		forward_static_call(['A', 'test']);


(new A())->instanceMethod();


Expected result:
i want to be in here, but how?

Actual result:
i don't want to be in here :-(


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2014-07-16 03:10 UTC]
-Status: Open +Status: Verified -Package: Unknown/Other Function +Package: Scripting Engine problem
 [2014-07-16 03:10 UTC]

PHP does not call __callStatic() when it's in the same class.
forward_static_call() should call it's own __callStatic()?

class A
    const NAME = 'A';
    public function __call($name, $args) {
        echo 'Non-Static ' . static::NAME . ' ' . $name;

    public static function __callStatic($name, $args) {
        echo 'Static ' . static::NAME . ' ' . $name;


class B extends A
    const NAME = 'B';

    public static function test() {
        echo self::NAME, "\n";
        forward_static_call(array('A', 'notExist'), 'more', 'args');



Static B notExist
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 26 00:01:30 2024 UTC