From 4d6d3feb7fc1fb63789554dddee8e489999c1201 Mon Sep 17 00:00:00 2001 From: Joshua Spence Date: Tue, 7 Jul 2015 19:22:12 +1000 Subject: [PATCH] Use PhutilClassMapQuery Summary: Use `PhutilClassMapQuery` where appropriate. Test Plan: `arc unit` Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: epriestley, Korvin Differential Revision: https://secure.phabricator.com/D13428 --- .../xhpast/ArcanistXHPASTLinterRule.php | 25 +++---------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/src/lint/linter/xhpast/ArcanistXHPASTLinterRule.php b/src/lint/linter/xhpast/ArcanistXHPASTLinterRule.php index 97e429fb..bf1c2aad 100644 --- a/src/lint/linter/xhpast/ArcanistXHPASTLinterRule.php +++ b/src/lint/linter/xhpast/ArcanistXHPASTLinterRule.php @@ -6,29 +6,10 @@ abstract class ArcanistXHPASTLinterRule extends Phobject { private $lintID = null; final public static function loadAllRules() { - $rules = array(); - - $symbols = id(new PhutilSymbolLoader()) + return id(new PhutilClassMapQuery()) ->setAncestorClass(__CLASS__) - ->loadObjects(); - - foreach ($symbols as $class => $rule) { - $id = $rule->getLintID(); - - if (isset($rules[$id])) { - throw new Exception( - pht( - 'Two linter rules (`%s`, `%s`) share the same lint ID (%d). '. - 'Each linter rule must have a unique ID.', - $class, - get_class($rules[$id]), - $id)); - } - - $rules[$id] = $rule; - } - - return $rules; + ->setUniqueMethod('getLintID') + ->execute(); } final public function getLintID() {