From 7295138f8d9499d64c9ea8a0b408f8b8218e7f33 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 22 Jun 2022 07:47:15 -0400 Subject: [PATCH 1/2] Remove type-hint inconsistent with expected return value in Database->getVariable --- src/Database/Database.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Database/Database.php b/src/Database/Database.php index 1c9e24adef..e5dec2d75e 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -1748,9 +1748,10 @@ class Database * Fetch a database variable * * @param string $name - * @return string content + * @return string|null content or null if inexistent + * @throws \Exception */ - public function getVariable(string $name): string + public function getVariable(string $name) { $result = $this->fetchFirst("SHOW GLOBAL VARIABLES WHERE `Variable_name` = ?", $name); return $result['Value'] ?? null; From e9f7bb477dd1e6e8daca8e6e8de663abeb0d94ae Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 22 Jun 2022 07:49:45 -0400 Subject: [PATCH 2/2] Add expected type-hint to BoundariesPager::renderFull - Address https://github.com/friendica/friendica/issues/11630#issuecomment-1162634199 --- src/Content/BoundariesPager.php | 2 +- src/Content/Pager.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Content/BoundariesPager.php b/src/Content/BoundariesPager.php index dbfa4ca73b..fe95040519 100644 --- a/src/Content/BoundariesPager.php +++ b/src/Content/BoundariesPager.php @@ -130,7 +130,7 @@ class BoundariesPager extends Pager return Renderer::replaceMacros($tpl, ['pager' => $data]); } - public function renderFull(int $itemCount) + public function renderFull(int $itemCount): string { throw new \BadMethodCallException(); } diff --git a/src/Content/Pager.php b/src/Content/Pager.php index 4e8a760a17..5109fd1de3 100644 --- a/src/Content/Pager.php +++ b/src/Content/Pager.php @@ -199,13 +199,13 @@ class Pager * * $html = $pager->renderFull(); * - * @param integer $itemCount The total number of items including those note displayed on the page + * @param int $itemCount The total number of items including those note displayed on the page * @return string HTML string of the pager * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ public function renderFull(int $itemCount): string { - $totalItemCount = max(0, intval($itemCount)); + $totalItemCount = max(0, $itemCount); $data = [];