mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-12-26 07:20:56 +01:00
Lint against undefined magic symbols
Summary: Fixes T5639. Allows the detection of undefined magic symbols, such as the use of `__DIR__` in a codebase that targets < PHP 5.3.0. Test Plan: Added a test case. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: Korvin, epriestley Maniphest Tasks: T5639 Differential Revision: https://secure.phabricator.com/D11386
This commit is contained in:
parent
bb8e9d7357
commit
7aa89ddf96
2 changed files with 6 additions and 1 deletions
|
@ -596,7 +596,10 @@ final class ArcanistXHPASTLinter extends ArcanistBaseXHPASTLinter {
|
|||
// TODO: Technically, this will include function names. This is unlikely to
|
||||
// cause any issues (unless, of course, there existed a function that had
|
||||
// the same name as some constant).
|
||||
$constants = $root->selectDescendantsOfType('n_SYMBOL_NAME');
|
||||
$constants = $root->selectDescendantsOfTypes(array(
|
||||
'n_SYMBOL_NAME',
|
||||
'n_MAGIC_SCALAR',
|
||||
));
|
||||
foreach ($constants as $node) {
|
||||
$name = $node->getConcreteString();
|
||||
$version = idx($compat_info['constants'], $name, array());
|
||||
|
|
|
@ -10,6 +10,7 @@ static::m();
|
|||
1 ?: 2;
|
||||
$a = 'stdClass';
|
||||
$a::m();
|
||||
echo __DIR__;
|
||||
~~~~~~~~~~
|
||||
error:3:1
|
||||
error:4:5
|
||||
|
@ -18,6 +19,7 @@ error:6:3
|
|||
error:7:3
|
||||
error:8:1
|
||||
error:10:1
|
||||
error:13:6
|
||||
~~~~~~~~~~
|
||||
~~~~~~~~~~
|
||||
{"config": {"xhpast.php-version": "5.2.3"}}
|
||||
|
|
Loading…
Reference in a new issue