Skip to content

Commit 3ef7a31

Browse files
committed
Fix offset access builder using non named type keys
1 parent be584e7 commit 3ef7a31

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

resources/grammar.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -705,15 +705,18 @@
705705
$statement = new Node\Stmt\TypesListNode($statement);
706706
break;
707707
// In case of offset access type
708-
case $child instanceof Node\Stmt\NamedTypeNode:
708+
case $child instanceof Node\Stmt\TypeStatement:
709709
if ($this->offsets === false) {
710710
throw FeatureNotAllowedException::fromFeature('square bracket type offsets', $offset);
711711
}
712712

713713
$statement = new Node\Stmt\TypeOffsetAccessNode($statement, $child);
714714
break;
715715
default:
716-
throw new SemanticException($offset, 'Unexpected square bracket node type');
716+
throw new SemanticException($offset, \sprintf(
717+
'Internal error, unexpected square bracket sub-node %s',
718+
\get_debug_type($child),
719+
));
717720
}
718721
}
719722

resources/grammar.pp2

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,18 @@ TypesList -> {
133133
$statement = new Node\Stmt\TypesListNode($statement);
134134
break;
135135
// In case of offset access type
136-
case $child instanceof Node\Stmt\NamedTypeNode:
136+
case $child instanceof Node\Stmt\TypeStatement:
137137
if ($this->offsets === false) {
138138
throw FeatureNotAllowedException::fromFeature('square bracket type offsets', $offset);
139139
}
140140

141141
$statement = new Node\Stmt\TypeOffsetAccessNode($statement, $child);
142142
break;
143143
default:
144-
throw new SemanticException($offset, 'Unexpected square bracket node type');
144+
throw new SemanticException($offset, \sprintf(
145+
'Internal error, unexpected square bracket sub-node %s',
146+
\get_debug_type($child),
147+
));
145148
}
146149
}
147150

0 commit comments

Comments
 (0)