diff --git a/src/Schema/ErrorCollection.php b/src/Schema/ErrorCollection.php index ce948ac..5057a28 100644 --- a/src/Schema/ErrorCollection.php +++ b/src/Schema/ErrorCollection.php @@ -37,10 +37,20 @@ class ErrorCollection implements IteratorAggregate, ArrayAccess, Serializable, C { private array $items = []; + public function __serialize(): array + { + return ['items' => $this->items]; + } + + public function __unserialize(array $data): void + { + $this->items = $data['items']; + } + /** * {@inheritdoc} */ - public function getIterator() + public function getIterator(): \Traversable { return new ArrayIterator($this->items); } @@ -48,7 +58,7 @@ public function getIterator() /** * {@inheritdoc} */ - public function count() + public function count(): int { return \count($this->items); } @@ -72,7 +82,7 @@ public function unserialize($serialized) /** * {@inheritdoc} */ - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->items[$offset]); } @@ -82,6 +92,7 @@ public function offsetExists($offset) * * @return ErrorInterface */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->items[$offset]; @@ -90,7 +101,8 @@ public function offsetGet($offset) /** * {@inheritdoc} */ - public function offsetSet($offset, $value) + #[\ReturnTypeWillChange] + public function offsetSet($offset, $value): void { null === $offset ? $this->add($value) : $this->items[$offset] = $value; } @@ -98,7 +110,8 @@ public function offsetSet($offset, $value) /** * {@inheritdoc} */ - public function offsetUnset($offset) + #[\ReturnTypeWillChange] + public function offsetUnset($offset): void { unset($this->items[$offset]); } diff --git a/tests/Data/Collection.php b/tests/Data/Collection.php index fe8d878..0642406 100644 --- a/tests/Data/Collection.php +++ b/tests/Data/Collection.php @@ -31,14 +31,12 @@ class Collection implements ArrayAccess, IteratorAggregate /** * {@inheritdoc} */ - public function offsetExists($offset) + public function offsetExists($offset): bool { return \array_key_exists($offset, $this->data); } - /** - * {@inheritdoc} - */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->data[$offset]; @@ -47,7 +45,7 @@ public function offsetGet($offset) /** * {@inheritdoc} */ - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { null === $offset ? $this->data[] = $value : $this->data[$offset] = $value; } @@ -55,7 +53,7 @@ public function offsetSet($offset, $value) /** * {@inheritdoc} */ - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->data[$offset]); } @@ -63,7 +61,7 @@ public function offsetUnset($offset) /** * {@inheritdoc} */ - public function getIterator() + public function getIterator(): \Traversable { return new ArrayIterator($this->data); } diff --git a/tests/Data/Models/AuthorCModel.php b/tests/Data/Models/AuthorCModel.php index b04917f..cecfd41 100644 --- a/tests/Data/Models/AuthorCModel.php +++ b/tests/Data/Models/AuthorCModel.php @@ -50,7 +50,7 @@ public function __construct(int $identity, string $firstName, string $lastName, /** * {@inheritdoc} */ - public function getIterator() + public function getIterator(): \Traversable { return new ArrayIterator($this->properties); } @@ -58,7 +58,7 @@ public function getIterator() /** * {@inheritdoc} */ - public function offsetExists($offset) + public function offsetExists($offset): bool { return \array_key_exists($offset, $this->properties); } @@ -66,6 +66,7 @@ public function offsetExists($offset) /** * {@inheritdoc} */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->properties[$offset]; @@ -74,7 +75,7 @@ public function offsetGet($offset) /** * {@inheritdoc} */ - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { $this->properties[$offset] = $value; } @@ -82,7 +83,7 @@ public function offsetSet($offset, $value) /** * {@inheritdoc} */ - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->properties[$offset]); }