mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-21 22:32:41 +01: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:
parent
830bcbc2a5
commit
504ff42681
2 changed files with 9 additions and 1 deletions
|
@ -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',
|
||||
);
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue