- is_callable: documentation ( source)
<?php
class A
{
public function testIsCallable(callable $param) {
return is_callable($param);
}
private function privateMethod() {
echo "This is a private method";
}
public function test($param) {
if ($this->testIsCallable($param)) {
$param();
}
}
}
class B extends A
{
public function test($param) {
if ($this->testIsCallable($param)) {
$param();
}
}
}
$a = new A();
$b = new B();
$callable = [$a, 'privMethod'];
$a->test($callable);
$b->test($callable);