more php 8.x compatibility

This commit is contained in:
slawkens 2023-02-18 21:22:54 +01:00
parent 3280b3b9df
commit 2ac8ed7411
2 changed files with 10 additions and 4 deletions

View File

@ -174,6 +174,7 @@ class OTS_MonstersList implements Iterator, Countable, ArrayAccess
* @return OTS_Monster Monster. * @return OTS_Monster Monster.
* @throws DOMException On DOM operation error. * @throws DOMException On DOM operation error.
*/ */
#[\ReturnTypeWillChange]
public function current() public function current()
{ {
return $this->getMonster( key($this->monsters) ); return $this->getMonster( key($this->monsters) );
@ -187,7 +188,7 @@ class OTS_MonstersList implements Iterator, Countable, ArrayAccess
/** /**
* Moves to next iterator monster. * Moves to next iterator monster.
*/ */
public function next() public function next(): void
{ {
next($this->monsters); next($this->monsters);
} }
@ -197,6 +198,7 @@ class OTS_MonstersList implements Iterator, Countable, ArrayAccess
* *
* @return string Current position key. * @return string Current position key.
*/ */
#[\ReturnTypeWillChange]
public function key() public function key()
{ {
return key($this->monsters); return key($this->monsters);
@ -207,7 +209,7 @@ class OTS_MonstersList implements Iterator, Countable, ArrayAccess
* *
* @return bool If iterator has anything more. * @return bool If iterator has anything more.
*/ */
public function valid() public function valid(): bool
{ {
return key($this->monsters) !== null; return key($this->monsters) !== null;
} }
@ -215,7 +217,7 @@ class OTS_MonstersList implements Iterator, Countable, ArrayAccess
/** /**
* Resets iterator index. * Resets iterator index.
*/ */
public function rewind() public function rewind(): void
{ {
reset($this->monsters); reset($this->monsters);
} }
@ -226,6 +228,7 @@ class OTS_MonstersList implements Iterator, Countable, ArrayAccess
* @param string $offset Array key. * @param string $offset Array key.
* @return bool True if it's set. * @return bool True if it's set.
*/ */
#[\ReturnTypeWillChange]
public function offsetExists($offset) public function offsetExists($offset)
{ {
return isset($this->monsters[$offset]); return isset($this->monsters[$offset]);
@ -239,6 +242,7 @@ class OTS_MonstersList implements Iterator, Countable, ArrayAccess
* @return OTS_Monster Monster instance. * @return OTS_Monster Monster instance.
* @throws DOMException On DOM operation error. * @throws DOMException On DOM operation error.
*/ */
#[\ReturnTypeWillChange]
public function offsetGet($offset) public function offsetGet($offset)
{ {
return $this->getMonster($offset); return $this->getMonster($offset);
@ -251,6 +255,7 @@ class OTS_MonstersList implements Iterator, Countable, ArrayAccess
* @param mixed $value Field value. * @param mixed $value Field value.
* @throws E_OTS_ReadOnly Always - this class is read-only. * @throws E_OTS_ReadOnly Always - this class is read-only.
*/ */
#[\ReturnTypeWillChange]
public function offsetSet($offset, $value) public function offsetSet($offset, $value)
{ {
throw new E_OTS_ReadOnly(); throw new E_OTS_ReadOnly();
@ -262,6 +267,7 @@ class OTS_MonstersList implements Iterator, Countable, ArrayAccess
* @param string|int $offset Array key. * @param string|int $offset Array key.
* @throws E_OTS_ReadOnly Always - this class is read-only. * @throws E_OTS_ReadOnly Always - this class is read-only.
*/ */
#[\ReturnTypeWillChange]
public function offsetUnset($offset) public function offsetUnset($offset)
{ {
throw new E_OTS_ReadOnly(); throw new E_OTS_ReadOnly();

View File

@ -308,7 +308,7 @@ class OTS_SpellsList implements IteratorAggregate, Countable
* @since 0.1.5 * @since 0.1.5
* @return AppendIterator Iterator for all spells. * @return AppendIterator Iterator for all spells.
*/ */
public function getIterator() public function getIterator(): Traversable
{ {
$iterator = new AppendIterator(); $iterator = new AppendIterator();
$iterator->append( new ArrayIterator($this->runes) ); $iterator->append( new ArrayIterator($this->runes) );