1111use OutOfRangeException ;
1212
1313/**
14- * An array-like collection of items
15- *
1614 * @api
1715 *
1816 * @template TKey of array-key
@@ -60,6 +58,15 @@ interface CollectionInterface extends
6058 */
6159 public function __construct ($ items = []);
6260
61+ /**
62+ * Check if the collection is empty
63+ *
64+ * @phpstan-assert-if-false non-empty-array<TKey,TValue> $this->all()
65+ * @phpstan-assert-if-false !null $this->first()
66+ * @phpstan-assert-if-false !null $this->last()
67+ */
68+ public function isEmpty (): bool ;
69+
6370 /**
6471 * Add or replace an item with a given key
6572 *
@@ -73,6 +80,9 @@ public function set($key, $value);
7380 * Check if an item with a given key exists
7481 *
7582 * @param TKey $key
83+ * @phpstan-assert-if-true non-empty-array<TKey,TValue> $this->all()
84+ * @phpstan-assert-if-true !null $this->first()
85+ * @phpstan-assert-if-true !null $this->last()
7686 */
7787 public function has ($ key ): bool ;
7888
@@ -246,6 +256,9 @@ public function slice(int $offset, ?int $length = null);
246256 * Check if a value is in the collection
247257 *
248258 * @param TValue $value
259+ * @phpstan-assert-if-true non-empty-array<TKey,TValue> $this->all()
260+ * @phpstan-assert-if-true !null $this->first()
261+ * @phpstan-assert-if-true !null $this->last()
249262 */
250263 public function hasValue ($ value , bool $ strict = false ): bool ;
251264
0 commit comments