Skip to content

Commit 16076b2

Browse files
authored
Bump laravel/prompts to v0.3.5 (#6246)
* Bump laravel/prompts to v0.3.5 See also https://github.com/laravel/prompts/releases/tag/v0.3.5 * Remove usage of Illuminate Collection
1 parent 8aae4e5 commit 16076b2

File tree

3 files changed

+25
-23
lines changed

3 files changed

+25
-23
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"dflydev/dot-access-data": "^3.0.2",
4747
"grasmash/yaml-cli": "^3.1",
4848
"guzzlehttp/guzzle": "^7.0",
49-
"laravel/prompts": "^0.1.21",
49+
"laravel/prompts": "^0.3.5",
5050
"league/container": "^4.2",
5151
"psy/psysh": "~0.12",
5252
"symfony/event-dispatcher": "^6 || ^7",

src-symfony-compatibility/v6/Style/DrushStyle.php

+10-11
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Drush\Style;
44

55
use Drush\Drush;
6-
use Illuminate\Support\Collection;
76
use JetBrains\PhpStorm\Deprecated;
87
use Laravel\Prompts\MultiSearchPrompt;
98
use Laravel\Prompts\MultiSelectPrompt;
@@ -76,40 +75,40 @@ public function password(\Stringable|string $label, \Stringable|string $placehol
7675
/**
7776
* Prompt the user to select an option.
7877
*
79-
* @param array<int|string, string>|Collection<int|string, string> $options
78+
* @param array<int|string, string> $options
8079
* @param true|string $required
8180
*/
82-
public function select(string $label, array|Collection $options, int|string|null $default = null, int $scroll = 10, ?\Closure $validate = null, string $hint = '', bool|string $required = true): int|string
81+
public function select(string $label, array $options, int|string|null $default = null, int $scroll = 10, ?\Closure $validate = null, string $hint = '', bool|string $required = true): int|string
8382
{
8483
return (new SelectPrompt($label, $options, $default, $scroll, $validate, $hint, $required))->prompt();
8584
}
8685

8786
/**
8887
* Prompt the user to select multiple options.
8988
*
90-
* @param array<int|string, string>|Collection<int|string, string> $options
91-
* @param array<int|string>|Collection<int, int|string> $default
89+
* @param array<int|string, string> $options
90+
* @param array<int|string> $default
9291
* @return array<int|string>
9392
*/
94-
public function multiselect(string $label, array|Collection $options, array|Collection $default = [], int $scroll = 10, bool|string $required = false, ?\Closure $validate = null, string $hint = 'Use the space bar to select options.'): array
93+
public function multiselect(string $label, array $options, array $default = [], int $scroll = 10, bool|string $required = false, ?\Closure $validate = null, string $hint = 'Use the space bar to select options.'): array
9594
{
9695
return (new MultiSelectPrompt($label, $options, $default, $scroll, $required, $validate, $hint))->prompt();
9796
}
9897

9998
/**
10099
* Prompt the user for text input with auto-completion.
101100
*
102-
* @param array<string>|Collection<int, string>|Closure(string): array<string> $options
101+
* @param array<string>|\Closure(string): array<string> $options
103102
*/
104-
public function suggest(string $label, array|Collection|\Closure $options, string $placeholder = '', string $default = '', int $scroll = 10, bool|string $required = false, ?\Closure $validate = null, string $hint = 'Start typing the first letter(s) and matching choices will be shown.'): string
103+
public function suggest(string $label, array|\Closure $options, string $placeholder = '', string $default = '', int $scroll = 10, bool|string $required = false, ?\Closure $validate = null, string $hint = 'Start typing the first letter(s) and matching choices will be shown.'): string
105104
{
106105
return (new SuggestPrompt($label, $options, $placeholder, $default, $scroll, $required, $validate, $hint))->prompt();
107106
}
108107

109108
/**
110109
* Allow the user to search for an option.
111110
*
112-
* @param Closure(string): array<int|string, string> $options
111+
* @param \Closure(string): array<int|string, string> $options
113112
* @param true|string $required
114113
*/
115114
public function search(string $label, \Closure $options, string $placeholder = '', int $scroll = 10, ?\Closure $validate = null, string $hint = '', bool|string $required = true): int|string
@@ -120,7 +119,7 @@ public function search(string $label, \Closure $options, string $placeholder = '
120119
/**
121120
* Allow the user to search for multiple option.
122121
*
123-
* @param Closure(string): array<int|string, string> $options
122+
* @param \Closure(string): array<int|string, string> $options
124123
* @return array<int|string>
125124
*/
126125
public function multisearch(string $label, \Closure $options, string $placeholder = '', int $scroll = 10, bool|string $required = false, ?\Closure $validate = null, string $hint = 'Use the space bar to select options.'): array
@@ -148,7 +147,7 @@ public function spin(\Closure $callback, string $message = ''): mixed
148147
* @template TReturn
149148
*
150149
* @param TSteps $steps
151-
* @param ?Closure((TSteps is int ? int : value-of<TSteps>), Progress<TSteps>): TReturn $callback
150+
* @param ?\Closure((TSteps is int ? int : value-of<TSteps>), Progress<TSteps>): TReturn $callback
152151
* @return ($callback is null ? Progress<TSteps> : array<TReturn>)
153152
*/
154153
public function progress(string $label, iterable|int $steps, ?\Closure $callback = null, string $hint = ''): array|Progress

src/Commands/ConfiguresPrompts.php

+14-11
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,11 @@ protected function configurePrompts(InputInterface $input)
8383

8484
return $this->promptUntilValid(
8585
// MW: Had to change to 'none' as key to fix test failure. Deviates from Laravel.
86-
fn () => collect($style->choice($prompt->label, ['none' => 'None', ...$prompt->options], 'none', true))
87-
->reject('none')
88-
->all(),
86+
fn () => array_filter(
87+
$style->choice($prompt->label, ['none' => 'None', ...$prompt->options], 'none', true),
88+
fn ($option, $key) => $key !== 'none',
89+
ARRAY_FILTER_USE_BOTH,
90+
),
8991
$prompt->required,
9092
$prompt->validate
9193
);
@@ -118,16 +120,17 @@ function () use ($prompt) {
118120

119121
if ($prompt->required === false) {
120122
if (array_is_list($options)) {
121-
return collect($style->choice($prompt->label, ['None', ...$options], 'None', true))
122-
->reject('None')
123-
->values()
124-
->all();
123+
return array_filter(
124+
$style->choice($prompt->label, ['None', ...$options], 'None', true),
125+
fn ($option) => $option !== 'None',
126+
);
125127
}
126128

127-
return collect($style->choice($prompt->label, ['' => 'None', ...$options], '', true))
128-
->reject('')
129-
->values()
130-
->all();
129+
return array_filter(
130+
$style->choice($prompt->label, ['' => 'None', ...$options], '', true),
131+
fn ($option, $key) => $key !== '',
132+
ARRAY_FILTER_USE_BOTH,
133+
);
131134
}
132135

133136
return $style->choice($prompt->label, $options, true);

0 commit comments

Comments
 (0)