@@ -63,7 +63,7 @@ private function createArgumentParams(array $commandArguments): array
6363
6464 $ argumentArgs = [new Arg (value: $ commandArgument ->getName (), name: new Identifier ('name ' ))];
6565
66- if ($ this ->hasUsefulDescription ($ commandArgument )) {
66+ if ($ this ->isNonEmptyExpr ($ commandArgument-> getDescription () )) {
6767 $ argumentArgs [] = new Arg (value: $ commandArgument ->getDescription (), name: new Identifier (
6868 'description '
6969 ));
@@ -97,19 +97,15 @@ private function createOptionParams(array $commandOptions): array
9797
9898 $ optionArgs = [new Arg (value: $ commandOption ->getName (), name: new Identifier ('name ' ))];
9999
100- if ($ commandOption ->getShortcut () instanceof Expr && ! $ this ->valueResolver ->isNull (
101- $ commandOption ->getShortcut ()
102- )) {
100+ if ($ this ->isNonEmptyExpr ($ commandOption ->getShortcut ())) {
103101 $ optionArgs [] = new Arg (value: $ commandOption ->getShortcut (), name: new Identifier ('shortcut ' ));
104102 }
105103
106- if ($ commandOption ->getMode () instanceof Expr && ! $ this ->valueResolver ->isNull (
107- $ commandOption ->getMode ()
108- )) {
104+ if ($ this ->isNonEmptyExpr ($ commandOption ->getMode ())) {
109105 $ optionArgs [] = new Arg (value: $ commandOption ->getMode (), name: new Identifier ('mode ' ));
110106 }
111107
112- if ($ this ->hasUsefulDescription ($ commandOption )) {
108+ if ($ this ->isNonEmptyExpr ($ commandOption-> getDescription () )) {
113109 $ optionArgs [] = new Arg (value: $ commandOption ->getDescription (), name: new Identifier ('description ' ));
114110 }
115111
@@ -135,26 +131,25 @@ private function createCamelCase(string $value): string
135131 return lcfirst ($ value );
136132 }
137133
138- private function hasUsefulDescription (CommandArgument |CommandOption $ commandArgumentOrOption ): bool
134+ private function isOptionalArgument (CommandArgument $ commandArgument ): bool
135+ {
136+ if (! $ commandArgument ->getMode () instanceof Expr) {
137+ return true ;
138+ }
139+
140+ return $ this ->valueResolver ->isValue ($ commandArgument ->getMode (), 2 );
141+ }
142+
143+ private function isNonEmptyExpr (?Expr $ expr ): bool
139144 {
140- if (! $ commandArgumentOrOption -> getDescription () instanceof Expr) {
145+ if (! $ expr instanceof Expr) {
141146 return false ;
142147 }
143148
144- $ expr = $ commandArgumentOrOption ->getDescription ();
145149 if ($ this ->valueResolver ->isNull ($ expr )) {
146150 return false ;
147151 }
148152
149153 return ! $ this ->valueResolver ->isValue ($ expr , '' );
150154 }
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- }
160155}
0 commit comments