From 6a7b1a7bddb2640c2daac879c10c2717a4c946e4 Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 9 Mar 2012 15:45:47 -0800 Subject: [PATCH] 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 --- scripts/phutil_analyzer.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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()); + } } -- 2.43.0