- var_dump: documentation ( source)
- class_exists: documentation ( source)
- interface_exists: documentation ( source)
- method_exists: documentation ( source)
<?php
interface Foo {}
interface Bar {
/**
* @return scalar|array|object|null
*/
public function __get(string $k);
}
function Baz(string $thing) : bool {
return method_exists($thing, '__get');
}
function Bat(string $thing) : bool {
return (class_exists($thing) || interface_exists($thing)) && (new ReflectionClass($thing))->hasMethod('__get');
}
var_dump(Baz(Foo::class), Bat(Foo::class), Baz(Bar::class), Bat(Bar::class));