1
0
Fork 0
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:
Joshua Spence 2015-01-13 07:23:01 +11:00
parent f58642a8ab
commit af4ab07381
2 changed files with 10 additions and 1 deletions

View file

@ -974,7 +974,12 @@ final class ArcanistXHPASTLinter extends ArcanistBaseXHPASTLinter {
foreach ($nodes as $node) { foreach ($nodes as $node) {
$parent = $node->getParentNode(); $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( $this->raiseLintAtNode(
$node, $node,
self::LINT_BRACE_FORMATTING, self::LINT_BRACE_FORMATTING,

View file

@ -34,6 +34,8 @@ do baz(); while ($x);
if ($x) {} if ($x) {}
else if ($y) {} else if ($y) {}
else {} else {}
declare(ticks = 1);
~~~~~~~~~~ ~~~~~~~~~~
advice:3:14 advice:3:14
warning:7:13 warning:7:13
@ -74,3 +76,5 @@ else bar();
do baz(); while ($x); do baz(); while ($x);
if ($x) {} else if ($y) {} else {} if ($x) {} else if ($y) {} else {}
declare(ticks = 1);