mirror of
https://github.com/symfony/console.git
synced 2026-03-24 01:12:13 +01:00
Improve-callable-typing
This commit is contained in:
@@ -234,7 +234,8 @@ class QuestionHelper extends Helper
|
||||
/**
|
||||
* Autocompletes a question.
|
||||
*
|
||||
* @param resource $inputStream
|
||||
* @param resource $inputStream
|
||||
* @param callable(string):string[] $autocomplete
|
||||
*/
|
||||
private function autocomplete(OutputInterface $output, Question $question, $inputStream, callable $autocomplete): string
|
||||
{
|
||||
|
||||
@@ -24,8 +24,17 @@ class Question
|
||||
private ?int $attempts = null;
|
||||
private bool $hidden = false;
|
||||
private bool $hiddenFallback = true;
|
||||
/**
|
||||
* @var (\Closure(string):string[])|null
|
||||
*/
|
||||
private ?\Closure $autocompleterCallback = null;
|
||||
/**
|
||||
* @var (\Closure(mixed):mixed)|null
|
||||
*/
|
||||
private ?\Closure $validator = null;
|
||||
/**
|
||||
* @var (\Closure(mixed):mixed)|null
|
||||
*/
|
||||
private ?\Closure $normalizer = null;
|
||||
private bool $trimmable = true;
|
||||
private bool $multiline = false;
|
||||
@@ -160,6 +169,8 @@ class Question
|
||||
|
||||
/**
|
||||
* Gets the callback function used for the autocompleter.
|
||||
*
|
||||
* @return (callable(string):string[])|null
|
||||
*/
|
||||
public function getAutocompleterCallback(): ?callable
|
||||
{
|
||||
@@ -171,6 +182,8 @@ class Question
|
||||
*
|
||||
* The callback is passed the user input as argument and should return an iterable of corresponding suggestions.
|
||||
*
|
||||
* @param (callable(string):string[])|null $callback
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setAutocompleterCallback(?callable $callback): static
|
||||
@@ -187,6 +200,8 @@ class Question
|
||||
/**
|
||||
* Sets a validator for the question.
|
||||
*
|
||||
* @param (callable(mixed):mixed)|null $validator
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setValidator(?callable $validator): static
|
||||
@@ -198,6 +213,8 @@ class Question
|
||||
|
||||
/**
|
||||
* Gets the validator for the question.
|
||||
*
|
||||
* @return (callable(mixed):mixed)|null
|
||||
*/
|
||||
public function getValidator(): ?callable
|
||||
{
|
||||
@@ -237,7 +254,7 @@ class Question
|
||||
/**
|
||||
* Sets a normalizer for the response.
|
||||
*
|
||||
* The normalizer can be a callable (a string), a closure or a class implementing __invoke.
|
||||
* @param callable(mixed):mixed $normalizer
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
@@ -251,7 +268,7 @@ class Question
|
||||
/**
|
||||
* Gets the normalizer for the response.
|
||||
*
|
||||
* The normalizer can ba a callable (a string), a closure or a class implementing __invoke.
|
||||
* @return (callable(mixed):mixed)|null
|
||||
*/
|
||||
public function getNormalizer(): ?callable
|
||||
{
|
||||
|
||||
@@ -70,11 +70,15 @@ interface StyleInterface
|
||||
|
||||
/**
|
||||
* Asks a question.
|
||||
*
|
||||
* @param (callable(mixed):mixed)|null $validator
|
||||
*/
|
||||
public function ask(string $question, ?string $default = null, ?callable $validator = null): mixed;
|
||||
|
||||
/**
|
||||
* Asks a question with the user input hidden.
|
||||
*
|
||||
* @param (callable(mixed):mixed)|null $validator
|
||||
*/
|
||||
public function askHidden(string $question, ?callable $validator = null): mixed;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user