Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add stubs for WP_Widget_Factory #221

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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