PHP:类属性中的变量类 - 为什么调用静态方法返回解析错误? [重复]

This question already has an answer here:

Since PHP version 5.3 we can call static method in a variable class like this:

class A 
{
    public static function foo()
    {
        echo 'bar';
    }
}

$myVariableA = A::class;

$myVariableA::foo(); //bar

So, given the examples below, I'd like to understand why Class B works and Class C does not:

class A 
{
    public static function foo()
    {
        echo 'bar';
    }
}

class B 
{
    protected $myVariableA;

    public function __construct()
    {
        $this->myVariableA = A::class;
    }

    public function doSomething()
    {
        $myVariableA = $this->myVariableA;
        return $myVariableA::foo(); //bar (no error)
    }
}

class C
{
    protected $myVariableA;

    public function __construct()
    {
        $this->myVariableA = A::class;
    }

    public function doSomething()
    {
        return $this->myVariableA::foo(); //parse error
    }
}

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

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

Note that I'm not trying to solve the issue here, but I want to understand exactly why it happens (with implementation details, if possible).

</div>

Based on this, the error message is something to with the double semicolon ( ::).

On your doSomething(), try using myVariableA->foo();