diff --git a/functionMap.php b/functionMap.php index 7b1082e..9464b8b 100644 --- a/functionMap.php +++ b/functionMap.php @@ -87,7 +87,24 @@ 'WP_REST_Request::get_params' => ['T'], 'WP_REST_Request::set_param' => ['void', '@phpstan-template' => 'TOffset of key-of', 'key' => 'TOffset', 'value' => 'T[TOffset]'], 'WP_REST_Request::has_param' => [null, 'key' => 'key-of'], - 'WP_Theme' => [null, '@phpstan-type' => "ThemeKey 'Name'|'Version'|'Status'|'Title'|'Author'|'Author Name'|'Author URI'|'Description'|'Template'|'Stylesheet'|'Template Files'|'Stylesheet Files'|'Template Dir'|'Stylesheet Dir'|'Screenshot'|'Tags'|'Theme Root'|'Theme Root URI'|'Parent Theme'"], + 'WP_Theme' => [ + null, + '@phpstan-type' => "ThemeKey 'Name'|'Version'|'Status'|'Title'|'Author'|'Author Name'|'Author URI'|'Description'|'Template'|'Stylesheet'|'Template Files'|'Stylesheet Files'|'Template Dir'|'Stylesheet Dir'|'Screenshot'|'Tags'|'Theme Root'|'Theme Root URI'|'Parent Theme'", + '@phpstan-property-read string $name' => '', + '@phpstan-property-read string $title' => '', + '@phpstan-property-read string $version' => '', + '@phpstan-property-read string $parent_theme' => '', + '@phpstan-property-read string $template_dir' => '', + '@phpstan-property-read string $stylesheet_dir' => '', + '@phpstan-property-read string $template' => '', + '@phpstan-property-read string $stylesheet' => '', + '@phpstan-property-read string $screenshot' => '', + '@phpstan-property-read string $description' => '', + '@phpstan-property-read string $author' => '', + '@phpstan-property-read list $tags' => '', + '@phpstan-property-read string $theme_root' => '', + '@phpstan-property-read string $theme_root_uri' => '', + ], 'WP_Theme::get' => ["(\$header is 'Name'|'ThemeURI'|'Description'|'Author'|'AuthorURI'|'Version'|'Template'|'Status'|'Tags'|'TextDomain'|'DomainPath'|'RequiresWP'|'RequiresPHP'|'UpdateURI' ? (\$header is 'Tags' ? string[] : string) : false)"], 'WP_Theme::offsetExists' => ['($offset is ThemeKey ? true : false)'], 'WP_Theme::offsetGet' => ['($offset is ThemeKey ? mixed : null)'], diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 6ebf26a..cae5645 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -29,6 +29,9 @@ tests/ + + tests/ + tests/ diff --git a/tests/data/wp_theme.php b/tests/data/wp_theme.php index 134d96c..ed0d0b7 100644 --- a/tests/data/wp_theme.php +++ b/tests/data/wp_theme.php @@ -7,7 +7,24 @@ use function PHPStan\Testing\assertType; /** @var \WP_Theme */ -$theme = $theme; +$theme = $_GET['theme']; + +// WP_Theme::__get() +assertType('string', $theme->name); +assertType('string', $theme->title); +assertType('string', $theme->version); +assertType('string', $theme->parent_theme); +assertType('string', $theme->template_dir); +assertType('string', $theme->stylesheet_dir); +assertType('string', $theme->template); +assertType('string', $theme->stylesheet); +assertType('string', $theme->screenshot); +assertType('string', $theme->description); +assertType('string', $theme->author); +assertType('list', $theme->tags); +assertType('string', $theme->theme_root); +assertType('string', $theme->theme_root_uri); +assertType('*ERROR*', $theme->unknown_property); // WP_Theme::get() assertType('string', $theme->get('Name')); diff --git a/wordpress-stubs.php b/wordpress-stubs.php index b4e8cfc..14cd5f6 100644 --- a/wordpress-stubs.php +++ b/wordpress-stubs.php @@ -54509,6 +54509,20 @@ protected static function get_valid_block_style_variations() * @subpackage Theme * @since 3.4.0 * @phpstan-type ThemeKey 'Name'|'Version'|'Status'|'Title'|'Author'|'Author Name'|'Author URI'|'Description'|'Template'|'Stylesheet'|'Template Files'|'Stylesheet Files'|'Template Dir'|'Stylesheet Dir'|'Screenshot'|'Tags'|'Theme Root'|'Theme Root URI'|'Parent Theme' + * @phpstan-property-read string $name + * @phpstan-property-read string $title + * @phpstan-property-read string $version + * @phpstan-property-read string $parent_theme + * @phpstan-property-read string $template_dir + * @phpstan-property-read string $stylesheet_dir + * @phpstan-property-read string $template + * @phpstan-property-read string $stylesheet + * @phpstan-property-read string $screenshot + * @phpstan-property-read string $description + * @phpstan-property-read string $author + * @phpstan-property-read list $tags + * @phpstan-property-read string $theme_root + * @phpstan-property-read string $theme_root_uri */ #[\AllowDynamicProperties] final class WP_Theme implements \ArrayAccess