aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/ramsey/collection/src/Queue.php
diff options
context:
space:
mode:
authorHilmar R <u02@u29lx193>2021-02-28 21:06:16 +0100
committerHilmar R <u02@u29lx193>2021-03-01 18:48:11 +0100
commitc26dede97f626b52b7bf8962ed55d1dbda86abe8 (patch)
tree3c8c9bc97aa09f7ce9afe9bf467cf87bbf2c7d0b /vendor/ramsey/collection/src/Queue.php
parentea3390d626f85b7293a750958bfd1b5460958365 (diff)
downloadvolse-hubzilla-c26dede97f626b52b7bf8962ed55d1dbda86abe8.tar.gz
volse-hubzilla-c26dede97f626b52b7bf8962ed55d1dbda86abe8.tar.bz2
volse-hubzilla-c26dede97f626b52b7bf8962ed55d1dbda86abe8.zip
get dev
Diffstat (limited to 'vendor/ramsey/collection/src/Queue.php')
-rw-r--r--vendor/ramsey/collection/src/Queue.php95
1 files changed, 19 insertions, 76 deletions
diff --git a/vendor/ramsey/collection/src/Queue.php b/vendor/ramsey/collection/src/Queue.php
index 4f53ff5e6..4af2fdf76 100644
--- a/vendor/ramsey/collection/src/Queue.php
+++ b/vendor/ramsey/collection/src/Queue.php
@@ -22,6 +22,10 @@ use Ramsey\Collection\Tool\ValueToStringTrait;
/**
* This class provides a basic implementation of `QueueInterface`, to minimize
* the effort required to implement this interface.
+ *
+ * @template T
+ * @template-extends AbstractArray<T>
+ * @template-implements QueueInterface<T>
*/
class Queue extends AbstractArray implements QueueInterface
{
@@ -50,7 +54,7 @@ class Queue extends AbstractArray implements QueueInterface
* specified data.
*
* @param string $queueType The type (FQCN) associated with this queue.
- * @param mixed[] $data The initial items to store in the collection.
+ * @param array<array-key, T> $data The initial items to store in the collection.
*/
public function __construct(string $queueType, array $data = [])
{
@@ -59,19 +63,11 @@ class Queue extends AbstractArray implements QueueInterface
}
/**
- * Sets the given value to the given offset in the queue.
+ * {@inheritDoc}
*
* Since arbitrary offsets may not be manipulated in a queue, this method
* serves only to fulfill the `ArrayAccess` interface requirements. It is
* invoked by other operations when adding values to the queue.
- *
- * @link http://php.net/manual/en/arrayaccess.offsetset.php ArrayAccess::offsetSet()
- *
- * @param mixed|null $offset The offset is ignored and is treated as `null`.
- * @param mixed $value The value to set at the given offset.
- *
- * @throws InvalidArgumentException when the value does not match the
- * specified type for this queue.
*/
public function offsetSet($offset, $value): void
{
@@ -86,19 +82,7 @@ class Queue extends AbstractArray implements QueueInterface
}
/**
- * Ensures that this queue contains the specified element.
- *
- * This method differs from `offer()` only in that it throws an exception if
- * it cannot add the element to the queue.
- *
- * @see self::offer()
- *
- * @param mixed $element The element to add to this queue.
- *
- * @return bool `true` if this queue changed as a result of the call.
- *
- * @throws InvalidArgumentException when the element does not match the
- * specified type for this queue.
+ * @inheritDoc
*/
public function add($element): bool
{
@@ -108,39 +92,23 @@ class Queue extends AbstractArray implements QueueInterface
}
/**
- * Retrieves, but does not remove, the head of this queue.
- *
- * This method differs from `peek()` only in that it throws an exception if
- * this queue is empty.
- *
- * @see self::peek()
- *
- * @return mixed the head of this queue.
- *
- * @throws NoSuchElementException if this queue is empty.
+ * @inheritDoc
*/
public function element()
{
- if ($this->count() === 0) {
+ $element = $this->peek();
+
+ if ($element === null) {
throw new NoSuchElementException(
'Can\'t return element from Queue. Queue is empty.'
);
}
- return $this[$this->index];
+ return $element;
}
/**
- * Inserts the specified element into this queue.
- *
- * This method differs from `add()` only in that it does not throw an
- * exception if it cannot add the element to the queue.
- *
- * @see self::add()
- *
- * @param mixed $element The element to add to this queue.
- *
- * @return bool `true` if the element was added to this queue, else `false`.
+ * @inheritDoc
*/
public function offer($element): bool
{
@@ -152,12 +120,7 @@ class Queue extends AbstractArray implements QueueInterface
}
/**
- * Retrieves, but does not remove, the head of this queue, or returns `null`
- * if this queue is empty.
- *
- * @see self::element()
- *
- * @return mixed|null the head of this queue, or `null` if this queue is empty.
+ * @inheritDoc
*/
public function peek()
{
@@ -169,12 +132,7 @@ class Queue extends AbstractArray implements QueueInterface
}
/**
- * Retrieves and removes the head of this queue, or returns `null`
- * if this queue is empty.
- *
- * @see self::remove()
- *
- * @return mixed|null the head of this queue, or `null` if this queue is empty.
+ * @inheritDoc
*/
public function poll()
{
@@ -191,34 +149,19 @@ class Queue extends AbstractArray implements QueueInterface
}
/**
- * Retrieves and removes the head of this queue.
- *
- * This method differs from `poll()` only in that it throws an exception if
- * this queue is empty.
- *
- * @see self::poll()
- *
- * @return mixed the head of this queue.
- *
- * @throws NoSuchElementException if this queue is empty.
+ * @inheritDoc
*/
public function remove()
{
- if ($this->count() === 0) {
+ $head = $this->poll();
+
+ if ($head === null) {
throw new NoSuchElementException('Can\'t return element from Queue. Queue is empty.');
}
- $head = $this[$this->index];
-
- unset($this[$this->index]);
- $this->index++;
-
return $head;
}
- /**
- * Returns the type associated with this queue.
- */
public function getType(): string
{
return $this->queueType;