wordpress-stubs icon indicating copy to clipboard operation
wordpress-stubs copied to clipboard

Support template for WP_Widget settings

Open lipemat opened this issue 1 year ago • 0 comments

The WP_Widget class supports passing an "$instance" array around which contains the value of the current widget settings.

Without a PHPStan template, adding a type to the $instance array results in warnings like "should be contravariant with parameter" for the following methods:

  • form
  • update
  • widget

Having a template available allows using @extends to pass the array shape around.

As a bonus, this pull request also includes the full shape of the $args passed to WP_Widget::widget

lipemat avatar Feb 13 '24 00:02 lipemat