From 1eee75496a5a08f7e2b04a2a50effb4ce7ce478c Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 2 Sep 2016 04:51:40 -0700 Subject: [PATCH] Update Diviner for array-valued `@doc-stuff` return values from DocblockParser Summary: Ref T11575. After D16431, the parser may return arrays. Test Plan: Ran `bin/diviner generate --clean` in `phabricator/` without errors. Previously, this raised some parsing errors related to getting arrays where strings were expected. Reviewers: chad, yelirekim, joshuaspence Reviewed By: joshuaspence Maniphest Tasks: T11575 Differential Revision: https://secure.phabricator.com/D16487 --- .../diviner/atomizer/DivinerPHPAtomizer.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/applications/diviner/atomizer/DivinerPHPAtomizer.php b/src/applications/diviner/atomizer/DivinerPHPAtomizer.php index 36616897f2..201055a15c 100644 --- a/src/applications/diviner/atomizer/DivinerPHPAtomizer.php +++ b/src/applications/diviner/atomizer/DivinerPHPAtomizer.php @@ -141,7 +141,7 @@ final class DivinerPHPAtomizer extends DivinerAtomizer { $docs = idx($metadata, 'param'); if ($docs) { - $docs = explode("\n", $docs); + $docs = (array)$docs; $docs = array_filter($docs); } else { $docs = array(); @@ -283,6 +283,15 @@ final class DivinerPHPAtomizer extends DivinerAtomizer { } } + $return = (array)$return; + if (count($return) > 1) { + $atom->addWarning( + pht( + 'Documentation specifies `%s` multiple times.', + '@return')); + } + $return = head($return); + if ($atom->getName() == '__construct' && $atom->getType() == 'method') { $return_spec = array( 'doctype' => 'this',