@@ -283,7 +283,7 @@ public function nodeVisitorsFromNative(string $name, TypeSet ...$typeSets): arra
283
283
($ this ->classNameFilter )($ typeName )
284
284
);
285
285
286
- $ nodeVisitors [] = new ClassMethod ($ this ->methodFromArray ($ name , $ typeName , 'from ' . $ typeMethod ));
286
+ $ nodeVisitors [] = new ClassMethod ($ this ->methodFromArray ($ name , $ typeName , 'from ' . $ typeMethod, \lcfirst ( $ typeMethod ) ));
287
287
$ nodeVisitors [] = new ClassMethod ($ this ->methodFromItems ($ name , $ typeName ));
288
288
$ nodeVisitors [] = new ClassMethod ($ this ->methodEmptyList ());
289
289
$ nodeVisitors [] = new ClassMethod ($ this ->methodMagicConstruct ($ name , $ name , $ typeName ));
@@ -319,7 +319,7 @@ public function classBuilderFromNative(string $name, TypeSet ...$typeSets): Clas
319
319
($ this ->classNameFilter )($ typeName )
320
320
);
321
321
$ classBuilder ->addMethod (
322
- ClassMethodBuilder::fromNode ($ this ->methodFromArray ($ name , $ typeName , 'from ' . $ typeMethod )->generate ()),
322
+ ClassMethodBuilder::fromNode ($ this ->methodFromArray ($ name , $ typeName , 'from ' . $ typeMethod, \lcfirst ( $ typeMethod ) )->generate ()),
323
323
ClassMethodBuilder::fromNode ($ this ->methodFromItems ($ name , $ typeName )->generate ()),
324
324
ClassMethodBuilder::fromNode ($ this ->methodEmptyList ()->generate ()),
325
325
ClassMethodBuilder::fromNode ($ this ->methodMagicConstruct ($ name , $ name , $ typeName )->generate ()),
@@ -590,10 +590,11 @@ public function methodToArray(
590
590
public function methodFromArray (
591
591
string $ argumentName ,
592
592
string $ typeName ,
593
- string $ typeMethod = 'fromString '
593
+ string $ typeMethod = 'fromString ' ,
594
+ string $ type = 'string '
594
595
): MethodGenerator {
595
596
$ body = <<<'PHP'
596
- return new self(...array_map(static function (string $item) {
597
+ return new self(...array_map(static function (%s $item) {
597
598
return %s::%s($item);
598
599
}, $%s));
599
600
PHP;
@@ -606,7 +607,7 @@ public function methodFromArray(
606
607
new ParameterGenerator ($ argumentName , 'array ' ),
607
608
],
608
609
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 ))
610
611
);
611
612
$ method ->setTyped ($ this ->typed );
612
613
$ method ->setReturnType ('self ' );
0 commit comments