From 98247b97afb7c7cd4c831deb30f8e487a59ac84b Mon Sep 17 00:00:00 2001 From: SharkyKZ Date: Tue, 28 Feb 2023 16:04:36 +0200 Subject: [PATCH] Correct return types (#39395) --- libraries/src/Application/ApplicationHelper.php | 4 +++- libraries/src/Application/CMSApplication.php | 4 +++- .../src/Application/CMSWebApplicationInterface.php | 2 +- libraries/src/Document/HtmlDocument.php | 4 ++-- libraries/src/Menu/AbstractMenu.php | 12 +++++++++--- libraries/src/Serializer/JoomlaSerializer.php | 4 +++- 6 files changed, 21 insertions(+), 9 deletions(-) diff --git a/libraries/src/Application/ApplicationHelper.php b/libraries/src/Application/ApplicationHelper.php index f7c016bb1ed41..edd697950ac34 100644 --- a/libraries/src/Application/ApplicationHelper.php +++ b/libraries/src/Application/ApplicationHelper.php @@ -113,7 +113,7 @@ public static function stringURLSafe($string, $language = '') * @param integer|string|null $id A client identifier * @param boolean $byName If true, find the client by its name * - * @return \stdClass|array|void Object describing the client, array containing all the clients or void if $id not known + * @return \stdClass|array|null Object describing the client, array containing all the clients or null if $id not known * * @since 1.5 */ @@ -171,6 +171,8 @@ public static function getClientInfo($id = null, $byName = false) } } } + + return null; } /** diff --git a/libraries/src/Application/CMSApplication.php b/libraries/src/Application/CMSApplication.php index d8d04f15cd02a..546d511ac8dfd 100644 --- a/libraries/src/Application/CMSApplication.php +++ b/libraries/src/Application/CMSApplication.php @@ -1099,7 +1099,7 @@ protected function route() * @param string $key The path of the state. * @param mixed $value The value of the variable. * - * @return mixed|void The previous state, if one existed. + * @return mixed The previous state, if one existed. Null otherwise. * * @since 3.2 */ @@ -1111,6 +1111,8 @@ public function setUserState($key, $value) if ($registry !== null) { return $registry->set($key, $value); } + + return null; } /** diff --git a/libraries/src/Application/CMSWebApplicationInterface.php b/libraries/src/Application/CMSWebApplicationInterface.php index 17c93f1eb7fa1..e6b8b00f5272a 100644 --- a/libraries/src/Application/CMSWebApplicationInterface.php +++ b/libraries/src/Application/CMSWebApplicationInterface.php @@ -92,7 +92,7 @@ public function getUserStateFromRequest($key, $request, $default = null, $type = * @param string $key The path of the state. * @param mixed $value The value of the variable. * - * @return mixed|void The previous state, if one existed. Void otherwise. + * @return mixed The previous state, if one existed. Null otherwise. * * @since 4.0.0 */ diff --git a/libraries/src/Document/HtmlDocument.php b/libraries/src/Document/HtmlDocument.php index e8e0927a84d68..69db48a8135ce 100644 --- a/libraries/src/Document/HtmlDocument.php +++ b/libraries/src/Document/HtmlDocument.php @@ -317,14 +317,14 @@ public function setHeadData($data) * * @param array $data The document head data in array form * - * @return HtmlDocument|void instance of $this to allow chaining or void for empty input data + * @return HtmlDocument instance of $this to allow chaining * * @since 1.7.0 */ public function mergeHeadData($data) { if (empty($data) || !\is_array($data)) { - return; + return $this; } $this->title = (isset($data['title']) && !empty($data['title']) && !stristr($this->title, $data['title'])) diff --git a/libraries/src/Menu/AbstractMenu.php b/libraries/src/Menu/AbstractMenu.php index 720c2f95b50d4..e123686c0c5aa 100644 --- a/libraries/src/Menu/AbstractMenu.php +++ b/libraries/src/Menu/AbstractMenu.php @@ -190,7 +190,7 @@ public function setDefault($id, $language = '*') * * @param string $language The language code, default value of * means all. * - * @return MenuItem|void The item object or null when not found for given language + * @return MenuItem|null The item object or null when not found for given language * * @since 1.5 */ @@ -206,6 +206,8 @@ public function getDefault($language = '*') if (\array_key_exists('*', $this->default)) { return $items[$this->default['*']]; } + + return null; } /** @@ -213,7 +215,7 @@ public function getDefault($language = '*') * * @param integer $id The item id * - * @return MenuItem|void The menu item representing the given ID if present or null otherwise + * @return MenuItem|null The menu item representing the given ID if present or null otherwise * * @since 1.5 */ @@ -224,12 +226,14 @@ public function setActive($id) return $this->getMenu()[$id]; } + + return null; } /** * Get menu item by id. * - * @return MenuItem|void The item object if an active menu item has been set or null + * @return MenuItem|null The item object if an active menu item has been set or null * * @since 1.5 */ @@ -238,6 +242,8 @@ public function getActive() if ($this->active) { return $this->getMenu()[$this->active]; } + + return null; } /** diff --git a/libraries/src/Serializer/JoomlaSerializer.php b/libraries/src/Serializer/JoomlaSerializer.php index 9f44d416d97b4..59dbcb48b0074 100644 --- a/libraries/src/Serializer/JoomlaSerializer.php +++ b/libraries/src/Serializer/JoomlaSerializer.php @@ -87,7 +87,7 @@ public function getAttributes($post, array $fields = null) * @param mixed $model The model of the entity being rendered * @param string $name The name of the relationship to return * - * @return \Tobscure\JsonApi\Relationship|void + * @return \Tobscure\JsonApi\Relationship|null * * @since 4.0.0 */ @@ -111,5 +111,7 @@ public function getRelationship($model, $name) if ($relationship instanceof Relationship) { return $relationship; } + + return null; } }