|
@@ -183,8 +183,8 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria
|
|
/**
|
|
/**
|
|
* Retrieve item from Collection.
|
|
* Retrieve item from Collection.
|
|
*
|
|
*
|
|
- * @param string $key
|
|
|
|
- * @param mixed $default
|
|
|
|
|
|
+ * @param string|null $key
|
|
|
|
+ * @param mixed $default
|
|
*
|
|
*
|
|
* @return mixed
|
|
* @return mixed
|
|
*/
|
|
*/
|
|
@@ -226,6 +226,7 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria
|
|
* @return mixed data which can be serialized by <b>json_encode</b>,
|
|
* @return mixed data which can be serialized by <b>json_encode</b>,
|
|
* which is a value of any type other than a resource
|
|
* which is a value of any type other than a resource
|
|
*/
|
|
*/
|
|
|
|
+ #[\ReturnTypeWillChange]
|
|
public function jsonSerialize()
|
|
public function jsonSerialize()
|
|
{
|
|
{
|
|
return $this->items;
|
|
return $this->items;
|
|
@@ -253,7 +254,7 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria
|
|
* @return ArrayIterator An instance of an object implementing <b>Iterator</b> or
|
|
* @return ArrayIterator An instance of an object implementing <b>Iterator</b> or
|
|
* <b>ArrayIterator</b>
|
|
* <b>ArrayIterator</b>
|
|
*/
|
|
*/
|
|
- public function getIterator()
|
|
|
|
|
|
+ public function getIterator(): \Traversable
|
|
{
|
|
{
|
|
return new ArrayIterator($this->items);
|
|
return new ArrayIterator($this->items);
|
|
}
|
|
}
|
|
@@ -269,7 +270,7 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria
|
|
* <p>
|
|
* <p>
|
|
* The return value is cast to an integer
|
|
* The return value is cast to an integer
|
|
*/
|
|
*/
|
|
- public function count()
|
|
|
|
|
|
+ public function count(): int
|
|
{
|
|
{
|
|
return count($this->items);
|
|
return count($this->items);
|
|
}
|
|
}
|
|
@@ -280,15 +281,15 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria
|
|
*
|
|
*
|
|
* @see http://php.net/manual/en/serializable.unserialize.php
|
|
* @see http://php.net/manual/en/serializable.unserialize.php
|
|
*
|
|
*
|
|
- * @param string $serialized <p>
|
|
|
|
|
|
+ * @param string $data <p>
|
|
* The string representation of the object.
|
|
* The string representation of the object.
|
|
* </p>
|
|
* </p>
|
|
*
|
|
*
|
|
* @return mixed|void
|
|
* @return mixed|void
|
|
*/
|
|
*/
|
|
- public function unserialize($serialized)
|
|
|
|
|
|
+ public function unserialize($data)
|
|
{
|
|
{
|
|
- return $this->items = unserialize($serialized);
|
|
|
|
|
|
+ return $this->items = unserialize($data);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -304,7 +305,7 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria
|
|
* @return bool true on success or false on failure.
|
|
* @return bool true on success or false on failure.
|
|
* The return value will be casted to boolean if non-boolean was returned
|
|
* The return value will be casted to boolean if non-boolean was returned
|
|
*/
|
|
*/
|
|
- public function offsetExists($offset)
|
|
|
|
|
|
+ public function offsetExists($offset): bool
|
|
{
|
|
{
|
|
return $this->has($offset);
|
|
return $this->has($offset);
|
|
}
|
|
}
|
|
@@ -319,7 +320,7 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria
|
|
* The offset to unset.
|
|
* The offset to unset.
|
|
* </p>
|
|
* </p>
|
|
*/
|
|
*/
|
|
- public function offsetUnset($offset)
|
|
|
|
|
|
+ public function offsetUnset($offset): void
|
|
{
|
|
{
|
|
if ($this->offsetExists($offset)) {
|
|
if ($this->offsetExists($offset)) {
|
|
$this->forget($offset);
|
|
$this->forget($offset);
|
|
@@ -338,6 +339,7 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria
|
|
*
|
|
*
|
|
* @return mixed Can return all value types
|
|
* @return mixed Can return all value types
|
|
*/
|
|
*/
|
|
|
|
+ #[\ReturnTypeWillChange]
|
|
public function offsetGet($offset)
|
|
public function offsetGet($offset)
|
|
{
|
|
{
|
|
return $this->offsetExists($offset) ? $this->get($offset) : null;
|
|
return $this->offsetExists($offset) ? $this->get($offset) : null;
|
|
@@ -356,8 +358,29 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria
|
|
* The value to set.
|
|
* The value to set.
|
|
* </p>
|
|
* </p>
|
|
*/
|
|
*/
|
|
|
|
+ #[\ReturnTypeWillChange]
|
|
public function offsetSet($offset, $value)
|
|
public function offsetSet($offset, $value)
|
|
{
|
|
{
|
|
$this->set($offset, $value);
|
|
$this->set($offset, $value);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * (PHP 8.1+) Magic method for serialization.
|
|
|
|
+ *
|
|
|
|
+ * @return array
|
|
|
|
+ */
|
|
|
|
+ public function __serialize(): array
|
|
|
|
+ {
|
|
|
|
+ return $this->items;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * (PHP 8.1+) Magic method for unserialization.
|
|
|
|
+ *
|
|
|
|
+ * @param array $data
|
|
|
|
+ */
|
|
|
|
+ public function __unserialize(array $data): void
|
|
|
|
+ {
|
|
|
|
+ $this->items = $data;
|
|
|
|
+ }
|
|
}
|
|
}
|