diff --git a/src/Discord/Helpers/Collection.php b/src/Discord/Helpers/Collection.php index 8f92909ee..d64f1ab2b 100644 --- a/src/Discord/Helpers/Collection.php +++ b/src/Discord/Helpers/Collection.php @@ -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; } diff --git a/src/Discord/Helpers/CollectionInterface.php b/src/Discord/Helpers/CollectionInterface.php index b3ed23b61..9266e208a 100644 --- a/src/Discord/Helpers/CollectionInterface.php +++ b/src/Discord/Helpers/CollectionInterface.php @@ -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] diff --git a/src/Discord/Helpers/CollectionTrait.php b/src/Discord/Helpers/CollectionTrait.php index 2cbf79f6f..e5e9c32cc 100644 --- a/src/Discord/Helpers/CollectionTrait.php +++ b/src/Discord/Helpers/CollectionTrait.php @@ -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. * @@ -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. *