From 3040167287fc62c5db1ea556a36c4389b8e12cf7 Mon Sep 17 00:00:00 2001 From: Marian <42134098+IanDelMar@users.noreply.github.com> Date: Wed, 29 Oct 2025 05:54:29 +0100 Subject: [PATCH] Narrow return type for did_filter() --- functionMap.php | 1 + tests/data/return/did-action.php | 10 ++++++++++ tests/data/return/did-filter.php | 10 ++++++++++ wordpress-stubs.php | 1 + 4 files changed, 22 insertions(+) create mode 100644 tests/data/return/did-action.php create mode 100644 tests/data/return/did-filter.php diff --git a/functionMap.php b/functionMap.php index 85de493..f781925 100644 --- a/functionMap.php +++ b/functionMap.php @@ -64,6 +64,7 @@ 'comment_class' => ['($display is true ? void : string)'], 'current_time' => ["(\$type is 'timestamp'|'U' ? int : string)"], 'did_action' => ['int<0, max>'], + 'did_filter' => ['int<0, max>'], 'edit_link' => ['int<0, max>'], 'edit_term_link' => ['($display is true ? void : string|void)'], 'get_approved_comments' => ["(\$args is array{count: true}&array ? int : (\$args is array{fields: 'ids'}&array ? array : array))"], diff --git a/tests/data/return/did-action.php b/tests/data/return/did-action.php new file mode 100644 index 0000000..8ff119f --- /dev/null +++ b/tests/data/return/did-action.php @@ -0,0 +1,10 @@ +', did_action('hook_name')); diff --git a/tests/data/return/did-filter.php b/tests/data/return/did-filter.php new file mode 100644 index 0000000..1f3f5dd --- /dev/null +++ b/tests/data/return/did-filter.php @@ -0,0 +1,10 @@ +', did_filter('hook_name')); diff --git a/wordpress-stubs.php b/wordpress-stubs.php index 26f4c88..df981c0 100644 --- a/wordpress-stubs.php +++ b/wordpress-stubs.php @@ -129545,6 +129545,7 @@ function doing_filter($hook_name = \null) * * @param string $hook_name The name of the filter hook. * @return int The number of times the filter hook has been applied. + * @phpstan-return int<0, max> */ function did_filter($hook_name) {