diff --git a/composer.json b/composer.json index 8219d29..ae9dca5 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ ], "require": { "php": "^7.2 || ^8.0", - "phpstan/phpstan": "^1.11.6" + "phpstan/phpstan": "^1.11.8" }, "conflict": { "nette/application": "<2.3.0", diff --git a/src/Type/Nette/StringsMatchDynamicReturnTypeExtension.php b/src/Type/Nette/StringsMatchDynamicReturnTypeExtension.php index 8a88444..a2489c5 100644 --- a/src/Type/Nette/StringsMatchDynamicReturnTypeExtension.php +++ b/src/Type/Nette/StringsMatchDynamicReturnTypeExtension.php @@ -42,14 +42,13 @@ public function getTypeFromStaticMethodCall(MethodReflection $methodReflection, return null; } - $patternType = $scope->getType($patternArg->value); $flagsArg = $args[2] ?? null; $flagsType = null; if ($flagsArg !== null) { $flagsType = $scope->getType($flagsArg->value); } - $arrayShape = $this->regexArrayShapeMatcher->matchType($patternType, $flagsType, TrinaryLogic::createYes()); + $arrayShape = $this->regexArrayShapeMatcher->matchExpr($patternArg->value, $flagsType, TrinaryLogic::createYes(), $scope); if ($arrayShape === null) { return null; } diff --git a/tests/Type/Nette/data/strings-match.php b/tests/Type/Nette/data/strings-match.php index 5d5df66..ed58596 100644 --- a/tests/Type/Nette/data/strings-match.php +++ b/tests/Type/Nette/data/strings-match.php @@ -18,4 +18,7 @@ function (string $s): void { $result = Strings::match($s, '/(foo)(bar)(baz)/'); assertType('array{string, string, string, string}|null', $result); + + $result = Strings::match($s, '/(foo)(bar)'. preg_quote($s) .'(baz)/'); + assertType('array{string, string, string, string}|null', $result); };