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

 ID:                 62330
 Comment by:         Sjon at hortensius dot net
 Reported by:        magike dot net at gmail dot com
 Summary:            PHP confuse "__callStatic" with "__call"
 Status:             Open
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   Ubuntu Server 12.04
 PHP Version:        5.3.14
 Block user comment: N
 Private report:     N

 New Comment:

I actually found a related bug, I filed it here:

https://bugs.php.net/bug.php?id=62333

PS. there is a small typo in your script, your last call to ->text() should 
have 
gone to ->test()


Previous Comments:
------------------------------------------------------------------------
[2012-06-15 10:46:13] Sjon at hortensius dot net

This is actually a feature: when you use CLASSNAME:: while extending that 
class, 
it mimics parent::, but to a specific class (so you can skip one parent)

You should instead use forward_static_call for this

------------------------------------------------------------------------
[2012-06-15 02:40:29] magike dot net at gmail dot com

Description:
------------
I find PHP will call "__call" instead of "__callStatic" when I'm calling a non-
exists static method from the class (Class A) which is the parent of current 
class 
(Class B).

And if the class (Class C) is not the child of that class (Class A), the result 
will be correct.



Test script:
---------------
<?php

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

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

class B extends A
{
    public function test()
    {
        A::test();
    }
}

class C
{
    public function test()
    {
        A::test();
    }
}

A::test();

$b = new B();
$b->test();

$c = new C();
$c->text();

Expected result:
----------------
YES
YES
YES

Actual result:
--------------
YES
NO
YES


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



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

Reply via email to