From 73f48aca74094b4871bb71059ac61af235fce2dd Mon Sep 17 00:00:00 2001 From: epriestley Date: Sat, 11 Apr 2020 15:30:43 -0700 Subject: [PATCH] Allow "loadHardpoints()" to accept a single ref and/or a single hardpoint Summary: Ref T13490. There's more `array(...)` happening in this API than necessary. Sugar it slightly. Test Plan: Grepped for "loadHardpoints()", ran a couple workflows. Maniphest Tasks: T13490 Differential Revision: https://secure.phabricator.com/D21088 --- src/browse/workflow/ArcanistBrowseWorkflow.php | 4 +--- src/workflow/ArcanistDiffWorkflow.php | 8 ++------ src/workflow/ArcanistFeatureBaseWorkflow.php | 5 +---- src/workflow/ArcanistInspectWorkflow.php | 4 +--- src/workflow/ArcanistWorkflow.php | 12 ++++++++++-- 5 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/browse/workflow/ArcanistBrowseWorkflow.php b/src/browse/workflow/ArcanistBrowseWorkflow.php index aa4d86a6..7346ed14 100644 --- a/src/browse/workflow/ArcanistBrowseWorkflow.php +++ b/src/browse/workflow/ArcanistBrowseWorkflow.php @@ -120,9 +120,7 @@ EOTEXT $this->loadHardpoints( $refs, - array( - ArcanistBrowseRef::HARDPOINT_URIS, - )); + ArcanistBrowseRef::HARDPOINT_URIS); $zero_hits = array(); $open_uris = array(); diff --git a/src/workflow/ArcanistDiffWorkflow.php b/src/workflow/ArcanistDiffWorkflow.php index 06e755b1..bd7310ac 100644 --- a/src/workflow/ArcanistDiffWorkflow.php +++ b/src/workflow/ArcanistDiffWorkflow.php @@ -3062,12 +3062,8 @@ EOTEXT ->setCommitRef($base_ref); $this->loadHardpoints( - array( - $state_ref, - ), - array( - ArcanistWorkingCopyStateRef::HARDPOINT_REVISIONREFS, - )); + $state_ref, + ArcanistWorkingCopyStateRef::HARDPOINT_REVISIONREFS); $revision_refs = $state_ref->getRevisionRefs(); $viewer_phid = $this->getUserPHID(); diff --git a/src/workflow/ArcanistFeatureBaseWorkflow.php b/src/workflow/ArcanistFeatureBaseWorkflow.php index fa00c628..94756c2a 100644 --- a/src/workflow/ArcanistFeatureBaseWorkflow.php +++ b/src/workflow/ArcanistFeatureBaseWorkflow.php @@ -79,10 +79,7 @@ EOHELP $this->loadHardpoints( ipull($states, 'state'), - array( - ArcanistWorkingCopyStateRef::HARDPOINT_REVISIONREFS, - )); - + ArcanistWorkingCopyStateRef::HARDPOINT_REVISIONREFS); $this->printBranches($states); diff --git a/src/workflow/ArcanistInspectWorkflow.php b/src/workflow/ArcanistInspectWorkflow.php index 7cd7fd81..6ebb9b22 100644 --- a/src/workflow/ArcanistInspectWorkflow.php +++ b/src/workflow/ArcanistInspectWorkflow.php @@ -98,9 +98,7 @@ EOTEXT if ($hardpoints) { $hardpoint_keys = mpull($hardpoints, 'getHardpointKey'); - $this->loadHardpoints( - $refs, - $hardpoint_keys); + $this->loadHardpoints($refs, $hardpoint_keys); } } } diff --git a/src/workflow/ArcanistWorkflow.php b/src/workflow/ArcanistWorkflow.php index 8e59052a..015b8170 100644 --- a/src/workflow/ArcanistWorkflow.php +++ b/src/workflow/ArcanistWorkflow.php @@ -2299,8 +2299,16 @@ abstract class ArcanistWorkflow extends Phobject { } final protected function loadHardpoints( - array $objects, - array $requests) { + $objects, + $requests) { + + if (!is_array($objects)) { + $objects = array($objects); + } + + if (!is_array($requests)) { + $requests = array($requests); + } $engine = $this->getHardpointEngine();