Bug #62330 [Opn->Nab]: PHP confuse "__callStatic" with "__call"

[email protected]
Newsgroups php.bugs
Message-ID <[email protected]>
Edit report at https://bugs.php.net/bug.php?id=62330&edit=1

 ID:                 62330
 Updated by:         [email protected]
 Reported by:        magike dot net at gmail dot com
 Summary:            PHP confuse "__callStatic" with "__call"
-Status:             Open
+Status:             Not a bug
 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:

As mentioned, this is not a bug, but a feature. A "fix" was applied to PHP 5.3.3, and then reverted in PHP 5.3.4: https://3v4l.org/9kknr


Previous Comments:
------------------------------------------------------------------------
[2015-12-20 17:28:21] [email protected]

As mentioned, this is not a bug, but a feature. A "fix" was applied to PHP 5.3.3, and then reverted in PHP 5.3.4: https://3v4l.org/9kknr

------------------------------------------------------------------------
[2013-01-02 11:01:22] sadasd at yahoo dot com

Please change $c->text(); to $c->test();

------------------------------------------------------------------------
[2012-06-15 11:13:28] Sjon at hortensius dot net

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()

------------------------------------------------------------------------
[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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.