From: Joshua Spence Date: Mon, 10 Aug 2015 21:55:11 +0000 (+1000) Subject: Minor improvement for array value linter rule X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=504ff426818898a25c13a597392c7451e73a447e;p=arcanist.git Minor improvement for array value linter rule Summary: This linter rule fails on multi-line arrays with no whitespace before the first array value. Specifically, the following exception is thrown: ``` Fatal error: Call to a member function isAnyWhitespace() on boolean in arcanist/src/lint/linter/xhpast/rules/ArcanistArrayValueXHPASTLinterRule.php on line 40 ``` Test Plan: Added another test case. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D13856 --- diff --git a/src/lint/linter/__tests__/xhpast/array-value.lint-test b/src/lint/linter/__tests__/xhpast/array-value.lint-test index a1339798..9ab10ad7 100644 --- a/src/lint/linter/__tests__/xhpast/array-value.lint-test +++ b/src/lint/linter/__tests__/xhpast/array-value.lint-test @@ -16,12 +16,16 @@ array( /* OPEN */ 1, /* CLOSED */ 2, ); + +array('quack', +); ~~~~~~~~~~ warning:4:5 warning:4:8 warning:8:18 warning:12:17 warning:12:32 +warning:20:7 ~~~~~~~~~~ getSurroundingNonsemanticTokens(); if (strpos(implode('', mpull($before, 'getValue')), "\n") === false) { - if (last($before)->isAnyWhitespace()) { + if (last($before) && last($before)->isAnyWhitespace()) { $token = last($before); $replacement = "\n".$value->getIndentation(); } else {