I tried to refer this question on SO, but still don't get it.
<?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();
From what I understand, the bar
function is calling the foo
method on class A
statically but the foo
method call the method using the instance of A
which is the parent of B
. I am expecting it should gives me:
I'm the __callStatic() magic method
I'm the __call() magic method
But, apparently, I get:
I'm the __call() magic method
I'm the __call() magic method