From 0ad7fdca5320f88886aa096091d0dcc0d6e83c2a Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Fri, 20 May 2022 14:01:58 +0200 Subject: [PATCH] Fix some signature inconsistencies --- library/Icinga/Application/Modules/DashletManager.php | 2 +- library/Icinga/Common/Database.php | 1 - library/Icinga/Web/Dashboard/Common/BaseDashboard.php | 4 ++-- library/Icinga/Web/Dashboard/Common/DashboardEntry.php | 8 ++++---- library/Icinga/Web/Dashboard/Common/DashboardManager.php | 6 +++--- library/Icinga/Web/Dashboard/DashboardHome.php | 6 +++--- library/Icinga/Web/Dashboard/Pane.php | 9 ++++----- 7 files changed, 17 insertions(+), 19 deletions(-) diff --git a/library/Icinga/Application/Modules/DashletManager.php b/library/Icinga/Application/Modules/DashletManager.php index 87e6d52bc..8f6e7740a 100644 --- a/library/Icinga/Application/Modules/DashletManager.php +++ b/library/Icinga/Application/Modules/DashletManager.php @@ -185,7 +185,7 @@ class DashletManager * * @param Dashlet $dashlet * - * @return void + * @return bool */ public static function ensureItIsNotOrphaned(Dashlet $dashlet): bool { diff --git a/library/Icinga/Common/Database.php b/library/Icinga/Common/Database.php index e39acfa0f..e600021ca 100644 --- a/library/Icinga/Common/Database.php +++ b/library/Icinga/Common/Database.php @@ -64,7 +64,6 @@ trait Database $insert->values(array_combine($insert->getColumns(), $values)); }); - } return $conn; diff --git a/library/Icinga/Web/Dashboard/Common/BaseDashboard.php b/library/Icinga/Web/Dashboard/Common/BaseDashboard.php index 7ba78fcf2..52649b533 100644 --- a/library/Icinga/Web/Dashboard/Common/BaseDashboard.php +++ b/library/Icinga/Web/Dashboard/Common/BaseDashboard.php @@ -286,11 +286,11 @@ abstract class BaseDashboard implements DashboardEntry { } - public function manageEntry($entry, BaseDashboard $origin = null, bool $manageRecursive = false) + public function manageEntry($entryOrEntries, BaseDashboard $origin = null, bool $manageRecursive = false) { } - public function loadDashboardEntries(string $name = '') + public function loadDashboardEntries(string $name = null) { } diff --git a/library/Icinga/Web/Dashboard/Common/DashboardEntry.php b/library/Icinga/Web/Dashboard/Common/DashboardEntry.php index 9b59dfe4e..e7d766abd 100644 --- a/library/Icinga/Web/Dashboard/Common/DashboardEntry.php +++ b/library/Icinga/Web/Dashboard/Common/DashboardEntry.php @@ -105,14 +105,14 @@ interface DashboardEntry * move pane(s)|dashlet(s) from another to this widget you have to also provide the origin from which the * given entry(ies) originated * - * @param BaseDashboard|BaseDashboard[] $entry The actual dashboard entry to be managed + * @param BaseDashboard|BaseDashboard[] $entryOrEntries The actual dashboard entry to be managed * @param ?BaseDashboard $origin The original widget from which the given entry originates * @param bool $manageRecursive Whether the given entry should be managed recursively e.g if the given entry - * is a Pane type, all its dashlets can be managed recursively + * is a {@see Pane} type, all its dashlets can be managed recursively * * @return $this */ - public function manageEntry($entry, BaseDashboard $origin = null, bool $manageRecursive = false); + public function manageEntry($entryOrEntries, BaseDashboard $origin = null, bool $manageRecursive = false); /** * Load all the assigned entries to this widget @@ -121,7 +121,7 @@ interface DashboardEntry * * @return $this */ - public function loadDashboardEntries(string $name = ''); + public function loadDashboardEntries(string $name = null); /** * Reset the current position of the internal dashboard entries pointer diff --git a/library/Icinga/Web/Dashboard/Common/DashboardManager.php b/library/Icinga/Web/Dashboard/Common/DashboardManager.php index b8584d845..d30d650ae 100644 --- a/library/Icinga/Web/Dashboard/Common/DashboardManager.php +++ b/library/Icinga/Web/Dashboard/Common/DashboardManager.php @@ -72,7 +72,7 @@ trait DashboardManager return sha1($name, true); } - public function loadDashboardEntries(string $name = '') + public function loadDashboardEntries(string $name = null) { $home = $this->getEntry($name); $home->loadDashboardEntries(); @@ -137,10 +137,10 @@ trait DashboardManager return $this; } - public function manageEntry($entry, BaseDashboard $origin = null, $manageRecursive = false) + public function manageEntry($entryOrEntries, BaseDashboard $origin = null, $manageRecursive = false) { $conn = DBUtils::getConn(); - $homes = is_array($entry) ? $entry : [$entry]; + $homes = is_array($entryOrEntries) ? $entryOrEntries : [$entryOrEntries]; /** @var DashboardHome $home */ foreach ($homes as $home) { diff --git a/library/Icinga/Web/Dashboard/DashboardHome.php b/library/Icinga/Web/Dashboard/DashboardHome.php index 66cf86f9f..c3cfb23f1 100644 --- a/library/Icinga/Web/Dashboard/DashboardHome.php +++ b/library/Icinga/Web/Dashboard/DashboardHome.php @@ -136,7 +136,7 @@ class DashboardHome extends BaseDashboard implements Sortable return $this; } - public function loadDashboardEntries(string $name = '') + public function loadDashboardEntries(string $name = null) { $this->setEntries([]); $panes = \Icinga\Model\Pane::on(DBUtils::getConn())->utilize(self::TABLE); @@ -172,12 +172,12 @@ class DashboardHome extends BaseDashboard implements Sortable return $this; } - public function manageEntry($entry, BaseDashboard $origin = null, bool $manageRecursive = false) + public function manageEntry($entryOrEntries, BaseDashboard $origin = null, bool $manageRecursive = false) { $user = Dashboard::getUser(); $conn = DBUtils::getConn(); - $panes = is_array($entry) ? $entry : [$entry]; + $panes = is_array($entryOrEntries) ? $entryOrEntries : [$entryOrEntries]; // Highest priority is 0, so count($entries) are all always lowest prio + 1 $order = count($this->getEntries()); diff --git a/library/Icinga/Web/Dashboard/Pane.php b/library/Icinga/Web/Dashboard/Pane.php index 4d5c924bf..d7d7d0b86 100644 --- a/library/Icinga/Web/Dashboard/Pane.php +++ b/library/Icinga/Web/Dashboard/Pane.php @@ -89,7 +89,7 @@ class Pane extends BaseDashboard implements Sortable return $this; } - public function loadDashboardEntries(string $name = '') + public function loadDashboardEntries(string $name = null) { $dashlets = Model\Dashlet::on(DBUtils::getConn()) ->utilize(self::TABLE) @@ -117,8 +117,7 @@ class Pane extends BaseDashboard implements Sortable $this->addEntry($newDashlet); - if ( - Modules\DashletManager::isOrphaned($newDashlet) + if (Modules\DashletManager::isOrphaned($newDashlet) || ( $newDashlet->isModuleDashlet() && $dashlet->system_module_dashlet_id === null @@ -149,7 +148,7 @@ class Pane extends BaseDashboard implements Sortable return $this; } - public function manageEntry($entry, BaseDashboard $origin = null, bool $manageRecursive = false) + public function manageEntry($entryOrEntries, BaseDashboard $origin = null, bool $manageRecursive = false) { if ($origin && ! $origin instanceof Pane) { throw new \InvalidArgumentException(sprintf( @@ -169,7 +168,7 @@ class Pane extends BaseDashboard implements Sortable $user = Dashboard::getUser()->getUsername(); $conn = DBUtils::getConn(); - $dashlets = is_array($entry) ? $entry : [$entry]; + $dashlets = is_array($entryOrEntries) ? $entryOrEntries : [$entryOrEntries]; // Highest priority is 0, so count($entries) are always lowest prio + 1 $order = count($this->getEntries()); foreach ($dashlets as $dashlet) {