Skip to content

Commit 4e71c1a

Browse files
committed
fixed RegexpOperator (added strict comparison)
1 parent 0878875 commit 4e71c1a

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/Operator/Comparator/RegexpOperator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ final class RegexpOperator extends AbstractCompareTwo
1818

1919
public function executeComparison(mixed $expr1, mixed $expr2): bool
2020
{
21-
return (bool) preg_match($expr2, $expr1);
21+
return preg_match($expr2, $expr1) !== false;
2222
}
2323
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace LogicTree\Test\Operator\Comparator;
4+
5+
use LogicTree\Operator\Comparator\RegexpOperator;
6+
7+
class RegexpOperatorTest extends \PHPUnit\Framework\TestCase
8+
{
9+
10+
public function testItMatchesExactMatch()
11+
{
12+
$this->assertTrue((new RegexpOperator())->executeComparison('toto', '/^[A-Z]+/'));
13+
}
14+
15+
}

0 commit comments

Comments
 (0)