Skip to content

Commit f7ebdcb

Browse files
authored
Merge pull request #132 from Toflar/fix-cache-key
Fix result cache key in CompilingMatcher
2 parents f79c90a + eca295a commit f7ebdcb

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

src/CompilingMatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public static function clear()
6868
*/
6969
public static function match(ConstraintInterface $constraint, $operator, $version)
7070
{
71-
$resultCacheKey = $operator.$constraint.$version;
71+
$resultCacheKey = $operator.$constraint.';'.$version;
7272

7373
if (isset(self::$resultCache[$resultCacheKey])) {
7474
return self::$resultCache[$resultCacheKey];

tests/CompilingMatcherTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,10 @@ public function testMatch()
2121
{
2222
$this->assertTrue(CompilingMatcher::match(new Constraint('>=', '1'), Constraint::OP_EQ, '2'));
2323
}
24+
25+
public function testCacheKey()
26+
{
27+
$this->assertFalse(CompilingMatcher::match(new Constraint('>=', '2.11'), Constraint::OP_EQ, '1.0'));
28+
$this->assertTrue(CompilingMatcher::match(new Constraint('>=', '2.1'), Constraint::OP_EQ, '11.0'));
29+
}
2430
}

0 commit comments

Comments
 (0)