Skip to content

Conversation

@Nikschavan
Copy link
Contributor

Summary

  • Adds a default value (array<string, mixed>) to the WP_REST_Request generic template

Problem

At PHPStan level 9, any method with a WP_REST_Request parameter that doesn't specify the generic type triggers:

Method MyController::handle_request() has parameter $request with 
generic class WP_REST_Request but does not specify its types: T

Solution

Change the template from:

@phpstan-template T of array

to:

@phpstan-template T of array = array<string, mixed>

This is backward-compatible — explicit type parameters still override the default.

Fixes #408

@szepeviktor
Copy link
Member

Thank you.

@szepeviktor szepeviktor merged commit d6f5132 into php-stubs:master Dec 8, 2025
7 checks passed
@Nikschavan Nikschavan deleted the fix-408 branch December 8, 2025 13:11
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.

Add default value to WP_REST_Request generic template to avoid missingType.generics errors

2 participants