aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/ramsey/collection/src/AbstractArray.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2024-03-14 10:13:22 +0000
committerMario <mario@mariovavti.com>2024-03-14 10:13:22 +0000
commit55097c47c5534d4453f7494f8a1542f7beb4d588 (patch)
tree399f81bbd03fcb4bb713339d06512eee962ec8f6 /vendor/ramsey/collection/src/AbstractArray.php
parent97b82fc77b424d051b2a472ab2318fd768151bdd (diff)
downloadvolse-hubzilla-55097c47c5534d4453f7494f8a1542f7beb4d588.tar.gz
volse-hubzilla-55097c47c5534d4453f7494f8a1542f7beb4d588.tar.bz2
volse-hubzilla-55097c47c5534d4453f7494f8a1542f7beb4d588.zip
Revert "composer update and use the fixed streams php-jcs library until the floats issue will be fixed upstream. see here for reference https://codeberg.org/streams/streams/issues/151"
This reverts commit 6bf61dfa6b585db01b607a79bd64ec9c583a9c10.
Diffstat (limited to 'vendor/ramsey/collection/src/AbstractArray.php')
-rw-r--r--vendor/ramsey/collection/src/AbstractArray.php60
1 files changed, 49 insertions, 11 deletions
diff --git a/vendor/ramsey/collection/src/AbstractArray.php b/vendor/ramsey/collection/src/AbstractArray.php
index 5ce622aa7..d72dbe697 100644
--- a/vendor/ramsey/collection/src/AbstractArray.php
+++ b/vendor/ramsey/collection/src/AbstractArray.php
@@ -17,7 +17,8 @@ namespace Ramsey\Collection;
use ArrayIterator;
use Traversable;
-use function count;
+use function serialize;
+use function unserialize;
/**
* This class provides a basic implementation of `ArrayInterface`, to minimize
@@ -33,7 +34,7 @@ abstract class AbstractArray implements ArrayInterface
*
* @var array<array-key, T>
*/
- protected array $data = [];
+ protected $data = [];
/**
* Constructs a new array object.
@@ -68,7 +69,7 @@ abstract class AbstractArray implements ArrayInterface
*
* @param array-key $offset The offset to check.
*/
- public function offsetExists(mixed $offset): bool
+ public function offsetExists($offset): bool
{
return isset($this->data[$offset]);
}
@@ -80,12 +81,15 @@ abstract class AbstractArray implements ArrayInterface
*
* @param array-key $offset The offset for which a value should be returned.
*
- * @return T 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.
+ *
+ * @psalm-suppress InvalidAttribute
*/
- public function offsetGet(mixed $offset): mixed
+ #[\ReturnTypeWillChange] // phpcs:ignore
+ public function offsetGet($offset)
{
- return $this->data[$offset];
+ return $this->data[$offset] ?? null;
}
/**
@@ -93,11 +97,12 @@ 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.
*/
- public function offsetSet(mixed $offset, mixed $value): void
+ // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
+ public function offsetSet($offset, $value): void
{
if ($offset === null) {
$this->data[] = $value;
@@ -113,12 +118,26 @@ abstract class AbstractArray implements ArrayInterface
*
* @param array-key $offset The offset to remove from the array.
*/
- public function offsetUnset(mixed $offset): void
+ public function offsetUnset($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
@@ -132,6 +151,25 @@ 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
@@ -166,6 +204,6 @@ abstract class AbstractArray implements ArrayInterface
public function isEmpty(): bool
{
- return $this->data === [];
+ return count($this->data) === 0;
}
}