Skip to content

Commit ae82b84

Browse files
committed
Applied multi line fixes to @param, analogous to those in @return.
1 parent bae65d2 commit ae82b84

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/phpDocumentor/Reflection/DocBlock/Tag/ParamTag.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,20 @@ public function __construct($type, $content)
3636
{
3737
$this->tag = $type;
3838
$this->content = $content;
39-
$content = preg_split('/\s+/u', $content);
39+
$content = preg_split(
40+
'/(\s+)/u',
41+
trim($content),
42+
3,
43+
PREG_SPLIT_DELIM_CAPTURE
44+
);
4045

4146
// if the first item that is encountered is not a variable; it is a type
4247
if (isset($content[0])
4348
&& (strlen($content[0]) > 0)
4449
&& ($content[0][0] !== '$')
4550
) {
4651
$this->type = array_shift($content);
52+
array_shift($content);
4753
}
4854

4955
// if the next item starts with a $ it must be the variable name
@@ -52,9 +58,10 @@ public function __construct($type, $content)
5258
&& ($content[0][0] == '$')
5359
) {
5460
$this->variableName = array_shift($content);
61+
array_shift($content);
5562
}
5663

57-
$this->description = implode(' ', $content);
64+
$this->description = implode('', $content);
5865
}
5966

6067
/**

tests/phpDocumentor/Reflection/DocBlock/Tag/ParamTagTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,15 @@ public function provideDataForConstructor()
7676
'param', 'int $bob Number of bobs', 'int', array('int'), '$bob',
7777
'Number of bobs'
7878
),
79+
array('param', "int Description \n on multiple lines", 'int',
80+
array('int'), '', "Description \n on multiple lines"
81+
),
82+
array('param', "int \n\$bob Variable name on a new line", 'int',
83+
array('int'), '$bob', "Variable name on a new line"
84+
),
85+
array('param', "\nint \$bob Type on a new line", 'int',
86+
array('int'), '$bob', "Type on a new line"
87+
)
7988
);
8089
}
8190
}

0 commit comments

Comments
 (0)