Php 为什么调用的是_调用而不是_调用静态

Php 为什么调用的是_调用而不是_调用静态,php,Php,我试着这么说,但还是不明白 <?php class A { public function __call($method, $parameters) { echo "I'm the __call() magic method".PHP_EOL; } public static function __callStatic($method, $parameters) { echo "I'm the __callStatic() mag

我试着这么说,但还是不明白

<?php

class A {
    public function __call($method, $parameters) {
        echo "I'm the __call() magic method".PHP_EOL;
    }

    public static function __callStatic($method, $parameters) {
        echo "I'm the __callStatic() magic method".PHP_EOL;
    }
}

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

    public function foo() {
        parent::foo();
    }
}

(new B)->bar();
(new B)->foo();
但是,显然,我得到:

I'm the __call() magic method
I'm the __call() magic method
A::foo()
,取决于上下文,并不总是静态调用。由于
B::bar()
内部存在
$this
对象,并且
a
中没有声明名为
foo
的静态方法,并且
B
a
的子类,因此将进行实例调用,因此将调用
\uu调用
魔术方法。当这些条件中的任何一个不满足时,将进行静态调用。

来自相关:

A::foo()
不一定是静态调用。也就是说,如果
foo()
不是静态的,并且存在兼容的上下文(
$this
存在,并且它的类是目标方法的类或它的子类),则将进行实例调用

如果
foo()

A类{
公共函数调用($method,$parameters){
echo“我是uu call()魔术方法$method”;
}
公共静态函数\uuu callStatic($method,$parameters){
echo“我是uu callStatic()神奇的方法$method”;
}
}
B类扩展了A类{
公共静态函数foo(){//foo();
我是uu callStatic()神奇的方法foo

I'm the __call() magic method
I'm the __call() magic method
class A {
    public function __call($method, $parameters) {
        echo "I'm the __call() magic method $method".PHP_EOL;
    }

    public static function __callStatic($method, $parameters) {
        echo "I'm the __callStatic() magic method $method".PHP_EOL;
    }
}

class B extends A {
    public static function foo() { // <-- static method
        parent::foo();
    }
}

(new B)->foo();