array, true); return $out === false ? null : $out; } /** * Searches the array with a given callback and returns the index for the last element if found. * * The callback function takes one or two parameters: * * function ($element [, $query]) {} * * The callback must return a boolean * When it's passed, $query must be the first argument: * * - find($query, callback) * - find(callback) * * @param array $arguments * * @return int|string|null the index or null if it hasn't been found */ public function findLastIndex(mixed ...$arguments): int|string|null { /** @var mixed $index */ $index = count($arguments) === 1 ? $this->findLast($arguments[0]) : $this->findLast($arguments[0], $arguments[1]); return $this->indexOf($index); } /** * Searches the array with a given callback and returns the index for the first element if found. * * The callback function takes one or two parameters: * * function ($element [, $query]) {} * * The callback must return a boolean * When it's passed, $query must be the first argument: * * - find($query, callback) * - find(callback) * * @param array $arguments * * @return int|string|null the index or null if it hasn't been found */ public function findIndex(mixed ...$arguments): int|string|null { /** @var mixed $index */ $index = count($arguments) === 1 ? $this->find($arguments[0]) : $this->find($arguments[0], $arguments[1]); return $this->indexOf($index); } }