Page MenuHomePhabricator

D16431.id39516.diff
No OneTemporary

D16431.id39516.diff

diff --git a/src/parser/PhutilDocblockParser.php b/src/parser/PhutilDocblockParser.php
--- a/src/parser/PhutilDocblockParser.php
+++ b/src/parser/PhutilDocblockParser.php
@@ -97,19 +97,34 @@
foreach ($matches as $match) {
list($_, $type, $data) = $match;
$data = trim($data);
- if (isset($special[$type])) {
- $special[$type] = $special[$type]."\n".$data;
- } else {
+
+ // For flags like "@stable" which don't have any string data, set the
+ // value to true.
+ if (!strlen($data)) {
+ $data = true;
+ }
+
+ if (!isset($special[$type])) {
$special[$type] = $data;
+ } else {
+ if (!is_array($special[$type])) {
+ $special[$type] = (array)$special[$type];
+ }
+ $special[$type][] = $data;
}
}
}
- // For flags like "@stable" which don't have any string data, set the value
- // to true.
+ // Convert arrays of size one back to a single value.
foreach ($special as $type => $data) {
- if (!strlen(trim($data))) {
- $special[$type] = true;
+ if (is_array($data)) {
+ $data = array_unique($data);
+
+ if (count($data) == 1) {
+ $data = $data[0];
+ }
+
+ $special[$type] = $data;
}
}
diff --git a/src/parser/__tests__/PhutilDocblockParserTestCase.php b/src/parser/__tests__/PhutilDocblockParserTestCase.php
--- a/src/parser/__tests__/PhutilDocblockParserTestCase.php
+++ b/src/parser/__tests__/PhutilDocblockParserTestCase.php
@@ -52,7 +52,7 @@
case 'multi-specials.docblock':
$this->assertEqual(
array(
- 'special' => "north\nsouth",
+ 'special' => array('north', 'south'),
),
$specials);
$this->assertEqual(
@@ -83,7 +83,7 @@
case 'specials-with-hyphen.docblock':
$this->assertEqual(
array(
- 'repeat-hyphen' => "a\nb",
+ 'repeat-hyphen' => array('a', 'b'),
'multiline-hyphen' => 'mmm nnn',
'normal-hyphen' => 'x',
),

File Metadata

Mime Type
text/plain
Expires
Tue, Apr 1, 12:25 PM (1 w, 4 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7705719
Default Alt Text
D16431.id39516.diff (2 KB)

Event Timeline