From cdba36f2515d318b9a1166bea8baec22788690e9 Mon Sep 17 00:00:00 2001 From: Simon Podlipsky Date: Wed, 9 Oct 2024 14:30:15 +0200 Subject: [PATCH] fix: assert type string is matched (#264) --- src/Sql/Type.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Sql/Type.php b/src/Sql/Type.php index b998f7a..52af57b 100644 --- a/src/Sql/Type.php +++ b/src/Sql/Type.php @@ -4,6 +4,7 @@ namespace SimPod\ClickHouseClient\Sql; +use function assert; use function preg_match; final readonly class Type @@ -14,7 +15,8 @@ private function __construct(public string $name, public string $params) public static function fromString(string $type): self { - preg_match('~([a-zA-Z\d ]+)(?:\((.+)\))?~', $type, $matches); + $result = preg_match('~([a-zA-Z\d ]+)(?:\((.+)\))?~', $type, $matches); + assert($result === 1); return new self($matches[1], $matches[2] ?? ''); }