Edit report at https://bugs.php.net/bug.php?id=62333&edit=1

 ID:                 62333
 Updated by:         cataphr...@php.net
 Reported by:        Sjon at hortensius dot net
 Summary:            Cannot statically call method to parent class
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            Scripting Engine problem
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

Not a bug. A::foo() is not necessarily a static call. Namely, if foo() is not 
static and there is a compatible context ($this exists and its class is either 
the class of the target method or a subclass of it), an instance call will be 
made. In your case, because you sort of have a static and non-static foo() via 
magic, the non-static is preferred. You'll have to be creative, like maybe 
calling __callstatic directly or using a closure.


Previous Comments:
------------------------------------------------------------------------
[2012-06-15 11:11:53] Sjon at hortensius dot net

Description:
------------
All static calls to a class-parent end up being non-static

Inconsistency clearly proven:

http://3v4l.org/Mkn0L
http://3v4l.org/1L3Wk (same, but without __call)

Test script:
---------------
See http://3v4l.org/Mkn0L

<?php

class A
{
        public function __call($name, $args)
        {
                echo "Not static\n";
        }

    public static function __callStatic($name, $args)
        {
                echo "Static\n";
        }
}

class B extends A
{
    public function test()
        {
                forward_static_call(array('A', 'stuff'));
                call_user_func(array('A', 'stuff'));
                A::stuff();
        }
}

class C
{
        public function test()
        {
                forward_static_call(array('A', 'stuff'));
                call_user_func(array('A', 'stuff'));
                A::stuff();
        }
}

A::test();

echo " = B =\n";
$b = new B();
$b->test();

echo " = C =\n";
$c = new C();
$c->test();

Expected result:
----------------
Static
 = B =
Not static
Not static
Not static
 = C =
Static
Static
Static

Actual result:
--------------
Static
 = B =
Not static
Not static
Not static
 = C =
Static
Static
Static


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=62333&edit=1

Reply via email to