Reputation: 1049
$this->categories = tx_dagoupost_lib::getCategories();
For above code: how could I find out wheather getCategories()
declared as staticor not? Because we can also call normal function this way: tx_dagoupost_lib::getCategories();
, although it is not proper. It seems that I can use this one: ReflectionMethod::isStatic
, but I do not know how to use it, there is no example here: http://php.net/manual/en/reflectionmethod.isstatic.php, so can anyone show me how to check if getCategories()
is static function.
Upvotes: 0
Views: 52
Reputation: 1001
you can use something like this:
$methods = $class->getMethods(ReflectionMethod::IS_STATIC | ReflectionMethod::IS_FINAL);
var_dump($methods);
view more details ReflectionClass
Upvotes: 0
Reputation: 100175
you could do:
$check_static = new ReflectionMethod('tx_dagoupost_lib', 'getCategories');
if( $check_static->isStatic() ) {
echo "Its static method";
}
Upvotes: 1
Reputation: 780779
If you look through the rest of the Reflection
documentation, you'll see that this is how you get a ReflectionMethod
object:
$class = new ReflectionClass('tx_dagoupost_lib');
$method = $class->getMethod('getCategories');
if ($method->isStatic()) {
...
}
Upvotes: 1