11<?php namespace lang \ast \syntax \php ;
22
3+ use lang \ast \Code ;
34use lang \ast \nodes \{
45 Assignment ,
56 ClassDeclaration ,
1314 Variable
1415};
1516use lang \ast \syntax \Extension ;
16- use lang \ast \types \IsArray ;
17- use lang \ast \{Code , Type };
17+ use lang \ast \types \{IsArray , IsLiteral };
1818
1919class Records implements Extension {
2020
@@ -89,7 +89,7 @@ public function setup($language, $emitter) {
8989 $ constructor ->body []= new Assignment ($ r , '= ' , new Variable ($ c ->name , $ l ), $ l );
9090
9191 // Property declaration + accessor method
92- $ type = $ c ->variadic ? ($ c ->type ? new IsArray ($ c ->type ) : new Type ('array ' )) : $ c ->type ;
92+ $ type = $ c ->variadic ? ($ c ->type ? new IsArray ($ c ->type ) : new IsLiteral ('array ' )) : $ c ->type ;
9393 $ body []= new Property ([$ modifiers ], $ c ->name , $ type , null , [], null , $ l );
9494 $ body []= new Method (['public ' ], $ c ->name , new Signature ([], $ type ), [new ReturnStatement ($ r , $ l )]);
9595
@@ -109,13 +109,13 @@ public function setup($language, $emitter) {
109109 $ body ['__construct() ' ]= $ constructor ;
110110
111111 // Implement lang.Value
112- self ::inject ($ body , 'toString ' , new Signature ([], new Type ('string ' )), new Code (
112+ self ::inject ($ body , 'toString ' , new Signature ([], new IsLiteral ('string ' )), new Code (
113113 '" ' .strtr (substr ($ node ->name , 1 ), '\\' , '. ' ).'( ' .substr ($ string , 2 ).')" '
114114 ));
115- self ::inject ($ body , 'hashCode ' , new Signature ([], new Type ('string ' )), new Code (
115+ self ::inject ($ body , 'hashCode ' , new Signature ([], new IsLiteral ('string ' )), new Code (
116116 'md5( \\util \\Objects::hashOf([" ' .substr ($ node ->name , 1 ).'" ' .$ object .'])) '
117117 ));
118- self ::inject ($ body , 'compareTo ' , new Signature ([new Parameter ('value ' , null )], new Type ('int ' )), new Code (
118+ self ::inject ($ body , 'compareTo ' , new Signature ([new Parameter ('value ' , null )], new IsLiteral ('int ' )), new Code (
119119 '$value instanceof self ? \\util \\Objects::compare([ ' .substr ($ object , 2 ).'], [ ' .substr ($ value , 2 ).']) : 1 '
120120 ));
121121
0 commit comments