mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-22 06:42:41 +01:00
Fix brace formatting linter rule
Summary: Fixes T8847. Test Plan: Ran `arc lint` on a test file: ```lang=php <?php if ($x) { echo 'foo'; }else { echo 'bar'; } ``` Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: epriestley, Korvin Maniphest Tasks: T8847 Differential Revision: https://secure.phabricator.com/D13633
This commit is contained in:
parent
3793998df4
commit
58302432cc
2 changed files with 8 additions and 1 deletions
|
@ -35,6 +35,8 @@ if ($x) {}
|
|||
else if ($y) {}
|
||||
else {}
|
||||
|
||||
if ($x) {}else{}
|
||||
|
||||
declare(ticks = 1);
|
||||
~~~~~~~~~~
|
||||
advice:3:14
|
||||
|
@ -52,6 +54,7 @@ warning:31:6
|
|||
warning:32:4
|
||||
warning:34:11
|
||||
warning:35:16
|
||||
warning:38:11
|
||||
~~~~~~~~~~
|
||||
<?php
|
||||
|
||||
|
@ -77,4 +80,6 @@ do baz(); while ($x);
|
|||
|
||||
if ($x) {} else if ($y) {} else {}
|
||||
|
||||
if ($x) {} else{}
|
||||
|
||||
declare(ticks = 1);
|
||||
|
|
|
@ -20,6 +20,7 @@ final class ArcanistBraceFormattingXHPASTLinterRule
|
|||
continue;
|
||||
}
|
||||
list($before, $after) = $list->getSurroundingNonsemanticTokens();
|
||||
|
||||
if (!$before) {
|
||||
$first = head($tokens);
|
||||
|
||||
|
@ -39,6 +40,7 @@ final class ArcanistBraceFormattingXHPASTLinterRule
|
|||
' '.$first->getValue());
|
||||
} else if (count($before) === 1) {
|
||||
$before = reset($before);
|
||||
|
||||
if ($before->getValue() !== ' ') {
|
||||
$this->raiseLintAtToken(
|
||||
$before,
|
||||
|
@ -78,7 +80,7 @@ final class ArcanistBraceFormattingXHPASTLinterRule
|
|||
}
|
||||
list($before, $after) = $list->getSurroundingNonsemanticTokens();
|
||||
if (!$before) {
|
||||
$first = last($tokens);
|
||||
$first = head($tokens);
|
||||
|
||||
$this->raiseLintAtToken(
|
||||
$first,
|
||||
|
|
Loading…
Reference in a new issue