PHP 8.1 compatibility

This commit is contained in:
slawkens 2023-02-02 16:16:06 +01:00
parent 9de8145f82
commit 8c801dddec
16 changed files with 160 additions and 153 deletions

View File

@ -11,7 +11,7 @@
defined('MYAAC') or die('Direct access not allowed!'); defined('MYAAC') or die('Direct access not allowed!');
$configForumTablePrefix = config('forum_table_prefix'); $configForumTablePrefix = config('forum_table_prefix');
if(!empty(trim($configForumTablePrefix))) { if(null !== $configForumTablePrefix && !empty(trim($configForumTablePrefix))) {
if(!in_array($configForumTablePrefix, array('myaac_', 'z_'))) { if(!in_array($configForumTablePrefix, array('myaac_', 'z_'))) {
throw new RuntimeException('Invalid value for forum_table_prefix in config.php. Can be only: "myaac_" or "z_".'); throw new RuntimeException('Invalid value for forum_table_prefix in config.php. Can be only: "myaac_" or "z_".');
} }

View File

@ -1091,6 +1091,7 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
* @throws PDOException On PDO operation error. * @throws PDOException On PDO operation error.
* @return Iterator List of players. * @return Iterator List of players.
*/ */
#[\ReturnTypeWillChange]
public function getIterator() public function getIterator()
{ {
return $this->getPlayersList(); return $this->getPlayersList();
@ -1105,7 +1106,7 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
* @throws PDOException On PDO operation error. * @throws PDOException On PDO operation error.
* @return int Count of players. * @return int Count of players.
*/ */
public function count() public function count(): int
{ {
return $this->getPlayersList()->count(); return $this->getPlayersList()->count();
} }

View File

@ -190,6 +190,7 @@ abstract class OTS_Base_List implements IOTS_DAO, Iterator, Countable
* @version 0.1.3 * @version 0.1.3
* @return OTS_Base_DAO Current row. * @return OTS_Base_DAO Current row.
*/ */
#[\ReturnTypeWillChange]
public function current() public function current()
{ {
$id = current($this->rows); $id = current($this->rows);
@ -203,7 +204,7 @@ abstract class OTS_Base_List implements IOTS_DAO, Iterator, Countable
* *
* @throws PDOException On PDO operation error. * @throws PDOException On PDO operation error.
*/ */
public function rewind() public function rewind(): void
{ {
$this->rows = $this->db->query( $this->getSQL() )->fetchAll(); $this->rows = $this->db->query( $this->getSQL() )->fetchAll();
} }
@ -211,7 +212,7 @@ abstract class OTS_Base_List implements IOTS_DAO, Iterator, Countable
/** /**
* Moves to next row. * Moves to next row.
*/ */
public function next() public function next(): void
{ {
next($this->rows); next($this->rows);
} }
@ -221,6 +222,7 @@ abstract class OTS_Base_List implements IOTS_DAO, Iterator, Countable
* *
* @return mixed Array key. * @return mixed Array key.
*/ */
#[\ReturnTypeWillChange]
public function key() public function key()
{ {
return key($this->rows); return key($this->rows);
@ -231,7 +233,7 @@ abstract class OTS_Base_List implements IOTS_DAO, Iterator, Countable
* *
* @return bool Does next row exist. * @return bool Does next row exist.
*/ */
public function valid() public function valid(): bool
{ {
return key($this->rows) !== null; return key($this->rows) !== null;
} }
@ -243,7 +245,7 @@ abstract class OTS_Base_List implements IOTS_DAO, Iterator, Countable
* @return int Number of rows. * @return int Number of rows.
* @throws PDOException On PDO operation error. * @throws PDOException On PDO operation error.
*/ */
public function count() public function count(): int
{ {
return $this->db->query( $this->getSQL(true) )->fetchColumn(); return $this->db->query( $this->getSQL(true) )->fetchColumn();
} }

View File

@ -73,7 +73,7 @@ class OTS_Container extends OTS_Item implements IteratorAggregate
* *
* @return int Number of items. * @return int Number of items.
*/ */
public function count() public function count(): int
{ {
return count($items); return count($items);
} }

View File

@ -6,7 +6,7 @@ if (PHP_VERSION_ID >= 80000) {
/** /**
* @return PDOStatement * @return PDOStatement
*/ */
public function query(?string $query = null, ?int $fetchMode = null, mixed ...$fetchModeArgs) public function query(?string $query = null, ?int $fetchMode = null, mixed ...$fetchModeArgs): PDOStatement
{ {
return $this->doQuery($query, $fetchMode, ...$fetchModeArgs); return $this->doQuery($query, $fetchMode, ...$fetchModeArgs);
} }

View File

@ -538,6 +538,7 @@ class OTS_Group extends OTS_Row_DAO implements IteratorAggregate, Countable
* @throws PDOException On PDO operation error. * @throws PDOException On PDO operation error.
* @return Iterator List of players. * @return Iterator List of players.
*/ */
#[\ReturnTypeWillChange]
public function getIterator() public function getIterator()
{ {
return $this->getPlayersList(); return $this->getPlayersList();
@ -552,7 +553,7 @@ class OTS_Group extends OTS_Row_DAO implements IteratorAggregate, Countable
* @throws PDOException On PDO operation error. * @throws PDOException On PDO operation error.
* @return int Count of players. * @return int Count of players.
*/ */
public function count() public function count(): int
{ {
return $this->getPlayersList()->count(); return $this->getPlayersList()->count();
} }

View File

@ -196,6 +196,7 @@ class OTS_Groups_List implements IteratorAggregate, Countable
* @since 0.1.5 * @since 0.1.5
* @return AppendIterator Iterator for all groups. * @return AppendIterator Iterator for all groups.
*/ */
#[\ReturnTypeWillChange]
public function getIterator() public function getIterator()
{ {
$iterator = new AppendIterator(); $iterator = new AppendIterator();
@ -210,7 +211,7 @@ class OTS_Groups_List implements IteratorAggregate, Countable
* @since 0.1.5 * @since 0.1.5
* @return int Amount of all groups. * @return int Amount of all groups.
*/ */
public function count() public function count(): int
{ {
return count($this->groups); return count($this->groups);
} }

View File

@ -709,6 +709,7 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
* @throws PDOException On PDO operation error. * @throws PDOException On PDO operation error.
* @return Iterator List of ranks. * @return Iterator List of ranks.
*/ */
#[\ReturnTypeWillChange]
public function getIterator() public function getIterator()
{ {
return $this->getGuildRanksList(); return $this->getGuildRanksList();
@ -723,7 +724,7 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
* @throws PDOException On PDO operation error. * @throws PDOException On PDO operation error.
* @return int Count of ranks. * @return int Count of ranks.
*/ */
public function count() public function count(): int
{ {
return $this->getGuildRanksList()->count(); return $this->getGuildRanksList()->count();
} }

View File

@ -396,6 +396,7 @@ class OTS_GuildRank extends OTS_Row_DAO implements IteratorAggregate, Countable
* @throws PDOException On PDO operation error. * @throws PDOException On PDO operation error.
* @return Iterator List of players. * @return Iterator List of players.
*/ */
#[\ReturnTypeWillChange]
public function getIterator() public function getIterator()
{ {
return $this->getPlayersList(); return $this->getPlayersList();
@ -410,7 +411,7 @@ class OTS_GuildRank extends OTS_Row_DAO implements IteratorAggregate, Countable
* @throws PDOException On PDO operation error. * @throws PDOException On PDO operation error.
* @return int Count of players. * @return int Count of players.
*/ */
public function count() public function count(): int
{ {
return $this->getPlayersList()->count(); return $this->getPlayersList()->count();
} }

View File

@ -150,7 +150,7 @@ class OTS_HousesList implements IteratorAggregate, Countable, ArrayAccess
* *
* @return int Count of houses. * @return int Count of houses.
*/ */
public function count() public function count(): int
{ {
return count($this->houses); return count($this->houses);
} }

View File

@ -128,7 +128,7 @@ class OTS_Item implements Countable
* *
* @return int Count of item. * @return int Count of item.
*/ */
public function count() public function count(): int
{ {
return $this->count; return $this->count;
} }

View File

@ -500,7 +500,7 @@ class OTS_ItemsList extends OTS_FileLoader implements IteratorAggregate, Countab
* *
* @return int Count of types. * @return int Count of types.
*/ */
public function count() public function count(): int
{ {
return count($this->items); return count($this->items);
} }

View File

@ -163,7 +163,7 @@ class OTS_MonstersList implements Iterator, Countable, ArrayAccess
* *
* @return int Count of monsters. * @return int Count of monsters.
*/ */
public function count() public function count(): int
{ {
return count($this->monsters); return count($this->monsters);
} }

View File

@ -630,7 +630,7 @@ class OTS_OTBMFile extends OTS_FileLoader implements IteratorAggregate, Countabl
* @since 0.0.8 * @since 0.0.8
* @return int Count of towns. * @return int Count of towns.
*/ */
public function count() public function count(): int
{ {
return count($this->towns); return count($this->towns);
} }

View File

@ -324,7 +324,7 @@ class OTS_SpellsList implements IteratorAggregate, Countable
* @since 0.1.5 * @since 0.1.5
* @return int Amount of all spells. * @return int Amount of all spells.
*/ */
public function count() public function count(): int
{ {
return count($this->runes) + count($this->instants) + count($this->conjures); return count($this->runes) + count($this->instants) + count($this->conjures);
} }

View File

@ -142,7 +142,7 @@ class OTS_VocationsList implements IteratorAggregate, Countable, ArrayAccess
* *
* @return int Count of vocations. * @return int Count of vocations.
*/ */
public function count() public function count(): int
{ {
return count($this->vocations); return count($this->vocations);
} }