Skip to content

Commit b5803f9

Browse files
authored
Narrow return type of current_action/filter() (#398)
1 parent dc9489b commit b5803f9

File tree

5 files changed

+24
-0
lines changed

5 files changed

+24
-0
lines changed

functionMap.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@
6262
'check_admin_referer' => ['1|2|false', 'action' => 'string'],
6363
'check_ajax_referer' => ['1|2|false', 'action' => 'string'],
6464
'comment_class' => ['($display is true ? void : string)'],
65+
'current_action' => ['non-empty-string|false'],
66+
'current_filter' => ['non-empty-string|false'],
6567
'current_time' => ["(\$type is 'timestamp'|'U' ? int : string)"],
6668
'did_action' => ['int<0, max>'],
6769
'edit_link' => ['int<0, max>'],
File renamed without changes.
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 current_action;
8+
use function PHPStan\Testing\assertType;
9+
10+
assertType('non-empty-string|false', current_action());
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 current_filter;
8+
use function PHPStan\Testing\assertType;
9+
10+
assertType('non-empty-string|false', current_filter());

wordpress-stubs.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129508,6 +129508,7 @@ function remove_all_filters($hook_name, $priority = \false)
129508129508
* @global string[] $wp_current_filter Stores the list of current filters with the current one last
129509129509
*
129510129510
* @return string Hook name of the current filter.
129511+
* @phpstan-return non-empty-string|false
129511129512
*/
129512129513
function current_filter()
129513129514
{
@@ -129696,6 +129697,7 @@ function remove_all_actions($hook_name, $priority = \false)
129696129697
* @since 3.9.0
129697129698
*
129698129699
* @return string Hook name of the current action.
129700+
* @phpstan-return non-empty-string|false
129699129701
*/
129700129702
function current_action()
129701129703
{

0 commit comments

Comments
 (0)