ZF-7682: Zend_Reflection_Parameter::getType() needs to catch Zend_Reflection_Exception to return null
Description
Zend_Reflection_Parameter::getType() gets the docblock from the declaring function, and just checks whether it evaluates to true. If there was no (or invalid) docblock, the getDocblock() method on Zend_Reflection_Method / Zend_Reflection_Function throws a Zend_Reflection_Exception. The 'return null' portion of Zend_Reflection_Parameter::getType() thus never gets executed. Suggest the following try/catch:
\
/**
* Get parameter type
*
* @return string
*/
public function getType()
{
try
{
$docblock = $this->getDeclaringFunction()->getDocblock();
$params = $docblock->getTags('param');
if (isset($params[$this->getPosition() - 1]))
{
return $params[$this->getPosition() - 1]->getType();
}
}
catch (Zend_Reflection_Exception $ex)
{
return null;
}
}
Comments
Posted by Carlton Gibson (carlton) on 2009-09-14T07:02:04.000+0000
Two instances of the same problem.
Question: resolve via an internal try/catch or an extra hasDockblock?
Posted by Benjamin Eberlei (beberlei) on 2009-09-18T08:00:41.000+0000
hasDocblock() sounds good for me
Posted by Chris Buckley (cbuckley) on 2010-03-08T03:08:01.000+0000
Attaching a patch to sort this issue.