Skip to content

Commit

Permalink
Add __get and __call for WP_Query
Browse files Browse the repository at this point in the history
  • Loading branch information
IanDelMar committed Sep 10, 2024
1 parent 98a5a30 commit 2a81a4d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions functionMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()' => ''],
];
1 change: 1 addition & 0 deletions tests/TypeInferenceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
14 changes: 14 additions & 0 deletions tests/data/wp_query.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

namespace PhpStubs\WordPress\Core\Tests;

use function PHPStan\Testing\assertType;
use WP_Query;

$wpQuery = new WP_Query();

assertType('bool', $wpQuery->query_vars_changed);
assertType('string|bool', $wpQuery->$query_vars_hash);
assertType('void', $wpQuery->init_query_flags());
3 changes: 3 additions & 0 deletions wordpress-stubs.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2a81a4d

Please sign in to comment.