@@ -283,7 +283,7 @@ public function nodeVisitorsFromNative(string $name, TypeSet ...$typeSets): arra
283283 ($ this ->classNameFilter )($ typeName )
284284 );
285285
286- $ nodeVisitors [] = new ClassMethod ($ this ->methodFromArray ($ name , $ typeName , 'from ' . $ typeMethod ));
286+ $ nodeVisitors [] = new ClassMethod ($ this ->methodFromArray ($ name , $ typeName , 'from ' . $ typeMethod, \lcfirst ( $ typeMethod ) ));
287287 $ nodeVisitors [] = new ClassMethod ($ this ->methodFromItems ($ name , $ typeName ));
288288 $ nodeVisitors [] = new ClassMethod ($ this ->methodEmptyList ());
289289 $ nodeVisitors [] = new ClassMethod ($ this ->methodMagicConstruct ($ name , $ name , $ typeName ));
@@ -319,7 +319,7 @@ public function classBuilderFromNative(string $name, TypeSet ...$typeSets): Clas
319319 ($ this ->classNameFilter )($ typeName )
320320 );
321321 $ classBuilder ->addMethod (
322- ClassMethodBuilder::fromNode ($ this ->methodFromArray ($ name , $ typeName , 'from ' . $ typeMethod )->generate ()),
322+ ClassMethodBuilder::fromNode ($ this ->methodFromArray ($ name , $ typeName , 'from ' . $ typeMethod, \lcfirst ( $ typeMethod ) )->generate ()),
323323 ClassMethodBuilder::fromNode ($ this ->methodFromItems ($ name , $ typeName )->generate ()),
324324 ClassMethodBuilder::fromNode ($ this ->methodEmptyList ()->generate ()),
325325 ClassMethodBuilder::fromNode ($ this ->methodMagicConstruct ($ name , $ name , $ typeName )->generate ()),
@@ -590,10 +590,11 @@ public function methodToArray(
590590 public function methodFromArray (
591591 string $ argumentName ,
592592 string $ typeName ,
593- string $ typeMethod = 'fromString '
593+ string $ typeMethod = 'fromString ' ,
594+ string $ type = 'string '
594595 ): MethodGenerator {
595596 $ body = <<<'PHP'
596- return new self(...array_map(static function (string $item) {
597+ return new self(...array_map(static function (%s $item) {
597598 return %s::%s($item);
598599 }, $%s));
599600PHP;
@@ -606,7 +607,7 @@ public function methodFromArray(
606607 new ParameterGenerator ($ argumentName , 'array ' ),
607608 ],
608609 MethodGenerator::FLAG_PUBLIC | MethodGenerator::FLAG_STATIC ,
609- new BodyGenerator ($ this ->parser , \sprintf ($ body , $ typeName , $ typeMethod , $ argumentName ))
610+ new BodyGenerator ($ this ->parser , \sprintf ($ body , $ type , $ typeName , $ typeMethod , $ argumentName ))
610611 );
611612 $ method ->setTyped ($ this ->typed );
612613 $ method ->setReturnType ('self ' );
0 commit comments