Page MenuHomePhabricator

D10467.diff
No OneTemporary

D10467.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
@@ -384,9 +384,15 @@
continue;
}
- $function_name = $function
- ->getChildOfType(0, 'n_SYMBOL_NAME')
- ->getConcreteString();
+ $function_token = $function
+ ->getChildByIndex(0);
+
+ if ($function_token->getTypeName() != 'n_SYMBOL_NAME') {
+ // This may be `Class::method(...)` or `$var(...)`.
+ continue;
+ }
+
+ $function_name = $function_token->getConcreteString();
switch ($function_name) {
case 'class_exists':
diff --git a/src/lint/linter/__tests__/xhpast/conditional-usage.lint-test b/src/lint/linter/__tests__/xhpast/conditional-usage.lint-test
--- a/src/lint/linter/__tests__/xhpast/conditional-usage.lint-test
+++ b/src/lint/linter/__tests__/xhpast/conditional-usage.lint-test
@@ -11,6 +11,11 @@
new CURLFile('');
new DateTimeImmutable();
}
+
+// These shouldn't fatal.
+if (SomeClass::someStaticMethod($param)) {}
+$var = 'some_func';
+if ($var()) {}
~~~~~~~~~~
error:5:3
error:7:3

File Metadata

Mime Type
text/plain
Expires
Wed, Oct 30, 8:17 PM (1 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6718756
Default Alt Text
D10467.diff (1 KB)

Event Timeline