@@ -23,6 +23,7 @@ class Option
23
23
private const ALLOWED_TYPES = ['string ' , 'bool ' , 'int ' , 'float ' , 'array ' ];
24
24
25
25
private string |bool |int |float |array |null $ default = null ;
26
+ private array |\Closure $ suggestedValues ;
26
27
private ?int $ mode = null ;
27
28
private string $ typeName = '' ;
28
29
private bool $ allowNull = false ;
@@ -32,18 +33,16 @@ class Option
32
33
*
33
34
* If unset, the `name` value will be inferred from the parameter definition.
34
35
*
35
- * @param array|string|null $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts
36
- * @param array<string|Suggestion>|callable-string (CompletionInput):list<string|Suggestion> $suggestedValues The values used for input completion
36
+ * @param array|string|null $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts
37
+ * @param array<string|Suggestion>|callable(CompletionInput):list<string|Suggestion> $suggestedValues The values used for input completion
37
38
*/
38
39
public function __construct (
39
40
public string $ name = '' ,
40
41
public array |string |null $ shortcut = null ,
41
42
public string $ description = '' ,
42
- public array |string $ suggestedValues = [],
43
+ array |callable $ suggestedValues = [],
43
44
) {
44
- if (\is_string ($ suggestedValues ) && !\is_callable ($ suggestedValues )) {
45
- throw new \TypeError (\sprintf ('Argument 5 passed to "%s()" must be either an array or a callable-string. ' , __METHOD__ ));
46
- }
45
+ $ this ->suggestedValues = \is_callable ($ suggestedValues ) ? $ suggestedValues (...) : $ suggestedValues ;
47
46
}
48
47
49
48
/**
0 commit comments