From 901f12dcb970e5215c309f8a48020a1269d36aa4 Mon Sep 17 00:00:00 2001 From: vrana Date: Tue, 5 Mar 2013 13:38:49 -0800 Subject: [PATCH] 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 --- scripts/phutil_symbols.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/scripts/phutil_symbols.php b/scripts/phutil_symbols.php index 18ab479e..50a342e8 100755 --- a/scripts/phutil_symbols.php +++ b/scripts/phutil_symbols.php @@ -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; }