mirror of
https://we.phorge.it/source/arcanist.git
synced 2025-02-16 16:58:38 +01:00
Fix PHP version check for function calls with static/variable functions
Summary: D10132 improved this check by eliminating some false postives, but assumes an `n_FUNCTION_CALL` always starts with `n_SYMBOL_NAME`. This is true for `f()`, but not true for `C::m()` or `$v()`. Test Plan: Added and ran unit tests. Reviewers: btrahan, joshuaspence Reviewed By: joshuaspence Subscribers: epriestley Differential Revision: https://secure.phabricator.com/D10467
This commit is contained in:
parent
3f79ae258f
commit
e043d22afd
2 changed files with 14 additions and 3 deletions
|
@ -384,9 +384,15 @@ final class ArcanistXHPASTLinter extends ArcanistBaseXHPASTLinter {
|
|||
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':
|
||||
|
|
|
@ -11,6 +11,11 @@ if (class_exists('CURLFile')) {
|
|||
new CURLFile('');
|
||||
new DateTimeImmutable();
|
||||
}
|
||||
|
||||
// These shouldn't fatal.
|
||||
if (SomeClass::someStaticMethod($param)) {}
|
||||
$var = 'some_func';
|
||||
if ($var()) {}
|
||||
~~~~~~~~~~
|
||||
error:5:3
|
||||
error:7:3
|
||||
|
|
Loading…
Add table
Reference in a new issue