Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15459368
D16431.id39516.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D16431.id39516.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D16431: Improve parsing of docblock specials
Attached
Detach File
Event Timeline
Log In to Comment