MethodReflection::getPrototype() crashes when method has no return #154
Description
When I use this method to grab the protype of a method of my class, it crashes with this error:
"Call to a member function getTypes() on boolean"
It happens because I have a method without return. My opinion is: the return type should be "void" on prototype. Issue #84 adresses the support for void. I've modified the code to make it return void. I could create a pull request if you guys want me to do so.
It was like this:
$return = $docBlock->getTag('return'); $returnTypes = $return->getTypes(); $returnType = count($returnTypes) > 1 ? implode('|', $returnTypes) : $returnTypes[0];
And I've changed to this:
$return = $docBlock->getTag('return'); if($return === false) { $returnType = 'void'; } else { $returnTypes = $return->getTypes(); $returnType = count($returnTypes) > 1 ? implode('|', $returnTypes) : $returnTypes[0]; }
If you don't think it should be void, at least set $returnType variable to empty string or null.
I've read the CONTRIBUTING.md, but I'm still pretty new to contributing on github, so fell free to get this code and push it into repository.
Regards