hphp/hack/manual/apis/Interfaces/HH/Collection/index.md
:::info[Note] This is a point-in-time snapshot of the API documentation from January 2026. Going forward, we will not be maintaining a public copy of these references, and recommend users to refer to the built-in signature helpers available in the Hack LSP instead for complete and up-to-date information. :::
Collection is the primary collection interface for mutable collections
Assuming you want the ability to clear out your collection, you would
implement this (or a child of this) interface. Otherwise, you can implement
OutputCollection only. If your collection to be immutable, implement
ConstCollection only instead.
namespace HH;
interface Collection implements \ConstCollection<Te>, \OutputCollection<Te> {...}
->clear()ConstCollection)->count(): int
Get the number of items in the collection
->isEmpty(): bool
Is the collection empty?
->items(): HH\Iterable<Te>
Get access to the items in the collection
IPureStringishObject)OutputCollection)->add(Te $e): this->addAll(?Traversable<Te> $traversable): thisTraversable, append a value into the
current collection