ZF-7682: Zend_Reflection_Parameter::getType() needs to catch Zend_Reflection_Exception to return null

Issue Type: Improvement Created: 2009-08-25T05:50:57.000+0000 Last Updated: 2012-11-20T21:38:14.000+0000 Status: Open Fix version(s): Reporter: Chris Buckley (cbuckley) Assignee: None Tags: - Zend_Reflection

Related issues: - ZF-7166

Attachments: - reflection.patch


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:


<pre class="highlight">/**
 * Get parameter type
 * @return string
public function getType()
        $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;


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.

Have you found an issue?

See the Overview section for more details.


© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.