1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-09-19 16:38:51 +02:00

Allow new self in linter

Summary: Also allow `sTaTiC::$x` which is a valid PHP (contrary to `sElF::$x` which is invalid PHP but I allowed that too).

Test Plan:
  new self;

Reviewers: epriestley

Reviewed By: epriestley

CC: wez, aran, Korvin

Differential Revision: https://secure.phabricator.com/D5241
This commit is contained in:
vrana 2013-03-05 13:38:49 -08:00
parent 64bbcda431
commit 901f12dcb9

View file

@ -237,6 +237,12 @@ foreach ($classes as $class) {
}
}
$magic_names = array(
'static' => true,
'parent' => true,
'self' => true,
);
// This is "new X()".
$uses_of_new = $root->selectDescendantsOfType('n_NEW');
foreach ($uses_of_new as $new_operator) {
@ -245,6 +251,10 @@ foreach ($uses_of_new as $new_operator) {
$name->getTypeName() == 'n_VARIABLE_VARIABLE') {
continue;
}
$name_concrete = strtolower($name->getConcreteString());
if (isset($magic_names[$name_concrete])) {
continue;
}
$need[] = array(
'type' => 'class',
'symbol' => $name,
@ -258,12 +268,7 @@ foreach ($static_uses as $static_use) {
if ($name->getTypeName() != 'n_CLASS_NAME') {
continue;
}
$name_concrete = $name->getConcreteString();
$magic_names = array(
'static' => true,
'parent' => true,
'self' => true,
);
$name_concrete = strtolower($name->getConcreteString());
if (isset($magic_names[$name_concrete])) {
continue;
}