Applied multi line fixes to @param, analogous to those in @return.

This commit is contained in:
Vasil Rangelov
2012-11-11 17:45:16 +02:00
parent b802727676
commit 2348c16485
2 changed files with 18 additions and 2 deletions
@@ -36,7 +36,12 @@ class ParamTag extends ReturnTag
{ {
$this->tag = $type; $this->tag = $type;
$this->content = $content; $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 the first item that is encountered is not a variable; it is a type
if (isset($content[0]) if (isset($content[0])
@@ -44,6 +49,7 @@ class ParamTag extends ReturnTag
&& ($content[0][0] !== '$') && ($content[0][0] !== '$')
) { ) {
$this->type = array_shift($content); $this->type = array_shift($content);
array_shift($content);
} }
// if the next item starts with a $ it must be the variable name // if the next item starts with a $ it must be the variable name
@@ -52,9 +58,10 @@ class ParamTag extends ReturnTag
&& ($content[0][0] == '$') && ($content[0][0] == '$')
) { ) {
$this->variableName = array_shift($content); $this->variableName = array_shift($content);
array_shift($content);
} }
$this->description = implode(' ', $content); $this->description = implode('', $content);
} }
/** /**
@@ -76,6 +76,15 @@ class ParamTagTest extends \PHPUnit_Framework_TestCase
'param', 'int $bob Number of bobs', 'int', array('int'), '$bob', 'param', 'int $bob Number of bobs', 'int', array('int'), '$bob',
'Number of bobs' '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"
)
); );
} }
} }