From 2348c16485ca798a6c9a6f2a4c4d950201bfb9ea Mon Sep 17 00:00:00 2001 From: Vasil Rangelov Date: Sun, 11 Nov 2012 17:45:16 +0200 Subject: [PATCH] Applied multi line fixes to @param, analogous to those in @return. --- .../Reflection/DocBlock/Tag/ParamTag.php | 11 +++++++++-- .../Reflection/DocBlock/Tag/ParamTagTest.php | 9 +++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/phpDocumentor/Reflection/DocBlock/Tag/ParamTag.php b/src/phpDocumentor/Reflection/DocBlock/Tag/ParamTag.php index 8688766..12edd11 100644 --- a/src/phpDocumentor/Reflection/DocBlock/Tag/ParamTag.php +++ b/src/phpDocumentor/Reflection/DocBlock/Tag/ParamTag.php @@ -36,7 +36,12 @@ class ParamTag extends ReturnTag { $this->tag = $type; $this->content = $content; - $content = preg_split('/\s+/u', $content); + $content = preg_split( + '/(\s+)/u', + trim($content), + 3, + PREG_SPLIT_DELIM_CAPTURE + ); // if the first item that is encountered is not a variable; it is a type if (isset($content[0]) @@ -44,6 +49,7 @@ class ParamTag extends ReturnTag && ($content[0][0] !== '$') ) { $this->type = array_shift($content); + array_shift($content); } // if the next item starts with a $ it must be the variable name @@ -52,9 +58,10 @@ class ParamTag extends ReturnTag && ($content[0][0] == '$') ) { $this->variableName = array_shift($content); + array_shift($content); } - $this->description = implode(' ', $content); + $this->description = implode('', $content); } /** diff --git a/tests/phpDocumentor/Reflection/DocBlock/Tag/ParamTagTest.php b/tests/phpDocumentor/Reflection/DocBlock/Tag/ParamTagTest.php index 8db7e46..5f1051d 100644 --- a/tests/phpDocumentor/Reflection/DocBlock/Tag/ParamTagTest.php +++ b/tests/phpDocumentor/Reflection/DocBlock/Tag/ParamTagTest.php @@ -76,6 +76,15 @@ class ParamTagTest extends \PHPUnit_Framework_TestCase 'param', 'int $bob Number of bobs', 'int', array('int'), '$bob', 'Number of bobs' ), + array('param', "int Description \n on multiple lines", 'int', + array('int'), '', "Description \n on multiple lines" + ), + array('param', "int \n\$bob Variable name on a new line", 'int', + array('int'), '$bob', "Variable name on a new line" + ), + array('param', "\nint \$bob Type on a new line", 'int', + array('int'), '$bob', "Type on a new line" + ) ); } }