Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix type error in suggest with collection #134

Merged
merged 4 commits into from
Apr 16, 2024

Conversation

macocci7
Copy link
Contributor

This PR fixes the bug below:

running the code below written in the document results in TypeError.

$name = suggest(
    'What is your name?',
    fn ($value) => collect(['Taylor', 'Dayle'])
        ->filter(fn ($name) => Str::contains($name, $value, ignoreCase: true))
)

laravel_prompts_suggest_type_error

Because ($this->options)($this->value()) in line 94 of Laravel/Prompts/SuggestPrompt returns Collection in this case, and it is passed as a parameter of array_values().

@taylorotwell taylorotwell marked this pull request as draft April 15, 2024 15:13
@jessarcher jessarcher marked this pull request as ready for review April 15, 2024 23:54
@taylorotwell taylorotwell merged commit 0ab75ac into laravel:main Apr 16, 2024
4 checks passed
@macocci7 macocci7 deleted the fix/type-error-in-suggest branch April 17, 2024 03:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants