src/Matcher/MatcherVerifier.php
public function matches(array $matchers, array $arguments): bool
    {
        $argumentCount = count($arguments);
        $index = 0;

        foreach ($matchers as $matcher) {
            if ($matcher instanceof WildcardMatcher) {
                $matchCount = 0;
                $innerMatcher = $matcher->matcher();

                while (
                    $index < $argumentCount &&
                    $innerMatcher->matches($arguments[$index])
                ) {
                    ++$matchCount;
                    ++$index;
                }

                $maximumArguments = $matcher->maximumArguments();

                $isMatch =
                    (
                        $maximumArguments < 0 ||
                        $matchCount <= $maximumArguments
                    ) &&
                    $matchCount >= $matcher->minimumArguments();

                if (!$isMatch) {
                    return false;
                }

                continue;
            }

            if (
                $index >= $argumentCount ||
                !$matcher->matches($arguments[$index])
            ) {
                return false;
            }

            ++$index;
        }

        return $index === $argumentCount;
    }
public function matches(array $matchers, array $arguments): bool
    {
        $argumentCount = count($arguments);
        $index = 0;

        foreach ($matchers as $matcher) {
            if ($matcher instanceof WildcardMatcher) {
                $matchCount = 0;
                $innerMatcher = $matcher->matcher();

                while (
                    $index < $argumentCount &&
                    $innerMatcher->matches($arguments[$index])
                ) {
                    ++$matchCount;
                    ++$index;
                }

                $maximumArguments = $matcher->maximumArguments();

                $isMatch =
                    (
                        $maximumArguments < 0 ||
                        $matchCount <= $maximumArguments
                    ) &&
                    $matchCount >= $matcher->minimumArguments();

                if (!$isMatch) {
                    return false;
                }

                continue;
            }

            if (
                $index >= $argumentCount ||
                !$matcher->matches($arguments[$index])
            ) {
                return false;
            }

            ++$index;
        }

        return $index === $argumentCount;
    }
public function matches ( array $ matchers , array $ arguments ) : bool { $ argumentCount = count ( $ arguments ) ; $ index = 0 ; foreach ( $ matchers as $ matcher ) { if ( $ matcher instanceof WildcardMatcher ) { $ matchCount = 0 ; $ innerMatcher = $ matcher -> matcher ( ) ; while ( $ index < $ argumentCount && $ innerMatcher -> matches ( $ arguments [ $ index ] ) ) { ++ $ matchCount ; ++ $ index ; } $ maximumArguments = $ matcher -> maximumArguments ( ) ; $ isMatch = ( $ maximumArguments < 0 || $ matchCount <= $ maximumArguments ) && $ matchCount >= $ matcher -> minimumArguments ( ) ; if ( ! $ isMatch ) { return false ; } continue ; } if ( $ index >= $ argumentCount || ! $ matcher -> matches ( $ arguments [ $ index ] ) ) { return false ; } ++ $ index ; } return $ index === $ argumentCount ; }
Verify that the supplied arguments match the supplied matchers.

@param array<Matchable> $matchers  The matchers.
@param array            $arguments The arguments.

@return bool True if the arguments match.
Verify that the supplied arguments match the supplied matchers .