Page MenuHomePhabricator

D12892.diff
No OneTemporary

D12892.diff

diff --git a/src/lint/linter/ArcanistXHPASTLinter.php b/src/lint/linter/ArcanistXHPASTLinter.php
--- a/src/lint/linter/ArcanistXHPASTLinter.php
+++ b/src/lint/linter/ArcanistXHPASTLinter.php
@@ -4144,9 +4144,13 @@
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
--- a/src/lint/linter/__tests__/xhpast/tostring-exception.lint-test
+++ b/src/lint/linter/__tests__/xhpast/tostring-exception.lint-test
@@ -14,5 +14,13 @@
return 'Success';
}
}
+
+interface SomeInterface {
+ public function __toString();
+}
+
+abstract class SomeAbstractClass {
+ abstract public function __toString();
+}
~~~~~~~~~~
error:5:7

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 26, 7:20 PM (21 h, 33 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6790585
Default Alt Text
D12892.diff (1 KB)

Event Timeline