Skip to content

Commit 3040167

Browse files
committed
Narrow return type for did_filter()
1 parent 8a150a9 commit 3040167

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

functionMap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
'comment_class' => ['($display is true ? void : string)'],
6565
'current_time' => ["(\$type is 'timestamp'|'U' ? int : string)"],
6666
'did_action' => ['int<0, max>'],
67+
'did_filter' => ['int<0, max>'],
6768
'edit_link' => ['int<0, max>'],
6869
'edit_term_link' => ['($display is true ? void : string|void)'],
6970
'get_approved_comments' => ["(\$args is array{count: true}&array ? int : (\$args is array{fields: 'ids'}&array ? array<int, int> : array<int, \WP_Comment>))"],

tests/data/return/did-action.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace PhpStubs\WordPress\Core\Tests;
6+
7+
use function did_action;
8+
use function PHPStan\Testing\assertType;
9+
10+
assertType('int<0, max>', did_action('hook_name'));

tests/data/return/did-filter.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace PhpStubs\WordPress\Core\Tests;
6+
7+
use function did_filter;
8+
use function PHPStan\Testing\assertType;
9+
10+
assertType('int<0, max>', did_filter('hook_name'));

wordpress-stubs.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129545,6 +129545,7 @@ function doing_filter($hook_name = \null)
129545129545
*
129546129546
* @param string $hook_name The name of the filter hook.
129547129547
* @return int The number of times the filter hook has been applied.
129548+
* @phpstan-return int<0, max>
129548129549
*/
129549129550
function did_filter($hook_name)
129550129551
{

0 commit comments

Comments
 (0)