Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PHP 8.1 deprecations #9

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions src/Schema/ErrorCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,28 @@ 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);
}

/**
* {@inheritdoc}
*/
public function count()
public function count(): int
{
return \count($this->items);
}
Expand All @@ -72,7 +82,7 @@ public function unserialize($serialized)
/**
* {@inheritdoc}
*/
public function offsetExists($offset)
public function offsetExists($offset): bool
{
return isset($this->items[$offset]);
}
Expand All @@ -82,6 +92,7 @@ public function offsetExists($offset)
*
* @return ErrorInterface
*/
#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
return $this->items[$offset];
Expand All @@ -90,15 +101,17 @@ 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;
}

/**
* {@inheritdoc}
*/
public function offsetUnset($offset)
#[\ReturnTypeWillChange]
public function offsetUnset($offset): void
{
unset($this->items[$offset]);
}
Expand Down
12 changes: 5 additions & 7 deletions tests/Data/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -47,23 +45,23 @@ 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;
}

/**
* {@inheritdoc}
*/
public function offsetUnset($offset)
public function offsetUnset($offset): void
{
unset($this->data[$offset]);
}

/**
* {@inheritdoc}
*/
public function getIterator()
public function getIterator(): \Traversable
{
return new ArrayIterator($this->data);
}
Expand Down
9 changes: 5 additions & 4 deletions tests/Data/Models/AuthorCModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,23 @@ public function __construct(int $identity, string $firstName, string $lastName,
/**
* {@inheritdoc}
*/
public function getIterator()
public function getIterator(): \Traversable
{
return new ArrayIterator($this->properties);
}

/**
* {@inheritdoc}
*/
public function offsetExists($offset)
public function offsetExists($offset): bool
{
return \array_key_exists($offset, $this->properties);
}

/**
* {@inheritdoc}
*/
#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
return $this->properties[$offset];
Expand All @@ -74,15 +75,15 @@ public function offsetGet($offset)
/**
* {@inheritdoc}
*/
public function offsetSet($offset, $value)
public function offsetSet($offset, $value): void
{
$this->properties[$offset] = $value;
}

/**
* {@inheritdoc}
*/
public function offsetUnset($offset)
public function offsetUnset($offset): void
{
unset($this->properties[$offset]);
}
Expand Down