]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Don't record anonymous functions into the symbol map
authorepriestley <git@epriestley.com>
Fri, 9 Mar 2012 23:45:47 +0000 (15:45 -0800)
committerepriestley <git@epriestley.com>
Fri, 9 Mar 2012 23:45:47 +0000 (15:45 -0800)
Summary:
Although we currently forbid anonymous functions, some day we will likely permit them, and our behavior for them is wrong.

Handle them correctly rather than throwing an exception because we should be covered by D1846 against accidental use, and we won't be on PHP 5.2 forever.

Test Plan: Ran against a test file with anonymous functions. Before, it emitted a declaration of a nameless function; afterward, it did not.

Reviewers: btrahan, edward

Reviewed By: btrahan

CC: aran, epriestley
Maniphest Tasks: T963

Differential Revision: https://secure.phabricator.com/D1847

scripts/phutil_analyzer.php

index b43ff30903a6016fc11d9a450e1e49a448ba9a8e..5dd568a479e24cbebf26ecac52ba11815729c7ab 100755 (executable)
@@ -219,9 +219,14 @@ foreach (Futures($futures) as $file => $future) {
     $functions = $root->selectDescendantsOfType('n_FUNCTION_DECLARATION');
     foreach ($functions as $function) {
       $name = $function->getChildByIndex(2);
-      $requirements->addFunctionDeclaration(
-        $name,
-        $name->getConcreteString());
+      if ($name->getTypeName() == 'n_EMPTY') {
+        // This is an anonymous function; don't record it into the symbol
+        // index.
+      } else {
+        $requirements->addFunctionDeclaration(
+          $name,
+          $name->getConcreteString());
+      }
     }