@@ -102,7 +102,7 @@ abstract class AbstractFlag implements ArrayAccess, FlagInterface
102102 * @param string $name
103103 * @param string $desc
104104 * @param string $type
105- * @param bool $required
105+ * @param bool $required
106106 * @param mixed|null $default
107107 *
108108 * @return static
@@ -121,7 +121,7 @@ public static function new(
121121 * Create by array define
122122 *
123123 * @param string $name
124- * @param array $define
124+ * @param array $define
125125 *
126126 * @return static
127127 */
@@ -142,7 +142,7 @@ public static function newByArray(string $name, array $define): static
142142 * @param string $name
143143 * @param string $desc
144144 * @param string $type
145- * @param bool $required
145+ * @param bool $required
146146 * @param mixed|null $default The default value
147147 * - for Flag::ARG_OPTIONAL mode only
148148 * - must be null for Flag::OPT_BOOLEAN
@@ -354,14 +354,15 @@ public function setDesc(string $desc): void
354354 public function toArray (): array
355355 {
356356 return [
357- 'name ' => $ this ->name ,
358- 'desc ' => $ this ->desc ,
359- 'type ' => $ this ->type ,
360- 'default ' => $ this ->default ,
361- 'envVar ' => $ this ->envVar ,
362- 'required ' => $ this ->required ,
363- 'isArray ' => $ this ->isArray (),
364- 'helpType ' => $ this ->getHelpType (),
357+ 'name ' => $ this ->name ,
358+ 'desc ' => $ this ->desc ,
359+ 'type ' => $ this ->type ,
360+ 'default ' => $ this ->default ,
361+ 'envVar ' => $ this ->envVar ,
362+ 'required ' => $ this ->required ,
363+ 'validator ' => $ this ->validator ,
364+ 'isArray ' => $ this ->isArray (),
365+ 'helpType ' => $ this ->getHelpType (),
365366 ];
366367 }
367368
@@ -431,6 +432,14 @@ public function setValidator(?callable $validator): void
431432 }
432433 }
433434
435+ /**
436+ * @return callable|ValidatorInterface|null
437+ */
438+ public function getValidator (): callable |ValidatorInterface |null
439+ {
440+ return $ this ->validator ;
441+ }
442+
434443 /**
435444 * @return string
436445 */
0 commit comments