Skip to content

Commit 7c96335

Browse files
committed
Trim whitespaces around the matchers after OR splitting
1 parent 01ec0db commit 7c96335

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

Diff for: src/Matcher/OrMatcher.php

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ public function __construct(ChainMatcher $chainMatcher)
1818
public function match($value, $pattern) : bool
1919
{
2020
$patterns = \explode('||', $pattern);
21+
$patterns = \array_map('trim', $patterns);
22+
2123
foreach ($patterns as $childPattern) {
2224
if ($this->matchChild($value, $childPattern)) {
2325
return true;

Diff for: tests/Matcher/OrMatcherTest.php

+15
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,21 @@ public function test_negative_match_arrays($value, $pattern)
4343
);
4444
}
4545

46+
public function test_whitespaces_trim_after_splitting()
47+
{
48+
$this->assertTrue(
49+
$this->matcher->match(
50+
[
51+
'test' => null
52+
],
53+
[
54+
'test' => ' @integer@ || @null@ '
55+
]
56+
),
57+
$this->matcher->getError()
58+
);
59+
}
60+
4661
public static function positiveMatchData()
4762
{
4863
$simpleArr = [

0 commit comments

Comments
 (0)