@@ -49,7 +49,12 @@ private function createArgumentParams(array $commandArguments): array
4949 foreach ($ commandArguments as $ commandArgument ) {
5050 $ variableName = $ this ->createCamelCase ($ commandArgument ->getNameValue ());
5151 $ argumentParam = new Param (new Variable ($ variableName ));
52- $ argumentParam ->type = new Identifier ('string ' );
52+
53+ if ($ commandArgument ->isArray ()) {
54+ $ argumentParam ->type = new Identifier ('array ' );
55+ } else {
56+ $ argumentParam ->type = new Identifier ('string ' );
57+ }
5358
5459 if ($ commandArgument ->getDefault () instanceof Expr) {
5560 $ argumentParam ->default = $ commandArgument ->getDefault ();
@@ -63,7 +68,7 @@ private function createArgumentParams(array $commandArguments): array
6368
6469 $ argumentArgs = [new Arg (value: $ commandArgument ->getName (), name: new Identifier ('name ' ))];
6570
66- if ($ this ->hasUsefulDescription ($ commandArgument )) {
71+ if ($ this ->isNonEmptyExpr ($ commandArgument-> getDescription () )) {
6772 $ argumentArgs [] = new Arg (value: $ commandArgument ->getDescription (), name: new Identifier (
6873 'description '
6974 ));
@@ -97,19 +102,15 @@ private function createOptionParams(array $commandOptions): array
97102
98103 $ optionArgs = [new Arg (value: $ commandOption ->getName (), name: new Identifier ('name ' ))];
99104
100- if ($ commandOption ->getShortcut () instanceof Expr && ! $ this ->valueResolver ->isNull (
101- $ commandOption ->getShortcut ()
102- )) {
105+ if ($ this ->isNonEmptyExpr ($ commandOption ->getShortcut ())) {
103106 $ optionArgs [] = new Arg (value: $ commandOption ->getShortcut (), name: new Identifier ('shortcut ' ));
104107 }
105108
106- if ($ commandOption ->getMode () instanceof Expr && ! $ this ->valueResolver ->isNull (
107- $ commandOption ->getMode ()
108- )) {
109+ if ($ this ->isNonEmptyExpr ($ commandOption ->getMode ())) {
109110 $ optionArgs [] = new Arg (value: $ commandOption ->getMode (), name: new Identifier ('mode ' ));
110111 }
111112
112- if ($ this ->hasUsefulDescription ($ commandOption )) {
113+ if ($ this ->isNonEmptyExpr ($ commandOption-> getDescription () )) {
113114 $ optionArgs [] = new Arg (value: $ commandOption ->getDescription (), name: new Identifier ('description ' ));
114115 }
115116
@@ -135,26 +136,25 @@ private function createCamelCase(string $value): string
135136 return lcfirst ($ value );
136137 }
137138
138- private function hasUsefulDescription (CommandArgument |CommandOption $ commandArgumentOrOption ): bool
139+ private function isOptionalArgument (CommandArgument $ commandArgument ): bool
140+ {
141+ if (! $ commandArgument ->getMode () instanceof Expr) {
142+ return true ;
143+ }
144+
145+ return $ this ->valueResolver ->isValue ($ commandArgument ->getMode (), 2 );
146+ }
147+
148+ private function isNonEmptyExpr (?Expr $ expr ): bool
139149 {
140- if (! $ commandArgumentOrOption -> getDescription () instanceof Expr) {
150+ if (! $ expr instanceof Expr) {
141151 return false ;
142152 }
143153
144- $ expr = $ commandArgumentOrOption ->getDescription ();
145154 if ($ this ->valueResolver ->isNull ($ expr )) {
146155 return false ;
147156 }
148157
149158 return ! $ this ->valueResolver ->isValue ($ expr , '' );
150159 }
151-
152- private function isOptionalArgument (CommandArgument $ commandArgument ): bool
153- {
154- if (! $ commandArgument ->getMode () instanceof Expr) {
155- return true ;
156- }
157-
158- return $ this ->valueResolver ->isValue ($ commandArgument ->getMode (), 2 );
159- }
160160}
0 commit comments