现在 SplFixedArray 不是 Interator,而是 IteratorAggregate,我如何更改以下代码以适用于 PHP 8
声明(strict_types=1);
命名空间 BitWasp\Bitcoin\Transaction\Mutator;
抽象类 AbstractCollectionMutator 实现 \Iterator、\ArrayAccess、\Countable { /** * @var \SplFixedArray */ 受保护的$集;
/**
* @return array
*/
public function all(): array
{
return $this->set->toArray();
}
/**
* @return bool
*/
public function isNull(): bool
{
return count($this->set) === 0;
}
/**
* @return int
*/
public function count(): int
{
return $this->set->count();
}
/**
*
*/
public function rewind()
{
$this->set->rewind();
}
/**
* @return mixed
*/
public function current()
{
return $this->set->current();
}
/**
* @return int
*/
public function key()
{
return $this->set->key();
}
/**
*
*/
public function next()
{
$this->set->next();
}
/**
* @return bool
*/
public function valid()
{
return $this->set->valid();
}
/**
* @param int $offset
* @return bool
*/
public function offsetExists($offset)
{
return $this->set->offsetExists($offset);
}
/**
* @param int $offset
*/
public function offsetUnset($offset)
{
if (!$this->offsetExists($offset)) {
throw new \InvalidArgumentException('Offset does not exist');
}
$this->set->offsetUnset($offset);
}
/**
* @param int $offset
* @return mixed
*/
public function offsetGet($offset)
{
if (!$this->set->offsetExists($offset)) {
throw new \OutOfRangeException('Nothing found at this offset');
}
return $this->set->offsetGet($offset);
}
/**
* @param int $offset
* @param mixed $value
*/
public function offsetSet($offset, $value)
{
$this->set->offsetSet($offset, $value);
}
}
我尝试将 Implements \Iterator 更改为 \InteratorAggregate 但它无法正常工作。