diff --git a/functionMap.php b/functionMap.php index 17f0291..f109857 100644 --- a/functionMap.php +++ b/functionMap.php @@ -192,4 +192,5 @@ 'size_format' => ["(\$bytes is not numeric ? false : (\$bytes is negative-int|'0' ? false : string))"], '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()' => ''], ]; diff --git a/tests/TypeInferenceTest.php b/tests/TypeInferenceTest.php index b2edf2f..3d827e5 100644 --- a/tests/TypeInferenceTest.php +++ b/tests/TypeInferenceTest.php @@ -55,6 +55,7 @@ public function dataFileAsserts(): iterable yield from $this->gatherAssertTypes(__DIR__ . '/data/wp_list_categories.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/wp_list_pages.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/wp_parse_list.php'); + yield from $this->gatherAssertTypes(__DIR__ . '/data/wp_query.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/wp_rest_request.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/wp_tag_cloud.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/wp_theme.php'); diff --git a/tests/data/wp_query.php b/tests/data/wp_query.php new file mode 100644 index 0000000..bdfed51 --- /dev/null +++ b/tests/data/wp_query.php @@ -0,0 +1,14 @@ +query_vars_changed); +assertType('string|bool', $wpQuery->$query_vars_hash); +assertType('void', $wpQuery->init_query_flags()); diff --git a/wordpress-stubs.php b/wordpress-stubs.php index ef7e231..ec7eaee 100644 --- a/wordpress-stubs.php +++ b/wordpress-stubs.php @@ -46297,6 +46297,9 @@ public function to_array() * * @since 1.5.0 * @since 4.5.0 Removed the `$comments_popup` property. + * @phpstan-property-read bool $query_vars_changed + * @phpstan-property-read bool|string $query_vars_hash + * @phpstan-method void init_query_flags() */ #[\AllowDynamicProperties] class WP_Query