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

View File

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