Skip to content

[Bug]: Using FormRequest's route() function generates an erroneous warning #236

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

Closed
Julien-Suarez opened this issue Feb 5, 2025 · 0 comments · Fixed by laravel/vs-code-php-parser-cli#11
Assignees
Labels

Comments

@Julien-Suarez
Copy link

Extension Version

0.1.18

PHP Binary

Docker

Operating System

Windows

What happened?

Trying to get a route parameter via a FormRequest's route() function generate an erroneous warning, I believe the extension thinks the code is trying to use Laravel's global route() helper.

Image

Mimimal Code Sample

// routes/api.php
Route::apiResource('/clients', ClientController::class);

// app/Http/Controllers/ClientController.php
public function show(ClientShowRequest $request, Client $client)
{
    return $client;
}

// app/Http/Requests/ClientShowRequest.php
class ClientShowRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        $client = $this->route('client');
        return $this->user()->can('viewClient', $client);
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        return [
            //
        ];
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants