ZF-7227: Zend_Reflection_Parameter::getType() method doesn't work properly


Looking to following block code:

class Foo {
     * @param integer $a
         * @param boolean $b
     * @return boolean
    public function bar($a, $b) {
            $r = new Zend_Reflection_Class($this);
            $p = $r->getMethod('bar')->getParameters();
            $t = $p[0]->getType();

,the value of $t is null instead of integer. The problem seems to be on 111 and 112 lines, from Reflection/Parameter.php file ;value of "$this->getPosition()" should not decrement:

--- Parameter.php       2009-07-08 15:51:53.000000000 +0300
+++ ParameterFix.php    2009-07-08 17:34:50.000000000 +0300
@@ -108,8 +108,8 @@
         if ($docblock = $this->getDeclaringFunction()->getDocblock()) {
             $params = $docblock->getTags('param');

-            if (isset($params[$this->getPosition() - 1])) {
-                return $params[$this->getPosition() - 1]->getType();
+            if (isset($params[$this->getPosition()])) {
+                return $params[$this->getPosition()]->getType();



i confirm this bag also

Changing to "Trivial" priority. "Should Have" in "Next Mini Release". Assigning to user [~carlton]

Changes to tests/ and library/

Should be fixed by revision 18073. (Please Review.)

Merged to release branch in r18161

This bugfix breaks Zend_CodeGenerator testsuite, now generating code with primative types in the parameter hints

Benjamin, this is... er... interesting.

The bug fix looks correct to me: the old test case was passing by luck -- it just happened that two params had the same type and so the fact the type for the wrong parameter was being returned wasn't picked up.

The new test case goes through each of the parameters and so picks up the error (it's not just THAT the old code fails, but HOW it fails that is interesting.) With the bug fix in place the new test passes. I've also been using it heavily and have not NOTICED a problem.

Of course there could be something else going on... :-)

I've not time to pop into the BugHunt today but I'm totally happy to track this one down. (It just so happens I wanted to get into Zend_CodeGenerator anyway.) Which tests were passing at r18072 but fail at r18073? (If you like, you can create a case and assign it to me -- or reopen this one if you think there is a fault with the fix -- sorry I can't help sooner!)

Hey Carlton,

CodeGenerator is the problem, it dependent on this bug ;-) I fixed it already so no problem! :-)