mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-25 16:22:42 +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 ($y) {}
|
||||||
else {}
|
else {}
|
||||||
|
|
||||||
|
if ($x) {}else{}
|
||||||
|
|
||||||
declare(ticks = 1);
|
declare(ticks = 1);
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
advice:3:14
|
advice:3:14
|
||||||
|
@ -52,6 +54,7 @@ warning:31:6
|
||||||
warning:32:4
|
warning:32:4
|
||||||
warning:34:11
|
warning:34:11
|
||||||
warning:35:16
|
warning:35:16
|
||||||
|
warning:38:11
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
@ -77,4 +80,6 @@ do baz(); while ($x);
|
||||||
|
|
||||||
if ($x) {} else if ($y) {} else {}
|
if ($x) {} else if ($y) {} else {}
|
||||||
|
|
||||||
|
if ($x) {} else{}
|
||||||
|
|
||||||
declare(ticks = 1);
|
declare(ticks = 1);
|
||||||
|
|
|
@ -20,6 +20,7 @@ final class ArcanistBraceFormattingXHPASTLinterRule
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
list($before, $after) = $list->getSurroundingNonsemanticTokens();
|
list($before, $after) = $list->getSurroundingNonsemanticTokens();
|
||||||
|
|
||||||
if (!$before) {
|
if (!$before) {
|
||||||
$first = head($tokens);
|
$first = head($tokens);
|
||||||
|
|
||||||
|
@ -39,6 +40,7 @@ final class ArcanistBraceFormattingXHPASTLinterRule
|
||||||
' '.$first->getValue());
|
' '.$first->getValue());
|
||||||
} else if (count($before) === 1) {
|
} else if (count($before) === 1) {
|
||||||
$before = reset($before);
|
$before = reset($before);
|
||||||
|
|
||||||
if ($before->getValue() !== ' ') {
|
if ($before->getValue() !== ' ') {
|
||||||
$this->raiseLintAtToken(
|
$this->raiseLintAtToken(
|
||||||
$before,
|
$before,
|
||||||
|
@ -78,7 +80,7 @@ final class ArcanistBraceFormattingXHPASTLinterRule
|
||||||
}
|
}
|
||||||
list($before, $after) = $list->getSurroundingNonsemanticTokens();
|
list($before, $after) = $list->getSurroundingNonsemanticTokens();
|
||||||
if (!$before) {
|
if (!$before) {
|
||||||
$first = last($tokens);
|
$first = head($tokens);
|
||||||
|
|
||||||
$this->raiseLintAtToken(
|
$this->raiseLintAtToken(
|
||||||
$first,
|
$first,
|
||||||
|
|
Loading…
Reference in a new issue