Filters all elements out that don't match the given matcher.

@param callable $matcher Is called with each element and its key
@return static
192605
public function filter($matcher) {
        $filtered = array();
        foreach ($this as $key => $element) {
            if (call_user_func($matcher, $element, $key)) {
                $filtered[$key] = $element;
            }
        }

        return new static($filtered);
    }
233791
public function hasChildFor(SegmentMatcher $matcher)
    {
        $hash = $matcher->getHash();

        return isset($this->children[$hash]);
    }
1374609
public function each(callable $callable)
    {
        foreach ($this->attributes as $key => $value)
        {
            if($callable($value, $key) === false)
                break;
        }

        return $this;
    }
1072476
public ResultMatcher matches(final Matcher<?> matcher) {
        return new AbstractResultMatcher(path, configuration) {
            public void doMatch(Object actual) {
                isPresent(actual);
                Node node = getNode(actual);
                assertThat("Node \"" + path + "\" does not match.", node.getValue(), (Matcher<? super Object>) matcher);
            }
        };

    }
223895
public static function filter(array $array, callable $callable = NULL) {
    $array = is_callable($callable) ? array_filter($array, $callable) : array_filter($array);
    foreach ($array as &$element) {
      if (is_array($element)) {
        $element = static::filter($element, $callable);
      }
    }

    return $array;
  }
436530
@Factory
    public static <T extends Throwable> Matcher<T> hasCause(final Matcher<?> matcher) {
        return new ThrowableCauseMatcher<T>(matcher);
    }
173722
public function filter(callable $func)
    {
        if (!$this->pipeline) {
            // No-op: either an empty array or null.
            return $this;
        }

        // We got an array, that's what we need. Moving along.
        if (\is_array($this->pipeline)) {
            $this->pipeline = \array_filter($this->pipeline, $func);

            return $this;
        }

        // CallbackFilterIterator needs a plain Iterator
        if (!$this->pipeline instanceof \Iterator) {
            $this->pipeline = new \IteratorIterator($this->pipeline);
        }

        $this->pipeline = new \CallbackFilterIterator($this->pipeline, $func);

        return $this;
    }
514349
public function filter($callable = '')
    {
        if ($callable != '' && !$this->isCallable($callable)) {
            throw new ArrayObjectException(ArrayObjectException::MSG_INVALID_PARAM, [
                '$callable',
                'a callable function or method'
            ]);
        }

        if ($callable == '') {
            // Filter all values equal to FALSE
            $this->val(array_filter($this->val()));
        } else {
            // Filter values using a callback
            $this->val(array_filter($this->val(), $callable));
        }

        return $this;
    }
1144027
public function filter($callback = null)
    {
        if (is_null($callback)) {
            return new static(array_filter($this->array)); 
        }
        return new static(array_filter($this->array, $callback));
    }
167151
public function match($callable)
    {
        $this->remote = lego_register(
            AutoCompleteMatchHandler::class,
            $callable,
            md5(__CLASS__ . $this->name())
        )->remote();

        return $this;
    }
1037776
public function setApplyFilterFunction(callable $function)
    {
        $validator = $this->getCallableValidatorApplyFilters();
        $validator->setCallableFunction($function);

        if ($validator->isValid() === false) {
            throw $validator->getException();
        }

        $this->applyFilterFunction = $function;

        return $this;
    }
22674
public function filter(callable $callback): self
    {
        $collection = Factory::create();
        $index      = 0;
        foreach ($this->items as $key => $value) {
            if ($callback($value, $key, $index++)) {
                $collection->set($key, $value);
            }
        }

        return $collection;
    }
1243892
public function filter(?callable $callable = null)
	{
		if($callable === null)
		{
			return new static(array_filter($this->items));
		}

		return new static(array_filter($this->items, $callable, ARRAY_FILTER_USE_BOTH));
	}
508799
public static Matcher<ContextElement> attributes(final Matcher<Map<String, Object>> matcher) {
    return new Matcher<ContextElement>() {

      @Override
      protected boolean matchesSafely(ContextElement t) {
        return matcher.matches(t.attributes());
      }

      @Override
      public String toString() {
        return "an attributes " + matcher;
      }
    };
  }
527077
public function filter(callable $callback = null)
    {
        if ($callback) {
            return new static($this->manager, array_filter($this->divisions, $callback));
        }

        return new static($this->manager, array_filter($this->divisions));
    }
1043539
function filter(callable $closure) {
        $args = $this->baseStorageArgs;
        $args[] = parent::filter($closure)->all();
        
        return (new static(...$args));
    }
45620
public static <S> Matcher<S> is(Matcher<S> matcher) {
        return Matchers.is(matcher);
    }