Skip to content

Commit

Permalink
Add stubs for WP_Widget_Factory (#221)
Browse files Browse the repository at this point in the history
  • Loading branch information
IanDelMar committed Sep 12, 2024
1 parent 90de094 commit db22bf0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions functionMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,7 @@
'WP_Translations::translate' => ['($singular is null ? null : string)'],
'WP_Translations::translate_plural' => ['($singular is null ? null : ($plural is null ? T : string))', '@phpstan-template T' => 'of string|null', 'singular' => 'T', 'count' => 'int'],
'WP_Query' => [null, '@phpstan-property-read bool $query_vars_changed' => '', '@phpstan-property-read bool|string $query_vars_hash' => '', '@phpstan-method void init_query_flags()' => ''],
'WP_Widget_Factory::$widgets' => [null, '@phpstan-var' => 'array<string, \WP_Widget>'],
'WP_Widget_Factory::register' => [null, 'widget' => 'class-string<\WP_Widget>|\WP_Widget'],
'WP_Widget_Factory::unregister' => [null, 'widget' => 'class-string<\WP_Widget>|\WP_Widget'],
];
1 change: 1 addition & 0 deletions tests/TypeInferenceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public function dataFileAsserts(): iterable
yield from $this->gatherAssertTypes(__DIR__ . '/data/wp_tag_cloud.php');
yield from $this->gatherAssertTypes(__DIR__ . '/data/wp_theme.php');
yield from $this->gatherAssertTypes(__DIR__ . '/data/wp_translations.php');
yield from $this->gatherAssertTypes(__DIR__ . '/data/wp_widget_factory.php');
yield from $this->gatherAssertTypes(__DIR__ . '/data/wpdb.php');
}

Expand Down
13 changes: 13 additions & 0 deletions tests/data/wp_widget_factory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

namespace PhpStubs\WordPress\Core\Tests;

use WP_Widget_Factory;

use function PHPStan\Testing\assertType;

$factory = new WP_Widget_Factory();

assertType('array<string, WP_Widget>', $factory->widgets);
3 changes: 3 additions & 0 deletions wordpress-stubs.php
Original file line number Diff line number Diff line change
Expand Up @@ -56518,6 +56518,7 @@ class WP_Widget_Factory
*
* @since 2.8.0
* @var array
* @phpstan-var array<string, \WP_Widget>
*/
public $widgets = array();
/**
Expand Down Expand Up @@ -56547,6 +56548,7 @@ public function WP_Widget_Factory()
* instead of simply a `WP_Widget` subclass name.
*
* @param string|WP_Widget $widget Either the name of a `WP_Widget` subclass or an instance of a `WP_Widget` subclass.
* @phpstan-param class-string<\WP_Widget>|\WP_Widget $widget
*/
public function register($widget)
{
Expand All @@ -56559,6 +56561,7 @@ public function register($widget)
* instead of simply a `WP_Widget` subclass name.
*
* @param string|WP_Widget $widget Either the name of a `WP_Widget` subclass or an instance of a `WP_Widget` subclass.
* @phpstan-param class-string<\WP_Widget>|\WP_Widget $widget
*/
public function unregister($widget)
{
Expand Down

0 comments on commit db22bf0

Please sign in to comment.