Skip to content

Commit db1e23a

Browse files
authored
have_posts() is an impure function (#64)
* `have_posts()` is an impure function. * Sort these functions. * Remove the trailing space. * Address `WP_Query::have_posts()`.
1 parent 601c429 commit db1e23a

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

functionMap.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
return [
1414
'add_meta_box' => ['void', 'context'=>'"normal"|"side"|"advanced"', 'priority'=>'"high"|"core"|"default"|"low"'],
1515
'addslashes_gpc' => ['T', '@phpstan-template'=>'T', 'gpc'=>'T'],
16+
'have_posts' => ['bool', '@phpstan-impure'=>''],
1617
'rawurlencode_deep' => ['T', '@phpstan-template'=>'T', 'value'=>'T'],
1718
'remove_meta_box' => ['void', 'context'=>'"normal"|"side"|"advanced"'],
1819
'sanitize_category' => ['T', '@phpstan-template'=>'T of array|object', 'category'=>'T'],
@@ -32,6 +33,7 @@
3233
'WP_List_Table::display_tablenav' => ['void', 'which'=>'"top"|"bottom"'],
3334
'WP_List_Table::pagination' => ['void', 'which'=>'"top"|"bottom"'],
3435
'wp_next_scheduled' => ['int|false', 'args'=>$cronArgsType],
36+
'WP_Query::have_posts' => ['bool', '@phpstan-impure'=>''],
3537
'wp_remote_get' => [$httpReturnType],
3638
'wp_remote_head' => [$httpReturnType],
3739
'wp_remote_post' => [$httpReturnType],

visitor.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,8 +630,9 @@ private function getAdditionalTagsFromMap(string $symbolName): array
630630

631631
foreach ($parameters as $paramName => $paramType) {
632632
if (strpos($paramName, '@') === 0) {
633+
$format = ( $paramType === '' ) ? '%s' : '%s %s';
633634
$additions[] = sprintf(
634-
'%s %s',
635+
$format,
635636
$paramName,
636637
$paramType
637638
);

wordpress-stubs.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45136,6 +45136,8 @@ public function the_post()
4513645136
* @since 1.5.0
4513745137
*
4513845138
* @return bool True if posts are available, false if end of the loop.
45139+
* @phpstan-impure
45140+
* @phpstan-return bool
4513945141
*/
4514045142
public function have_posts()
4514145143
{
@@ -122372,6 +122374,8 @@ function is_main_query()
122372122374
* @global WP_Query $wp_query WordPress Query object.
122373122375
*
122374122376
* @return bool True if posts are available, false if end of the loop.
122377+
* @phpstan-impure
122378+
* @phpstan-return bool
122375122379
*/
122376122380
function have_posts()
122377122381
{

0 commit comments

Comments
 (0)