Index: library/Zend/Reflection/Method.php =================================================================== --- library/Zend/Reflection/Method.php (revision 24511) +++ library/Zend/Reflection/Method.php (working copy) @@ -163,6 +163,6 @@ } // just in case we had code on the bracket lines - return rtrim(ltrim(implode("\n", $lines), '{'), '}'); + return implode("\n", $lines); } } Index: tests/Zend/Reflection/MethodTest.php =================================================================== --- tests/Zend/Reflection/MethodTest.php (revision 24511) +++ tests/Zend/Reflection/MethodTest.php (working copy) @@ -26,6 +26,11 @@ require_once 'Zend/Reflection/Method.php'; /** + * @see ZF-9018 + */ +require_once dirname(__FILE__) . '/_files/ZF9018TestClass.php'; + +/** * @category Zend * @package Zend_Reflection * @subpackage UnitTests @@ -79,6 +84,36 @@ $reflectionMethod = new Zend_Reflection_Method('Zend_Reflection_TestSampleClass6', 'doSomething'); $this->assertEquals($body, $reflectionMethod->getBody()); } + + /** + * @group ZF-9018 + * @group ZF-9501 + */ + public function testGetBodyReturnsCorrectBodyWhenContentEndsWithClosingCurlyBrace() + { + $body = ' if ( true ) { + echo "True"; + } else { + echo "False"; + }'; + $reflectionMethod = new Zend_Reflection_Method('ZF9018TestClass', 'doSomething'); + $this->assertEquals($body, $reflectionMethod->getBody()); + } + + /** + * @group ZF-9018 + * @group ZF-9501 + */ + public function testGetBodyReturnsCorrectBodyWhenMethodWithInlineOpenBraceHasBodyWhichEndsWithClosingCurlyBrace() + { + $body = ' if ( true ) { + echo "True"; + } else { + echo "False"; + }'; + $reflectionMethod = new Zend_Reflection_Method('ZF9018TestClass', 'doSomethingOpenBraceInline'); + $this->assertEquals($body, $reflectionMethod->getBody()); + } public function testGetContentsReturnsCorrectContent() { Index: tests/Zend/Reflection/_files/ZF9018TestClass.php =================================================================== --- tests/Zend/Reflection/_files/ZF9018TestClass.php (revision 0) +++ tests/Zend/Reflection/_files/ZF9018TestClass.php (revision 0) @@ -0,0 +1,21 @@ +