Use $callback to filter items in this list. Array keys are
reset after filtering.

@param callable $callback The function to filter the list.
@param bool     $in_place Whether to replace the current list
432021
public function filter($callback, $in_place = false)
    {
        if (!is_callable($callback)) {
            throw new \InvalidArgumentException('ItemList::filter() expects a callable argument.');
        }
        $filtered = array_values(array_filter($this->list, $callback));

        if ($in_place) {
            $this->list = $filtered;

            return $this;
        }

        return new ItemList($filtered);
    }
751931
public function each(callable $callback)
    {
        foreach ($this->items as $key => $item) {
            $result = $callback($item, $key);

            if (false === $result) {
                break;
            }

            if (!is_object($item)) {
                $this->items[$key] = $result;
            }
        }

        return $this;
    }
1046349
public function each(callable $callback): self
    {
        $index = 0;
        foreach ($this->items as $key => $value) {
            $callback($value, $key, $index++);
        }

        return $this;
    }
899444
public function whereNested(Closure $callback, $boolean = 'and')
    {
        call_user_func($callback, $query = $this->forNestedWhere());

        return $this->addNestedWhereQuery($query, $boolean);
    }
1295105
public function addFilterCallback($callback, $flags = null)
    {
        $flags = (int) $flags;

        if ($flags & self::FILTER_REPLACE_ENTRY) {
            $this->filterEntryCallbacks = [];
        }

        if ($flags & self::FILTER_REPLACE_EXIT) {
            $this->filterExitCallbacks = [];
        }

        // Called when entry records came
        if (($flags & self::FILTER_ENTRY) || !($flags & self::FILTER_EXIT)) {
            if ($flags & self::FILTER_APPEND_ENTRY) {
                $this->filterEntryCallbacks[] = $callback;

            } else {
                \array_unshift($this->filterEntryCallbacks, $callback);
            }
        }

        // Called when exit records came
        if ($flags & self::FILTER_EXIT) {
            if ($flags & self::FILTER_APPEND_EXIT) {
                $this->filterExitCallbacks[] = $callback;

            } else {
                \array_unshift($this->filterExitCallbacks, $callback);
            }
        }
    }
355602
public static function filter(array $data, $callback, $flag = null)
    {
        if (! is_callable($callback)) {
            throw new Exception\InvalidArgumentException(sprintf(
                'Second parameter of %s must be callable',
                __METHOD__
            ));
        }

        if (version_compare(PHP_VERSION, '5.6.0') >= 0) {
            return array_filter($data, $callback, $flag);
        }

        $output = [];
        foreach ($data as $key => $value) {
            $params = [$value];

            if ($flag === static::ARRAY_FILTER_USE_BOTH) {
                $params[] = $key;
            }

            if ($flag === static::ARRAY_FILTER_USE_KEY) {
                $params = [$key];
            }

            $response = call_user_func_array($callback, $params);
            if ($response) {
                $output[$key] = $value;
            }
        }

        return $output;
    }
949544
function filter(object, callback) {
		if (!object) { return true; }
		if (object.filter) { return object.filter(callback); }
		if (object instanceof Array) {
			var result = [],
				length	= array ? array.length : 0;
			for(var index = 0; index < length; index++) {
				if (callback(array[index], index)) {
					result.push(array[index]);
				}
			}
		}else{
			var result = {};
			for(var key in object) {
				if (!object.hasOwnProperty(key)) { continue; }
				if (callback(object[key], key)) {
					result[key] = object[key];
				}
			}
		}
		return false;
	}
186826
public function setFilterFunction($callback)
    {
        if (!is_callable($callback, true)) {
            throw new InvalidArgumentException('TreeDropdownField->setFilterCallback(): not passed a valid callback');
        }

        $this->filterCallback = $callback;
        return $this;
    }
532949
public function filter(callable $callback = null)
    {
        if (!is_null($callback)) {
            return new static(
                $this->wye,
                array_filter($this->items, $callback, ARRAY_FILTER_USE_BOTH)
            );
        }

        return new static($this->wye, array_filter($this->items));
    }
62101
public function filter(callable $callback = null)
    {
        if ($callback) {

            return new static(ArrayHelper::where($this->items, $callback));
        }

        return new static(array_filter($this->items));
    }
383897
public function filter(Closure $callback)
    {
        $filtered_map = new static;

        foreach ($this->items as $key => $item) {
            if ($callback($item) === true) {
                $filtered_map->setItem($key, $item);
            }
        }

        return $filtered_map;
    }
861791
protected function doFilter($value, Closure $callback)
    {
        return true === $this->multiByteEnabled ?
            mb_convert_case($value, $this->mode, $this->encoding) : $callback($value);
    }
710696
public function removeFilter($callback)
    {
        if (($index = array_search(self::NAMESPACE_PLUGINS_FILTERS. 'Filter' . self::toCamelCase($callback), $this->filters,
                true)) !==
            false) {
            unset($this->filters[$index]);
        } elseif (($index = array_search($callback, $this->filters, true)) !== false) {
            unset($this->filters[$index]);
        } else {
            $class = self::NAMESPACE_PLUGINS_FILTERS . 'Filter' . $callback;
            foreach ($this->filters as $index => $filter) {
                if (is_array($filter) && $filter[0] instanceof $class) {
                    unset($this->filters[$index]);
                    break;
                }
            }
        }
    }
212331
public function filter(callable $callback) : self
    {
        $entries = array_filter($this->getItems()->getArrayCopy(), $callback);
        $this->getItems()->exchangeArray($entries);
        return $this;
    }
67991
public function filter(\Closure $callback, $reindex = true) {
		$result = array_filter($this->annotations, $callback);
		
		if ($reindex) {
			$result = array_values($result);
		}
		
		return $result;
	}
1277185
protected function doFilter(callable $filterCallback)
    {
        foreach ($this->iterator as $value) {
            if (call_user_func($filterCallback, $value)) {
                yield $value;
            }
        }
    }
1313279
public function filter(callable $callback = null)
    {
        foreach ($this->items as $key => $value) {
            if (
                (!$callback && !(bool)$value) ||
                ($callback && !$callback($value, $key))
            ) {
                unset($this->items[$key]);
            }
        }

        return $this;
    }