Skip to content

Commit

Permalink
Fix conflicts in CollectionInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
valzargaming committed Dec 24, 2024
1 parent fcd5be7 commit 7212c30
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 27 deletions.
21 changes: 21 additions & 0 deletions src/Discord/Helpers/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,26 @@
*/
class Collection implements CollectionInterface
{
/**
* The collection discriminator.
*
* @var ?string
*/
protected $discrim;

/**
* The items contained in the collection.
*
* @var array
*/
protected $items;

/**
* Class type allowed into the collection.
*
* @var string
*/
protected $class;

use CollectionTrait;
}
12 changes: 6 additions & 6 deletions src/Discord/Helpers/CollectionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ interface CollectionInterface extends ArrayAccess, JsonSerializable, IteratorAgg
public function get(string $discrim, $key);
public function set($offset, $value);
public function pull($key, $default = null);
public function fill(array $items): static;
public function push(...$items): static;
public function pushItem($item): static;
public function fill(array $items);
public function push(...$items);
public function pushItem($item);
public function count(): int;
public function first();
public function last();
public function isset($offset): bool;
public function has(...$keys): bool;
public function filter(callable $callback): static;
public function filter(callable $callback);
public function find(callable $callback);
public function clear(): void;
public function map(callable $callback): static;
public function merge($collection): static;
public function map(callable $callback);
public function merge($collection);
public function toArray();
public function offsetExists($offset): bool;
#[\ReturnTypeWillChange]
Expand Down
33 changes: 12 additions & 21 deletions src/Discord/Helpers/CollectionTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,6 @@

trait CollectionTrait
{
/**
* The collection discriminator.
*
* @var ?string
*/
protected $discrim;

/**
* The items contained in the collection.
*
* @var array
*/
protected $items;

/**
* Class type allowed into the collection.
*
* @var string
*/
protected $class;

/**
* Create a new static.
*
Expand Down Expand Up @@ -353,6 +332,18 @@ public function toArray()
return $this->items;
}

/**
* @since 11.0.0
*
* Get the keys of the items.
*
* @return int[]|string[]
*/
public function keys(): array
{
return array_keys($this->items);
}

/**
* If the collection has an offset.
*
Expand Down

0 comments on commit 7212c30

Please sign in to comment.