* @template DEFAULTS of array, mixed> */ trait Instance { /** * The current widget instance * * @phpstan-var \Required> * * @var array */ protected array $widget_settings; /** * Store the instance to this class. * We do this manually because filters hit the instance before we * get to self::form() and self::widget() * * @see \WP_Widget::form_callback() * * @phpstan-param SETTINGS $instance * @phpstan-param DEFAULTS $defaults * * @param array $instance - widget settings. * @param array $defaults - defaults for all widgets. * * @phpstan-return \Required> * @return array */ public function set_instance( array $instance, array $defaults ): array { $this->widget_settings = \array_merge( $defaults, $instance ); return $this->widget_settings; } }