diff --git a/src/lint/linter/ArcanistXHPASTLinter.php b/src/lint/linter/ArcanistXHPASTLinter.php index cad5bffa..88e4ffea 100644 --- a/src/lint/linter/ArcanistXHPASTLinter.php +++ b/src/lint/linter/ArcanistXHPASTLinter.php @@ -4144,9 +4144,13 @@ final class ArcanistXHPASTLinter extends ArcanistBaseXHPASTLinter { continue; } - $throws = $method - ->getChildOfType(5, 'n_STATEMENT_LIST') - ->selectDescendantsOfType('n_THROW'); + $statements = $method->getChildByIndex(5); + + if ($statements->getTypeName() != 'n_STATEMENT_LIST') { + continue; + } + + $throws = $statements->selectDescendantsOfType('n_THROW'); foreach ($throws as $throw) { $this->raiseLintAtNode( diff --git a/src/lint/linter/__tests__/xhpast/tostring-exception.lint-test b/src/lint/linter/__tests__/xhpast/tostring-exception.lint-test index 2788fbdc..32913db7 100644 --- a/src/lint/linter/__tests__/xhpast/tostring-exception.lint-test +++ b/src/lint/linter/__tests__/xhpast/tostring-exception.lint-test @@ -14,5 +14,13 @@ class MyOtherClass { return 'Success'; } } + +interface SomeInterface { + public function __toString(); +} + +abstract class SomeAbstractClass { + abstract public function __toString(); +} ~~~~~~~~~~ error:5:7