Skip to content

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

Closed
laravel/vs-code-php-parser-cli
#11
@Julien-Suarez

Description

@Julien-Suarez

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 [
            //
        ];
    }
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions