diff --git a/src/lint/linter/ArcanistXHPASTLinter.php b/src/lint/linter/ArcanistXHPASTLinter.php index 2e2ec066..9ea60505 100644 --- a/src/lint/linter/ArcanistXHPASTLinter.php +++ b/src/lint/linter/ArcanistXHPASTLinter.php @@ -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, diff --git a/src/lint/linter/__tests__/xhpast/creative-brace-use.lint-test b/src/lint/linter/__tests__/xhpast/creative-brace-use.lint-test index 7d010c6c..969417cc 100644 --- a/src/lint/linter/__tests__/xhpast/creative-brace-use.lint-test +++ b/src/lint/linter/__tests__/xhpast/creative-brace-use.lint-test @@ -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);