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.php37
1 files changed, 17 insertions, 20 deletions
diff --git a/vendor/ramsey/collection/src/AbstractArray.php b/vendor/ramsey/collection/src/AbstractArray.php
index f8b4be2ce..2c6e0dedd 100644
--- a/vendor/ramsey/collection/src/AbstractArray.php
+++ b/vendor/ramsey/collection/src/AbstractArray.php
@@ -23,20 +23,23 @@ use function unserialize;
/**
* This class provides a basic implementation of `ArrayInterface`, to minimize
* the effort required to implement this interface.
+ *
+ * @template T
+ * @template-implements ArrayInterface<T>
*/
abstract class AbstractArray implements ArrayInterface
{
/**
* The items of this array.
*
- * @var mixed[]
+ * @var array<array-key, T>
*/
protected $data = [];
/**
* Constructs a new array object.
*
- * @param mixed[] $data The initial items to add to this array.
+ * @param array<array-key, T> $data The initial items to add to this array.
*/
public function __construct(array $data = [])
{
@@ -51,8 +54,6 @@ abstract class AbstractArray implements ArrayInterface
* Returns an iterator for this array.
*
* @link http://php.net/manual/en/iteratoraggregate.getiterator.php IteratorAggregate::getIterator()
- *
- * @return ArrayIterator<mixed, mixed>
*/
public function getIterator(): Traversable
{
@@ -64,7 +65,7 @@ abstract class AbstractArray implements ArrayInterface
*
* @link http://php.net/manual/en/arrayaccess.offsetexists.php ArrayAccess::offsetExists()
*
- * @param mixed $offset The offset to check.
+ * @param array-key $offset The offset to check.
*/
public function offsetExists($offset): bool
{
@@ -76,9 +77,9 @@ abstract class AbstractArray implements ArrayInterface
*
* @link http://php.net/manual/en/arrayaccess.offsetget.php ArrayAccess::offsetGet()
*
- * @param mixed $offset The offset for which a value should be returned.
+ * @param array-key $offset The offset for which a value should be returned.
*
- * @return mixed|null the value stored at the offset, or null if the offset
+ * @return T|null the value stored at the offset, or null if the offset
* does not exist.
*/
public function offsetGet($offset)
@@ -91,10 +92,11 @@ abstract class AbstractArray implements ArrayInterface
*
* @link http://php.net/manual/en/arrayaccess.offsetset.php ArrayAccess::offsetSet()
*
- * @param mixed|null $offset The offset to set. If `null`, the value may be
+ * @param array-key|null $offset The offset to set. If `null`, the value may be
* set at a numerically-indexed offset.
- * @param mixed $value The value to set at the given offset.
+ * @param T $value The value to set at the given offset.
*/
+ // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
public function offsetSet($offset, $value): void
{
if ($offset === null) {
@@ -109,7 +111,7 @@ abstract class AbstractArray implements ArrayInterface
*
* @link http://php.net/manual/en/arrayaccess.offsetunset.php ArrayAccess::offsetUnset()
*
- * @param mixed $offset The offset to remove from the array.
+ * @param array-key $offset The offset to remove from the array.
*/
public function offsetUnset($offset): void
{
@@ -139,7 +141,10 @@ abstract class AbstractArray implements ArrayInterface
*/
public function unserialize($serialized): void
{
- $this->data = unserialize($serialized, ['allowed_classes' => false]);
+ /** @var array<array-key, T> $data */
+ $data = unserialize($serialized, ['allowed_classes' => false]);
+
+ $this->data = $data;
}
/**
@@ -152,27 +157,19 @@ abstract class AbstractArray implements ArrayInterface
return count($this->data);
}
- /**
- * Removes all items from this array.
- */
public function clear(): void
{
$this->data = [];
}
/**
- * Returns a native PHP array representation of this array object.
- *
- * @return mixed[]
+ * @inheritDoc
*/
public function toArray(): array
{
return $this->data;
}
- /**
- * Returns `true` if this array is empty.
- */
public function isEmpty(): bool
{
return count($this->data) === 0;