Skip to content

Commit 33f4a67

Browse files
committed
Identifier cannot contain spaces
1 parent 11ee184 commit 33f4a67

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/Type/Constant/ConstantArrayType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1586,7 +1586,7 @@ public function toPhpDocNode(): TypeNode
15861586

15871587
public static function isValidIdentifier(string $value): bool
15881588
{
1589-
$result = Strings::match($value, '~(?:[\\\\]?+[a-z_\\x80-\\xFF][0-9a-z_\\x80-\\xFF-]*+)++~Asi');
1589+
$result = Strings::match($value, '~^(?:[\\\\]?+[a-z_\\x80-\\xFF][0-9a-z_\\x80-\\xFF-]*+)++$~si');
15901590

15911591
return $result !== null;
15921592
}

tests/PHPStan/Type/TypeToPhpDocNodeTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,15 @@ public function dataToPhpDocNode(): iterable
7373
"array{'1100-RB': 1}",
7474
];
7575

76+
yield [
77+
new ConstantArrayType([
78+
new ConstantStringType('Karlovy Vary'),
79+
], [
80+
new ConstantIntegerType(1),
81+
], [0]),
82+
"array{'Karlovy Vary': 1}",
83+
];
84+
7685
yield [
7786
new ObjectShapeType([
7887
'1100-RB' => new ConstantIntegerType(1),

0 commit comments

Comments
 (0)