Skip to content

Commit

Permalink
Remove some collection methods (#613)
Browse files Browse the repository at this point in the history
Co-authored-by: Deeka Wong <8337659+huangdijia@users.noreply.github.com>
  • Loading branch information
huangdijia and huangdijia authored Apr 26, 2024
1 parent 0ec2ac7 commit 5ef590b
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 120 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
63 changes: 0 additions & 63 deletions output/Hyperf/Collection/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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.
*
Expand All @@ -97,16 +74,6 @@ public function intersectUsing($items, callable $callback)
{
}

/**
* Intersect the collection with the given items with additional index check.
*
* @param Arrayable<TKey, TValue>|iterable<TKey, TValue> $items
* @return static
*/
public function intersectAssoc($items)
{
}

/**
* Intersect the collection with the given items with additional index check, using the callback.
*
Expand All @@ -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.
*
Expand All @@ -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.
*
Expand Down
56 changes: 0 additions & 56 deletions src/CollectionMixin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand All @@ -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 */
Expand All @@ -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) {
Expand All @@ -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 */
Expand Down

0 comments on commit 5ef590b

Please sign in to comment.