55namespace TypeLang \Printer ;
66
77use TypeLang \Node \Node ;
8- use TypeLang \Node \Statement ;
98use TypeLang \Node \Type \Attribute \AttributeGroupNode ;
109use TypeLang \Node \Type \Attribute \AttributeGroupsListNode ;
1110use TypeLang \Node \Type \Callable \CallableParameterNode ;
2524use TypeLang \Node \Type \LogicalTypeNode ;
2625use TypeLang \Node \Type \NamedTypeNode ;
2726use TypeLang \Node \Type \NullableTypeNode ;
27+ use TypeLang \Node \Type \Shape \ClassConstFieldNode ;
2828use TypeLang \Node \Type \Shape \ClassConstMaskFieldNode ;
2929use TypeLang \Node \Type \Shape \ConstMaskFieldNode ;
3030use TypeLang \Node \Type \Shape \FieldNode ;
@@ -123,7 +123,7 @@ public function __construct(
123123 /**
124124 * @throws NonPrintableNodeException
125125 */
126- protected function make (Statement $ stmt ): string
126+ protected function make (TypeNode $ stmt ): string
127127 {
128128 return match (true ) {
129129 $ stmt instanceof LiteralNode => $ this ->printLiteralNode ($ stmt ),
@@ -282,6 +282,7 @@ protected function printShapeFieldName(FieldNode $field): string
282282 $ field instanceof NamedFieldNode => $ this ->printNamedShapeFieldName ($ field ),
283283 $ field instanceof ConstMaskFieldNode => $ this ->printConstMaskShapeFieldName ($ field ),
284284 $ field instanceof ClassConstMaskFieldNode => $ this ->printClassConstMaskShapeFieldName ($ field ),
285+ $ field instanceof ClassConstFieldNode => $ this ->printClassConstShapeFieldName ($ field ),
285286 default => $ this ->printUnknownShapeFieldName ($ field ),
286287 };
287288 }
@@ -306,20 +307,20 @@ protected function printConstMaskShapeFieldName(ConstMaskFieldNode $field): stri
306307 return $ field ->key ->name ->toString () . '* ' ;
307308 }
308309
310+ protected function printClassConstShapeFieldName (ClassConstFieldNode $ field ): string
311+ {
312+ return \sprintf ('%s::%s ' , $ field ->key ->class , $ field ->key ->constant );
313+ }
314+
309315 protected function printClassConstMaskShapeFieldName (ClassConstMaskFieldNode $ field ): string
310316 {
311- $ class = $ field ->key ->class ;
312317 $ constant = $ field ->key ->constant ;
313318
314- if ($ field ->key instanceof ClassConstNode) {
315- return $ class . ':: ' . $ constant ;
316- }
317-
318319 if ($ constant === null ) {
319- return $ class . ' ::* ' ;
320+ return \sprintf ( ' %s ::* ', $ field -> key -> class ) ;
320321 }
321322
322- return $ class . ' :: ' . $ constant . ' * ' ;
323+ return \sprintf ( ' %s::%s* ' , $ field -> key -> class , $ constant) ;
323324 }
324325
325326 protected function printUnknownShapeFieldName (FieldNode $ field ): string
0 commit comments