@@ -35,11 +35,11 @@ protected function validate(Collection $collection): Collection
3535 $ messages
3636 );
3737
38- if (! $ validator ->fails ()) {
38+ if (!$ validator ->fails ()) {
3939 return $ collection ;
4040 }
4141
42- $ inputErrors = $ collection ->mapWithKeys (fn (InputReflection $ reflection ) => [
42+ $ inputErrors = $ collection ->mapWithKeys (fn (InputReflection $ reflection ) => [
4343 $ reflection ->getName () => new InputErrorData (
4444 key: $ reflection ->getName (),
4545 choices: $ choices [$ reflection ->getName ()] ?? [],
@@ -56,7 +56,7 @@ protected function validate(Collection $collection): Collection
5656 */
5757 protected function extractValidationData (Collection $ collection ): array
5858 {
59- return $ collection ->reduce (fn (array $ carry , InputReflection $ reflection ) => [
59+ return $ collection ->reduce (fn (array $ carry , InputReflection $ reflection ) => [
6060 'values ' => [...$ carry ['values ' ], ...$ this ->extractInputValues ($ reflection )],
6161 'rules ' => [...$ carry ['rules ' ], ...$ this ->extractInputRules ($ reflection )],
6262 'messages ' => [...$ carry ['messages ' ], ...$ this ->extractValidationMessages ($ reflection )],
@@ -71,12 +71,12 @@ protected function extractValidationData(Collection $collection): array
7171
7272 protected function extractValidationMessages (InputReflection $ reflection ): array
7373 {
74- if (! $ reflection ->getValidationMessage ()) {
74+ if (!$ reflection ->getValidationMessage ()) {
7575 return [];
7676 }
7777
7878 return collect ($ reflection ->getValidationMessage ())
79- ->mapWithKeys (fn (string $ value , string $ key ) => ["{$ reflection ->getName ()}. {$ key }" => $ value ])
79+ ->mapWithKeys (fn (string $ value , string $ key ) => ["{$ reflection ->getName ()}. {$ key }" => $ value ])
8080 ->all ();
8181 }
8282
@@ -98,7 +98,7 @@ protected function extractInputRules(
9898 ): array {
9999 $ rules = [];
100100
101- if ($ this ->hasAutoAskEnabled ($ reflection ) && ! $ reflection ->isArray ()) {
101+ if ($ this ->hasAutoAskEnabled ($ reflection ) && !$ reflection ->isArray ()) {
102102 $ rules [] = 'required ' ;
103103 }
104104
@@ -129,7 +129,12 @@ protected function hasAutoAskEnabled(InputReflection $reflection): bool
129129 ConsoleInputType::Argument => $ reflection ->isAutoAskEnabled (),
130130 ConsoleInputType::Option => $ reflection ->isAutoAskEnabled ()
131131 && $ reflection ->hasRequiredValue ()
132- && $ this -> option ($ reflection ->getName ()) !== ' $__not_provided__$ ' ,
132+ && array_key_exists ($ reflection ->getName (), $ this -> getSpecifiedOptions ()) ,
133133 };
134134 }
135+
136+ protected function getSpecifiedOptions (): array
137+ {
138+ return (new \ReflectionClass ($ this ->input ))->getProperty ('options ' )->getValue ($ this ->input );
139+ }
135140}
0 commit comments