0
$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.

1
  • Why do you need to do this in the program? Why don't you just look at the code and see if it say "static" before writing the call? Commented Aug 16, 2013 at 7:24

3 Answers 3

1

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()) {
    ...
}
Sign up to request clarification or add additional context in comments.

Comments

1

you could do:

$check_static = new ReflectionMethod('tx_dagoupost_lib', 'getCategories');

if( $check_static->isStatic() ) {
   echo "Its static method";
}

Comments

0

you can use something like this:

$methods = $class->getMethods(ReflectionMethod::IS_STATIC | ReflectionMethod::IS_FINAL);
var_dump($methods);

view more details ReflectionClass

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.