- forward_static_call_array: documentation ( source)
<?php
class ParentClass {
public static function whoami() {
echo static::class;
}
}
class Child extends ParentClass {
public static function whoami() {
echo "Don't call me now!";
parent::whoami();
}
}
$className = ParentClass::class;
$method = 'whoami';
$closure = function(array $args) use ($className, $method) {
return forward_static_call_array([$className, $method], $args);
};
$bindedClosure = $closure->bindTo(null, Child::class);
$bindedClosure->__invoke([]);