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
/* OPEN */ 1,
/* CLOSED */ 2,
);
+
+array('quack',
+);
~~~~~~~~~~
warning:4:5
warning:4:8
warning:8:18
warning:12:17
warning:12:32
+warning:20:7
~~~~~~~~~~
<?php
/* OPEN */ 1,
/* CLOSED */ 2,
);
+
+array(
+'quack',
+);
list($before, $after) = $value->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 {