Is this a bug that __call and _ __callStatic will generate after they are inherited in php?

  ios, question

Please look at the following code

<?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();
    }

    public static function stest()
    {
        A::test();
    }
}

A::test();

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

B::stest();

The above code will be output

YES
NO
YES

When we use it directly in other placesA::testWhich calls the__callStaticThe output is normalYes.

But when we use a classAlex BandInheritanceALater, inAlex BandUsed in a method ofA::testIf we happen to be here againAIs defined in__callMethod, this is afterA::testWill call__call.

Is this a bug in php?

—————— update ——————-

This is @Laruence on blog (http://www.laruence.com/2012/06/14/26 …The effect of php scope mentioned in) on the class calling context, but after careful reading, I found that my problem here has certain particularity.

  1. I am hereAIs defined in__callStatic, soA::testIt is not the non-existent static method that is called, but it actually calls the__callGo up.
  2. If I putAlex BandAndARemove the inheritance relation of, then all the above outputs areYes.
  3. Based on the above two points, I think php thinks hereA::test() == $this->test().

This is my conclusion, and according to @Laruence’s explanation, php’s design makes sense here, but whether this design is reasonable or not is up to everyone to decide.

—————— update ——————-

I have found a bug description almost the same as mine in php’s bug system.
https://bugs.php.net/bug.php? id=52713

The final reply shows that it has been fixed in PHP 5.3.4, but I am now using version 5.3.13, and this error still exists.

The problem is a bit confusing, think about parent::test ()? Static or not lies in the calling scope, not in the:: symbol.