Zend Framework

Zend_Reflection_Parameter::getType() method doesn't work properly

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Trivial Trivial
  • Resolution: Fixed
  • Affects Version/s: 1.8.4
  • Fix Version/s: 1.9.3
  • Component/s: Zend_Reflection
  • Labels:
    None

Description

Looking to following block code:

Foo.php
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.patch
--- 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();
             }

         }

Activity

Hide
Alexander Chirkov added a comment -

i confirm this bag also

Show
Alexander Chirkov added a comment - i confirm this bag also
Hide
Ralph Schindler added a comment -

Changing to "Trivial" priority.
"Should Have" in "Next Mini Release".
Assigning to user Carlton Gibson

Show
Ralph Schindler added a comment - Changing to "Trivial" priority. "Should Have" in "Next Mini Release". Assigning to user Carlton Gibson
Hide
Carlton Gibson added a comment -

Changes to tests/ and library/

Show
Carlton Gibson added a comment - Changes to tests/ and library/
Hide
Carlton Gibson added a comment -

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

Show
Carlton Gibson added a comment - Should be fixed by revision 18073. (Please Review.)
Hide
Carlton Gibson added a comment -

Merged to release branch in r18161

Show
Carlton Gibson added a comment - Merged to release branch in r18161
Hide
Benjamin Eberlei added a comment -

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

Show
Benjamin Eberlei added a comment - This bugfix breaks Zend_CodeGenerator testsuite, now generating code with primative types in the parameter hints
Hide
Carlton Gibson added a comment -

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!)

Show
Carlton Gibson added a comment - 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!)
Hide
Benjamin Eberlei added a comment -

Hey Carlton,

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

Show
Benjamin Eberlei added a comment - Hey Carlton, CodeGenerator is the problem, it dependent on this bug I fixed it already so no problem!

People

Vote (1)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: