gen_stub: fix regexps with unintentional range due to - character placement (#12004)

This commit is contained in:
Ayesh Karunaratne 2023-08-20 20:20:56 +08:00 committed by GitHub
parent 807a05ee55
commit e6627ccb52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -272,7 +272,7 @@ class SimpleType {
} }
$matches = []; $matches = [];
$isArray = preg_match("/array\s*<\s*([A-Za-z0-9_-|]+)?(\s*,\s*)?([A-Za-z0-9_-|]+)?\s*>/i", $typeString, $matches); $isArray = preg_match("/array\s*<\s*([A-Za-z0-9_|-]+)?(\s*,\s*)?([A-Za-z0-9_|-]+)?\s*>/i", $typeString, $matches);
if ($isArray) { if ($isArray) {
if (empty($matches[1]) || empty($matches[3])) { if (empty($matches[1]) || empty($matches[3])) {
throw new Exception("array<> type hint must have both a key and a value"); throw new Exception("array<> type hint must have both a key and a value");