aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/ramsey/collection/src/AbstractArray.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/ramsey/collection/src/AbstractArray.php')
-rw-r--r--vendor/ramsey/collection/src/AbstractArray.php60
1 files changed, 11 insertions, 49 deletions
diff --git a/vendor/ramsey/collection/src/AbstractArray.php b/vendor/ramsey/collection/src/AbstractArray.php
index d72dbe697..5ce622aa7 100644
--- a/vendor/ramsey/collection/src/AbstractArray.php
+++ b/vendor/ramsey/collection/src/AbstractArray.php
@@ -17,8 +17,7 @@ namespace Ramsey\Collection;
use ArrayIterator;
use Traversable;
-use function serialize;
-use function unserialize;
+use function count;
/**
* This class provides a basic implementation of `ArrayInterface`, to minimize
@@ -34,7 +33,7 @@ abstract class AbstractArray implements ArrayInterface
*
* @var array<array-key, T>
*/
- protected $data = [];
+ protected array $data = [];
/**
* Constructs a new array object.
@@ -69,7 +68,7 @@ abstract class AbstractArray implements ArrayInterface
*
* @param array-key $offset The offset to check.
*/
- public function offsetExists($offset): bool
+ public function offsetExists(mixed $offset): bool
{
return isset($this->data[$offset]);
}
@@ -81,15 +80,12 @@ abstract class AbstractArray implements ArrayInterface
*
* @param array-key $offset The offset for which a value should be returned.
*
- * @return T|null the value stored at the offset, or null if the offset
+ * @return T the value stored at the offset, or null if the offset
* does not exist.
- *
- * @psalm-suppress InvalidAttribute
*/
- #[\ReturnTypeWillChange] // phpcs:ignore
- public function offsetGet($offset)
+ public function offsetGet(mixed $offset): mixed
{
- return $this->data[$offset] ?? null;
+ return $this->data[$offset];
}
/**
@@ -97,12 +93,11 @@ abstract class AbstractArray implements ArrayInterface
*
* @link http://php.net/manual/en/arrayaccess.offsetset.php ArrayAccess::offsetSet()
*
- * @param array-key|null $offset The offset to set. If `null`, the value may be
- * set at a numerically-indexed offset.
+ * @param array-key | null $offset The offset to set. If `null`, the value
+ * may be set at a numerically-indexed offset.
* @param T $value The value to set at the given offset.
*/
- // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
- public function offsetSet($offset, $value): void
+ public function offsetSet(mixed $offset, mixed $value): void
{
if ($offset === null) {
$this->data[] = $value;
@@ -118,26 +113,12 @@ abstract class AbstractArray implements ArrayInterface
*
* @param array-key $offset The offset to remove from the array.
*/
- public function offsetUnset($offset): void
+ public function offsetUnset(mixed $offset): void
{
unset($this->data[$offset]);
}
/**
- * Returns a serialized string representation of this array object.
- *
- * @deprecated The Serializable interface will go away in PHP 9.
- *
- * @link http://php.net/manual/en/serializable.serialize.php Serializable::serialize()
- *
- * @return string a PHP serialized string.
- */
- public function serialize(): string
- {
- return serialize($this->data);
- }
-
- /**
* Returns data suitable for PHP serialization.
*
* @link https://www.php.net/manual/en/language.oop5.magic.php#language.oop5.magic.serialize
@@ -151,25 +132,6 @@ abstract class AbstractArray implements ArrayInterface
}
/**
- * Converts a serialized string representation into an instance object.
- *
- * @deprecated The Serializable interface will go away in PHP 9.
- *
- * @link http://php.net/manual/en/serializable.unserialize.php Serializable::unserialize()
- *
- * @param string $serialized A PHP serialized string to unserialize.
- *
- * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
- */
- public function unserialize($serialized): void
- {
- /** @var array<array-key, T> $data */
- $data = unserialize($serialized, ['allowed_classes' => false]);
-
- $this->data = $data;
- }
-
- /**
* Adds unserialized data to the object.
*
* @param array<array-key, T> $data
@@ -204,6 +166,6 @@ abstract class AbstractArray implements ArrayInterface
public function isEmpty(): bool
{
- return count($this->data) === 0;
+ return $this->data === [];
}
}