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
// 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());
1 ?: 2;
$a = 'stdClass';
$a::m();
+echo __DIR__;
~~~~~~~~~~
error:3:1
error:4:5
error:7:3
error:8:1
error:10:1
+error:13:6
~~~~~~~~~~
~~~~~~~~~~
{"config": {"xhpast.php-version": "5.2.3"}}