mirror of
https://we.phorge.it/source/arcanist.git
synced 2025-01-10 14:51:05 +01:00
Improve lint handling of declare()
special statement blocks
Summary: Fixes T6830. Don't require `n_STATEMENT` nested under `n_DECLARE` to be written using braces. Test Plan: Added a test case. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T6830 Differential Revision: https://secure.phabricator.com/D11350
This commit is contained in:
parent
f58642a8ab
commit
af4ab07381
2 changed files with 10 additions and 1 deletions
|
@ -974,7 +974,12 @@ final class ArcanistXHPASTLinter extends ArcanistBaseXHPASTLinter {
|
|||
foreach ($nodes as $node) {
|
||||
$parent = $node->getParentNode();
|
||||
|
||||
if ($parent && $parent->getTypeName() != 'n_STATEMENT_LIST') {
|
||||
if (!$parent) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$type = $parent->getTypeName();
|
||||
if ($type != 'n_STATEMENT_LIST' && $type != 'n_DECLARE') {
|
||||
$this->raiseLintAtNode(
|
||||
$node,
|
||||
self::LINT_BRACE_FORMATTING,
|
||||
|
|
|
@ -34,6 +34,8 @@ do baz(); while ($x);
|
|||
if ($x) {}
|
||||
else if ($y) {}
|
||||
else {}
|
||||
|
||||
declare(ticks = 1);
|
||||
~~~~~~~~~~
|
||||
advice:3:14
|
||||
warning:7:13
|
||||
|
@ -74,3 +76,5 @@ else bar();
|
|||
do baz(); while ($x);
|
||||
|
||||
if ($x) {} else if ($y) {} else {}
|
||||
|
||||
declare(ticks = 1);
|
||||
|
|
Loading…
Reference in a new issue