From 247a4fabb8b6f0751f246665f7779909ba6310f6 Mon Sep 17 00:00:00 2001 From: Joshua Spence Date: Fri, 26 Sep 2014 08:35:40 +1000 Subject: [PATCH] Fix `LINT_ARRAY_SEPARATOR` for heredocs 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 | 4 ++++ src/lint/linter/__tests__/xhpast/array-comma.lint-test | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/lint/linter/ArcanistXHPASTLinter.php b/src/lint/linter/ArcanistXHPASTLinter.php index bb952d31..2373d772 100644 --- a/src/lint/linter/ArcanistXHPASTLinter.php +++ b/src/lint/linter/ArcanistXHPASTLinter.php @@ -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, diff --git a/src/lint/linter/__tests__/xhpast/array-comma.lint-test b/src/lint/linter/__tests__/xhpast/array-comma.lint-test index 74856a04..031f3f3c 100644 --- a/src/lint/linter/__tests__/xhpast/array-comma.lint-test +++ b/src/lint/linter/__tests__/xhpast/array-comma.lint-test @@ -15,6 +15,11 @@ array( 'foo', array('foo') ); +array( + 'foo' => << <<