Skip to content

Commit

Permalink
Fix matching for '@array@||@null@'
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric GELOEN committed Oct 4, 2024
1 parent 6145a0e commit 468b415
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Factory/MatcherFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,22 @@ private function buildMatchers(Parser $parser, Backtrace $backtrace) : Matcher\C

private function buildArrayMatcher(Matcher\ChainMatcher $scalarMatchers, Parser $parser, Backtrace $backtrace) : Matcher\ArrayMatcher
{
$orMatcher = new Matcher\OrMatcher($backtrace, $scalarMatchers);

return new Matcher\ArrayMatcher(
$arrayMatcher = new Matcher\ArrayMatcher(
new Matcher\ChainMatcher(
'array',
$backtrace,
[
$orMatcher,
new Matcher\OrMatcher($backtrace, $orMatchers = clone $scalarMatchers),
$scalarMatchers,
new Matcher\TextMatcher($backtrace, $parser),
]
),
$backtrace,
$parser
);
$orMatchers->registerMatcher($arrayMatcher);

Check warning on line 65 in src/Factory/MatcherFactory.php

View workflow job for this annotation

GitHub Actions / Mutation Tests

Escaped Mutant for Mutator "MethodCallRemoval": --- Original +++ New @@ @@ private function buildArrayMatcher(Matcher\ChainMatcher $scalarMatchers, Parser $parser, Backtrace $backtrace) : Matcher\ArrayMatcher { $arrayMatcher = new Matcher\ArrayMatcher(new Matcher\ChainMatcher('array', $backtrace, [new Matcher\OrMatcher($backtrace, $orMatchers = clone $scalarMatchers), $scalarMatchers, new Matcher\TextMatcher($backtrace, $parser)]), $backtrace, $parser); - $orMatchers->registerMatcher($arrayMatcher); + return $arrayMatcher; } private function buildScalarMatchers(Parser $parser, Backtrace $backtrace) : Matcher\ChainMatcher

return $arrayMatcher;
}

private function buildScalarMatchers(Parser $parser, Backtrace $backtrace) : Matcher\ChainMatcher
Expand Down
5 changes: 5 additions & 0 deletions src/Matcher/ChainMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ public function __construct(string $name, Backtrace $backtrace, array $matchers
$this->name = $name;
}

public function registerMatcher(ValueMatcher $matcher): void
{
$this->matchers[] = $matcher;
}

public function match($value, $pattern) : bool
{
$this->backtrace->matcherEntrance($this->matcherName(), $value, $pattern);
Expand Down

0 comments on commit 468b415

Please sign in to comment.