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

Two instances of the same problem.

Question: resolve via an internal try/catch or an extra hasDockblock?

hasDocblock() sounds good for me

Attaching a patch to sort this issue.