Is_callable and self

Friday, July 11, 2014

Oddly enough, the following both expressions dump bool(true):



class B {
public function __construct() {
var_dump(is_callable(array($this, "z")), is_callable(array("self", "z")));
}
}
class C extends B {
public function z() {}
}

new C();


I had only expected the first to be true. If I call self::z() from inside B, an error is shown.


Is there another, simple way to find out if class B contains a callable method z (other than using the ReflectionMethod class - that more like a last resort)?







http://ift.tt/VUqSUk