]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Allow `new self` in linter
authorvrana <jakubv@fb.com>
Tue, 5 Mar 2013 21:38:49 +0000 (13:38 -0800)
committervrana <jakubv@fb.com>
Tue, 5 Mar 2013 21:51:58 +0000 (13:51 -0800)
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

scripts/phutil_symbols.php

index 18ab479e038a52d296defcddd9511b2d590da04e..50a342e80d2caae731dbd49d25492ae6bde55926 100755 (executable)
@@ -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;
   }