From 578f80e51d351cd83d8e349260b96bf21e066fac Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 19 Sep 2024 16:13:58 +0200 Subject: [PATCH] Fix types --- src/CompilingMatcher.php | 2 +- tests/VersionParserTest.php | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/CompilingMatcher.php b/src/CompilingMatcher.php index 45bce70a..aea1d3b9 100644 --- a/src/CompilingMatcher.php +++ b/src/CompilingMatcher.php @@ -64,7 +64,7 @@ public static function clear() * @phpstan-param Constraint::OP_* $operator * @param string $version * - * @return mixed + * @return bool */ public static function match(ConstraintInterface $constraint, $operator, $version) { diff --git a/tests/VersionParserTest.php b/tests/VersionParserTest.php index 269a495a..b7856d94 100644 --- a/tests/VersionParserTest.php +++ b/tests/VersionParserTest.php @@ -197,7 +197,9 @@ public static function failingNormalizedVersions() */ public function testNormalizeFailsAndReportsAliasIssue($fullInput) { - preg_match('{^([^,\s#]+)(?:#[^ ]+)? +as +([^,\s]+)$}', $fullInput, $match); + if (!preg_match('{^([^,\s#]+)(?:#[^ ]+)? +as +([^,\s]+)$}', $fullInput, $match)) { + $this->fail($fullInput.' did not match the regex'); + } $parser = new VersionParser(); $parser->normalize($match[1], $fullInput); try { @@ -227,7 +229,9 @@ public static function failingNormalizedVersionsWithBadAlias() */ public function testNormalizeFailsAndReportsAliaseeIssue($fullInput) { - preg_match('{^([^,\s#]+)(?:#[^ ]+)? +as +([^,\s]+)$}', $fullInput, $match); + if (!preg_match('{^([^,\s#]+)(?:#[^ ]+)? +as +([^,\s]+)$}', $fullInput, $match)) { + $this->fail($fullInput.' did not match the regex'); + } $parser = new VersionParser(); try { $parser->normalize($match[1], $fullInput);