From 7130004015f93a6733dc9b8f5357728408c57469 Mon Sep 17 00:00:00 2001 From: Miorel-Lucian Palii Date: Fri, 28 Jun 2013 18:24:30 -0700 Subject: [PATCH] Don't instantiate abstract classes in ArcanistConfiguration::buildAllWorkflows Summary: I wanted to write a couple of workflows that shared some code in an abstract superclass, but ##arc## would fail trying to instantiate the abstract class. As it turns out, we can modernize the ##buildAllWorkflows## function a bit, and it will only load concrete objects. Test Plan: 1. Define an abstract subclass of ##ArcanistBaseWorkflow##. 2. ##arc liberate## the source directory that contains it. 3. Try any ##arc## operation without this diff, and see it fail. 4. Patch this diff and see that ##arc## operations work now. Reviewers: epriestley, vrana Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D6324 --- src/configuration/ArcanistConfiguration.php | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/configuration/ArcanistConfiguration.php b/src/configuration/ArcanistConfiguration.php index 23d58c66..fe4a79bb 100644 --- a/src/configuration/ArcanistConfiguration.php +++ b/src/configuration/ArcanistConfiguration.php @@ -33,28 +33,25 @@ class ArcanistConfiguration { } public function buildAllWorkflows() { - $symbols = id(new PhutilSymbolLoader()) - ->setType('class') - ->setAncestorClass('ArcanistBaseWorkflow') - ->selectAndLoadSymbols(); + $workflows_by_name = array(); - $workflows = array(); - foreach ($symbols as $symbol) { - $class = $symbol['name']; - $workflow = newv($class, array()); + $workflows_by_class_name = id(new PhutilSymbolLoader()) + ->setAncestorClass('ArcanistBaseWorkflow') + ->loadObjects(); + foreach ($workflows_by_class_name as $class => $workflow) { $name = $workflow->getWorkflowName(); - if (isset($workflows[$name])) { - $other = get_class($workflows[$name]); + if (isset($workflows_by_name[$name])) { + $other = get_class($workflows_by_name[$name]); throw new Exception( "Workflows {$class} and {$other} both implement workflows named ". "{$name}."); } - $workflows[$workflow->getWorkflowName()] = $workflow; + $workflows_by_name[$name] = $workflow; } - return $workflows; + return $workflows_by_name; } final public function isValidWorkflow($workflow) { -- 2.43.0