diff -r 2251fb41dbc7 -r 1e110b03ae96 web/lib/Zend/Reflection/Method.php --- a/web/lib/Zend/Reflection/Method.php Sun Apr 21 10:07:03 2013 +0200 +++ b/web/lib/Zend/Reflection/Method.php Sun Apr 21 21:54:24 2013 +0200 @@ -14,9 +14,9 @@ * * @category Zend * @package Zend_Reflection - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Method.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Method.php 24870 2012-06-02 02:15:12Z adamlundrigan $ */ /** @@ -37,7 +37,7 @@ /** * @category Zend * @package Zend_Reflection - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Reflection_Method extends ReflectionMethod @@ -145,24 +145,43 @@ { $lines = array_slice( file($this->getDeclaringClass()->getFileName(), FILE_IGNORE_NEW_LINES), - $this->getStartLine(), - ($this->getEndLine() - $this->getStartLine()), + $this->getStartLine()-1, + ($this->getEndLine() - $this->getStartLine()) + 1, true ); - $firstLine = array_shift($lines); + // Strip off lines until we come to a closing bracket + do { + if (count($lines) == 0) break; + $firstLine = array_shift($lines); + } while (strpos($firstLine, ')') === false); - if (trim($firstLine) !== '{') { - array_unshift($lines, $firstLine); + // If the opening brace isn't on the same line as method + // signature, then we should pop off more lines until we find it + if (strpos($firstLine,'{') === false) { + do { + if (count($lines) == 0) break; + $firstLine = array_shift($lines); + } while (strpos($firstLine, '{') === false); + } + + // If there are more characters on the line after the opening brace, + // push them back onto the lines stack as they are part of the body + $restOfFirstLine = trim(substr($firstLine, strpos($firstLine, '{')+1)); + if (!empty($restOfFirstLine)) { + array_unshift($lines, $restOfFirstLine); } $lastLine = array_pop($lines); - if (trim($lastLine) !== '}') { - array_push($lines, $lastLine); + // If there are more characters on the line before the closing brace, + // push them back onto the lines stack as they are part of the body + $restOfLastLine = trim(substr($lastLine, 0, strrpos($lastLine, '}')-1)); + if (!empty($restOfLastLine)) { + array_push($lines, $restOfLastLine); } // just in case we had code on the bracket lines - return rtrim(ltrim(implode("\n", $lines), '{'), '}'); + return implode("\n", $lines); } }