From d0b3437995bceaf4824a948d11e0b1b5c49b558c Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Mon, 13 Jun 2022 09:29:55 +0200 Subject: [PATCH] Dashlet: Add return type decleration where applicable & use parent method in `toArray()` --- library/Icinga/Web/Dashboard/Dashlet.php | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/library/Icinga/Web/Dashboard/Dashlet.php b/library/Icinga/Web/Dashboard/Dashlet.php index aae92a97a..9f11b8046 100644 --- a/library/Icinga/Web/Dashboard/Dashlet.php +++ b/library/Icinga/Web/Dashboard/Dashlet.php @@ -79,7 +79,7 @@ class Dashlet extends BaseDashboard * * @return ?Url */ - public function getUrl() + public function getUrl(): ?Url { if ($this->url !== null && ! $this->url instanceof Url) { if (! Icinga::app()->isCli()) { @@ -151,7 +151,7 @@ class Dashlet extends BaseDashboard * * @return ?Pane */ - public function getPane() + public function getPane(): ?Pane { return $this->pane; } @@ -161,7 +161,7 @@ class Dashlet extends BaseDashboard * * @return ?string */ - public function getModule() + public function getModule(): ?string { return $this->module; } @@ -250,15 +250,11 @@ class Dashlet extends BaseDashboard public function toArray(bool $stringify = true): array { + $arr = parent::toArray($stringify); $pane = $this->getPane(); - return [ - 'id' => $this->getUuid(), - 'pane' => ! $stringify ? $pane : ($pane ? $pane->getName() : null), - 'name' => $this->getName(), - 'url' => $this->getUrl()->getRelativeUrl(), - 'label' => $this->getTitle(), - 'priority' => $this->getPriority(), - 'description' => $this->getDescription() - ]; + $arr['pane'] = ! $stringify ? $pane : ($pane ? $pane->getName() : null); + $arr['url'] = $this->getUrl()->getRelativeUrl(); + + return $arr; } }