From 5ef590bb2dba29e7846122d7bf6fe382f8e87af3 Mon Sep 17 00:00:00 2001 From: Deeka Wong Date: Fri, 26 Apr 2024 10:18:38 +0800 Subject: [PATCH] Remove some collection methods (#613) Co-authored-by: Deeka Wong <8337659+huangdijia@users.noreply.github.com> --- composer.json | 2 +- output/Hyperf/Collection/Collection.php | 63 ------------------------- src/CollectionMixin.php | 56 ---------------------- 3 files changed, 1 insertion(+), 120 deletions(-) diff --git a/composer.json b/composer.json index c5ad8b4..e2b2d32 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ }, "require": { "friendsofhyperf/support": "~3.1.0", - "hyperf/collection": "~3.1.0", + "hyperf/collection": "~3.1.20", "hyperf/macroable": "~3.1.0", "hyperf/stringable": "~3.1.0", "hyperf/support": "~3.1.0", diff --git a/output/Hyperf/Collection/Collection.php b/output/Hyperf/Collection/Collection.php index d2f9ef3..0cbba58 100644 --- a/output/Hyperf/Collection/Collection.php +++ b/output/Hyperf/Collection/Collection.php @@ -16,19 +16,6 @@ class Collection { - /** - * Determine if an item is missing in the collection. - * Determine if an item is not contained in the collection. - * - * @param string $key - * @param mixed $operator - * @param mixed $value - * @return bool - */ - public function doesntContain($key, $operator = null, $value = null) - { - } - /** * Ensure that every item in the collection is of the expected type. * @@ -67,16 +54,6 @@ public function getOrPut($key, $value) { } - /** - * Determine if any of the keys exist in the collection. - * - * @param mixed $key - * @return bool - */ - public function hasAny($key) - { - } - /** * Determine if the collection contains a single element. * @@ -97,16 +74,6 @@ public function intersectUsing($items, callable $callback) { } - /** - * Intersect the collection with the given items with additional index check. - * - * @param Arrayable|iterable $items - * @return static - */ - public function intersectAssoc($items) - { - } - /** * Intersect the collection with the given items with additional index check, using the callback. * @@ -128,27 +95,6 @@ public function pipeThrough($pipes) { } - /** - * Create chunks representing a "sliding window" view of the items in the collection. - * - * @param int $size - * @param int $step - * @return static - */ - public function sliding($size = 2, $step = 1) - { - } - - /** - * Skip the first {$count} items. - * - * @param int $count - * @return static - */ - public function skip($count) - { - } - /** * Get the first item in the collection, but only if exactly one item exists. Otherwise, throw an exception. * @@ -163,15 +109,6 @@ public function sole($key = null, $operator = null, $value = null) { } - /** - * Sort the collection keys using a callback. - * - * @return static - */ - public function sortKeysUsing(callable $callback) - { - } - /** * Convert a flatten "dot" notation array into an expanded array. * diff --git a/src/CollectionMixin.php b/src/CollectionMixin.php index 08eb702..92b62f9 100644 --- a/src/CollectionMixin.php +++ b/src/CollectionMixin.php @@ -27,11 +27,6 @@ */ class CollectionMixin { - public function doesntContain() - { - return fn ($key, $operator = null, $value = null) => ! $this->contains(...func_get_args()); - } - public function ensure() { return fn ($type) => $this->each(function ($item) use ($type) { @@ -77,25 +72,6 @@ public function getOrPut() }; } - public function hasAny() - { - return function ($key) { - if ($this->isEmpty()) { - return false; - } - - $keys = is_array($key) ? $key : func_get_args(); - - foreach ($keys as $value) { - if ($this->has($value)) { - return true; - } - } - - return false; - }; - } - public function isSingle() { return fn () => $this->count() === 1; @@ -107,12 +83,6 @@ public function intersectUsing() return fn ($items, callable $callback) => new static(array_uintersect($this->items, $this->getArrayableItems($items), $callback)); } - public function intersectAssoc() - { - /* @phpstan-ignore-next-line */ - return fn ($items) => new static(array_intersect_assoc($this->items, $this->getArrayableItems($items))); - } - public function intersectAssocUsing() { /* @phpstan-ignore-next-line */ @@ -124,20 +94,6 @@ public function pipeThrough() return fn ($pipes) => static::make($pipes)->reduce(fn ($carry, $pipe) => $pipe($carry), $this); } - public function skip() - { - return fn ($count) => $this->slice($count); - } - - public function sliding() - { - return function ($size = 2, $step = 1) { - $chunks = (int) floor(($this->count() - $size) / $step) + 1; - - return static::times($chunks, fn ($number) => $this->slice(($number - 1) * $step, $size)); - }; - } - public function sole() { return function ($key = null, $operator = null, $value = null) { @@ -158,18 +114,6 @@ public function sole() }; } - public function sortKeysUsing() - { - return function (callable $callback) { - /** @phpstan-ignore-next-line */ - $items = $this->items; - - uksort($items, $callback); - - return new static($items); - }; - } - public function undot() { return fn () => new Collection(Arr::undot($this->all())); /* @phpstan-ignore-line */