filter
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.
Returns a ImmVector containing the values of the current ImmVector that
meet a supplied condition
public function filter(
(function(Tv): bool) $callback,
): ImmVector<Tv>;
filter()'s result contains only values that meet the provided criterion;
unlike map(), where a value is included for each value in the original
ImmVector.
Guide
Parameters
(function(Tv): bool) $callback
Returns
ImmVector<Tv>- AnImmVectorcontaining the values after a user-specified condition is applied.
Examples
See Vector::filter for usage examples.