0

I am using PHP ReflectionClass to extract as much information about a class as possible. Can I also use this to get return values from functions? Or does that not make sense since reflection only profiles what an object accepts?

2 Answers 2

1

You can not rely, if a function has a well defined return value you can simply extract from the source code. Imagine something like this:

return $this->isValid() ? $result : $this->createNullObject();

Thats hard (/impossible) to parse just to get the return value. You can use DocComments instead. @return is the usual tag for that use

/**
 * MyMethod
 *
 * @return int
 */

Call getDocComment() on a ReflectionMethod-object and then parse the docComment.

Sign up to request clarification or add additional context in comments.

Comments

0

for internal functions you could use

$reflect = new ReflectionExtension('standard');
echo "<pre>" . $reflect . "</pre>"; 

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.