From 212565b01e1fa596a3793be3610ac4303ed78bd8 Mon Sep 17 00:00:00 2001 From: Molkobain Date: Mon, 16 May 2022 08:15:29 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B04517=20-=20PHP=208.1:=20Fix=20return=20t?= =?UTF-8?q?ypes=20to=20match=20parent=20Countable=20class?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * DBObjectSet::Seek() now returns void instead of the current object, this was mandatory in to order to match parent class. Returned object is never used in iTop core and extensions so we consider it ok and will document it in the migration notes. --- core/dbobjectiterator.php | 4 ++-- core/dbobjectset.class.php | 8 +++----- core/ormlinkset.class.inc.php | 4 ++-- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/core/dbobjectiterator.php b/core/dbobjectiterator.php index 85e1e5208..8f9311266 100644 --- a/core/dbobjectiterator.php +++ b/core/dbobjectiterator.php @@ -38,7 +38,7 @@ interface iDBObjectSetIterator extends Countable * * @return int */ - public function Count(); + public function Count(): int; /** * Reset the cursor to the first item in the collection. Equivalent to Seek(0) @@ -52,7 +52,7 @@ interface iDBObjectSetIterator extends Countable * * @param int $iRow */ - public function Seek($iPosition); + public function Seek($iPosition): void; /** * Fetch the object at the current position in the collection and move the cursor to the next position. diff --git a/core/dbobjectset.class.php b/core/dbobjectset.class.php index 57c2da786..fb8ebb43b 100644 --- a/core/dbobjectset.class.php +++ b/core/dbobjectset.class.php @@ -842,7 +842,7 @@ class DBObjectSet implements iDBObjectSetIterator * @throws \MySQLException * @throws \MySQLHasGoneAwayException */ - public function Count() + public function Count(): int { if (is_null($this->m_iNumTotalDBRows)) { @@ -1077,14 +1077,13 @@ class DBObjectSet implements iDBObjectSetIterator * * @param int $iRow * - * @return int|mixed - * * @throws \CoreException * @throws \MissingQueryArgument * @throws \MySQLException * @throws \MySQLHasGoneAwayException + * @since 3.1.0 N°4517 Now returns void for return type to match parent class and be compatible with PHP 8.1 */ - public function Seek($iRow) + public function Seek($iRow): void { if (!$this->m_bLoaded) $this->Load(); @@ -1093,7 +1092,6 @@ class DBObjectSet implements iDBObjectSetIterator { $this->m_oSQLResult->data_seek($this->m_iCurrRow); } - return $this->m_iCurrRow; } /** diff --git a/core/ormlinkset.class.inc.php b/core/ormlinkset.class.inc.php index caa5be16c..f39863755 100644 --- a/core/ormlinkset.class.inc.php +++ b/core/ormlinkset.class.inc.php @@ -311,7 +311,7 @@ class ormLinkSet implements iDBObjectSetIterator, Iterator, SeekableIterator * @throws \CoreUnexpectedValue * @throws \MySQLException */ - public function Count() + public function Count(): int { $this->LoadOriginalIds(); $iRet = count($this->aPreserved) + count($this->aAdded) + count($this->aModified); @@ -326,7 +326,7 @@ class ormLinkSet implements iDBObjectSetIterator, Iterator, SeekableIterator * @throws Exception * @internal param int $iRow */ - public function Seek($iPosition) + public function Seek($iPosition): void { $this->LoadOriginalIds();