From a050ff2878387dbe4aa5f4dd66c82f6b83416630 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20B=C3=B6sing?= <2189546+boesing@users.noreply.github.com> Date: Sun, 26 Sep 2021 16:23:38 +0200 Subject: [PATCH] bugfix: quote regular expression MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com> --- src/Psalm/Internal/Type/SimpleAssertionReconciler.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Psalm/Internal/Type/SimpleAssertionReconciler.php b/src/Psalm/Internal/Type/SimpleAssertionReconciler.php index 50db0595c..2da742187 100644 --- a/src/Psalm/Internal/Type/SimpleAssertionReconciler.php +++ b/src/Psalm/Internal/Type/SimpleAssertionReconciler.php @@ -50,6 +50,7 @@ use function get_class; use function max; use function min; use function preg_match; +use function preg_quote; use function sprintf; use function str_replace; use function strpos; @@ -2419,7 +2420,7 @@ class SimpleAssertionReconciler extends \Psalm\Type\Reconciler return $existing_type; } - $constant_regex_pattern = sprintf('#^%s$#', str_replace('*', '.*', $constant_pattern)); + $constant_regex_pattern = sprintf('#^%s$#', preg_quote(str_replace('*', '.*', $constant_pattern), '#')); $class_like_storage = $codebase->classlike_storage_provider->get($class_name); $matched_class_constant_types = [];