]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Fix `LINT_ARRAY_SEPARATOR` for heredocs
authorJoshua Spence <josh@joshuaspence.com>
Thu, 25 Sep 2014 22:35:40 +0000 (08:35 +1000)
committerJoshua Spence <josh@joshuaspence.com>
Thu, 25 Sep 2014 22:35:40 +0000 (08:35 +1000)
Summary: It is not correct to add a trailing comma if the `n_ARRAY_VALUE` node is a heredoc string.

Test Plan: Added a test case.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D10569

src/lint/linter/ArcanistXHPASTLinter.php
src/lint/linter/__tests__/xhpast/array-comma.lint-test

index bb952d315f45293400da157cfbc16ced1107aeba..2373d7721ddd21ca2818a2274043ab22da916e20 100644 (file)
@@ -2736,6 +2736,10 @@ final class ArcanistXHPASTLinter extends ArcanistBaseXHPASTLinter {
       $after = last($value->getTokens())->getNextToken();
 
       if ($multiline && (!$after || $after->getValue() != ',')) {
+        if ($value->getChildByIndex(1)->getTypeName() == 'n_HEREDOC') {
+          continue;
+        }
+
         $this->raiseLintAtNode(
           $value,
           self::LINT_ARRAY_SEPARATOR,
index 74856a04d2c480aa24fa2b8c842c765ca7b522e4..031f3f3c1c17c25e8567f590cea4e767604b32e8 100644 (file)
@@ -15,6 +15,11 @@ array(
   'foo',
   array('foo')
 );
+array(
+  'foo' => <<<EOTEXT
+This is some heredoc text.
+EOTEXT
+);
 ~~~~~~~~~~
 advice:3:14
 advice:12:3
@@ -37,3 +42,8 @@ array(
   'foo',
   array('foo'),
 );
+array(
+  'foo' => <<<EOTEXT
+This is some heredoc text.
+EOTEXT
+);