@@ -98,11 +98,11 @@ public function add(string $name, array $data): self
9898 * Prompt line, directly prompt line without data
9999 *
100100 * @param array $row
101- * @return string|array|bool|int
101+ * @return mixed
102102 * @throws PromptException
103103 * @throws Exception
104104 */
105- public function promptLine (array $ row ): string | array | bool | int
105+ public function promptLine (array $ row ): mixed
106106 {
107107 $ input = false ;
108108 $ default = $ row ['default ' ] ?? "" ;
@@ -113,7 +113,7 @@ public function promptLine(array $row): string|array|bool|int
113113 $ rowType = $ row ['type ' ] ?? "text " ;
114114 $ confirm = $ row ['confirm ' ] ?? false ;
115115
116- if (isset ($ default ) && is_string ($ default )) {
116+ if (isset ($ default ) && is_string ($ default ) && strlen ( $ default ) ) {
117117 $ message .= " ( $ default) " ;
118118 }
119119
@@ -177,10 +177,7 @@ public function promptLine(array $row): string|array|bool|int
177177 if ($ this ->isEmpty ($ input )) {
178178 $ input = $ default ;
179179 }
180-
181- if (!(is_array ($ input ) || is_string ($ input ))) {
182- throw new InvalidArgumentException ("The input item is wrong input data type " , 1 );
183- }
180+
184181 if (!(is_array ($ validate ) || is_callable ($ validate ))) {
185182 throw new InvalidArgumentException ("The validate item is wrong input data type " , 1 );
186183 }
@@ -270,15 +267,14 @@ protected function isEmpty(mixed $input): bool
270267 * Validate a set of items
271268 *
272269 * @param array|callable $validate
273- * @param string|array $input
274- * @param array|null $error
275- * @param-out null|string $error Error message or method that caused validation failure.
270+ * @param mixed $input
271+ * @param string|null $error
276272 * @return bool
277273 * @throws ErrorException
278274 */
279- protected function validateItems (array |callable $ validate , string | array $ input , ?array &$ error = [] ): bool
275+ protected function validateItems (array |callable $ validate , mixed $ input , ?string &$ error = "" ): bool
280276 {
281- $ input = is_string ( $ input ) ? [$ input ] : $ input ;
277+ $ input = (! is_array ( $ input) ) ? [$ input ] : $ input ;
282278 foreach ($ input as $ value ) {
283279 if (is_callable ($ validate )) {
284280 $ isValid = $ validate ($ value );
0 commit comments