From: epriestley Date: Fri, 9 Mar 2012 23:45:47 +0000 (-0800) Subject: Don't record anonymous functions into the symbol map X-Git-Tag: conduit-4~105 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=6a7b1a7bddb2640c2daac879c10c2717a4c946e4;p=arcanist.git Don't record anonymous functions into the symbol map 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 --- diff --git a/scripts/phutil_analyzer.php b/scripts/phutil_analyzer.php index b43ff309..5dd568a4 100755 --- a/scripts/phutil_analyzer.php +++ b/scripts/phutil_analyzer.php @@ -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()); + } }