Skip to content

php 8.1 compatibility #61

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
36 changes: 16 additions & 20 deletions src/Common/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
use Countable;
use IteratorAggregate;

class Collection implements ArrayAccess, IteratorAggregate, Countable {

class Collection implements ArrayAccess, IteratorAggregate, Countable
{
/**
* The items contained in the collection.
*
Expand All @@ -19,7 +19,7 @@ class Collection implements ArrayAccess, IteratorAggregate, Countable {
/**
* Create a new collection.
*
* @param array $items
* @param array $items
*/
public function __construct(array $items = [])
{
Expand All @@ -29,17 +29,16 @@ public function __construct(array $items = [])
/**
* Get an iterator for the items.
*
* @return \ArrayIterator
*/
public function getIterator()
public function getIterator() : ArrayIterator
{
return new ArrayIterator($this->items);
}

/**
* Create a new collection instance if the value isn't one already.
*
* @param mixed $items
* @param mixed $items
*
* @return static
*/
Expand Down Expand Up @@ -84,32 +83,31 @@ function ($value) {
/**
* Count the number of items in the collection.
*
* @return int
*/
public function count()
public function count() : int
{
return count($this->items);
}

/**
* Determine if an item exists at an offset.
*
* @param mixed $key
* @param mixed $key
*
* @return bool
*/
public function offsetExists($key)
public function offsetExists($key) : bool
{
return array_key_exists($key, $this->items);
}

/**
* Get an item at a given offset.
*
* @param mixed $key
* @param mixed $key
*
* @return mixed
*/
#[\ReturnTypeWillChange]
public function offsetGet($key)
{
return $this->items[$key];
Expand All @@ -118,12 +116,11 @@ public function offsetGet($key)
/**
* Set the item at a given offset.
*
* @param mixed $key
* @param mixed $value
* @param mixed $key
* @param mixed $value
*
* @return void
*/
public function offsetSet($key, $value)
public function offsetSet($key, $value) : void
{
if (is_null($key)) {
$this->items[] = $value;
Expand All @@ -135,13 +132,12 @@ public function offsetSet($key, $value)
/**
* Unset the item at a given offset.
*
* @param string $key
* @param string $key
*
* @return void
*/
public function offsetUnset($key)
public function offsetUnset($key) : void
{
unset($this->items[$key]);
}

}
}