1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-10-23 17:18:50 +02:00

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
This commit is contained in:
Joshua Spence 2015-08-11 07:55:11 +10:00
parent 830bcbc2a5
commit 504ff42681
2 changed files with 9 additions and 1 deletions

View file

@ -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
~~~~~~~~~~
<?php
@ -46,3 +50,7 @@ array(
/* OPEN */ 1,
/* CLOSED */ 2,
);
array(
'quack',
);

View file

@ -36,7 +36,7 @@ final class ArcanistArrayValueXHPASTLinterRule
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 {