diff --git a/functionMap.php b/functionMap.php index b4ee94b..af34054 100644 --- a/functionMap.php +++ b/functionMap.php @@ -55,6 +55,9 @@ 'add_users_page' => [null, 'callback' => "''|callable"], 'addslashes_gpc' => ['($gpc is string ? string : array)', '@phpstan-pure' => ''], 'antispambot' => [null, 'hex_encoding' => '0|1'], + 'apply_filters' => [null, 'hook_name' => 'non-empty-string'], + 'apply_filters_ref_array' => [null, 'hook_name' => 'non-empty-string'], + 'apply_filters_deprecated' => [null, 'hook_name' => 'non-empty-string'], 'backslashit' => [null, '@phpstan-pure' => ''], 'block_version' => ["(\$content is '' ? 0 : 0|1)", '@phpstan-pure' => ''], 'bool_from_yn' => ["(\$yn is 'y' ? true : false)", '@phpstan-pure' => ''], @@ -67,6 +70,9 @@ 'current_time' => ["(\$type is 'timestamp'|'U' ? int : string)"], 'did_action' => ['int<0, max>'], 'did_filter' => ['int<0, max>'], + 'do_action' => ['void', 'hook_name' => 'non-empty-string'], + 'do_action_ref_array' => ['void', 'hook_name' => 'non-empty-string'], + 'do_action_deprecated' => ['void', 'hook_name' => 'non-empty-string'], '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/ParameterTypeTest.php b/tests/ParameterTypeTest.php index 883c3fe..19020c7 100644 --- a/tests/ParameterTypeTest.php +++ b/tests/ParameterTypeTest.php @@ -83,6 +83,21 @@ public function testAntispambot(): void ); } + public function testApplyFilters(): void + { + $this->analyse( + __DIR__ . '/data/param/apply-filters.php', + [ + ["Parameter #1 \$hook_name of function apply_filters expects non-empty-string, '' given.", 8], + ["Parameter #1 \$hook_name of function apply_filters_ref_array expects non-empty-string, '' given.", 9], + ["Parameter #1 \$hook_name of function apply_filters_deprecated expects non-empty-string, '' given.", 10], + ['Parameter #1 $hook_name of function apply_filters expects non-empty-string, string given.', 13], + ['Parameter #1 $hook_name of function apply_filters_ref_array expects non-empty-string, string given.', 14], + ['Parameter #1 $hook_name of function apply_filters_deprecated expects non-empty-string, string given.', 15], + ] + ); + } + public function testBookmarks(): void { $field = "'link_category'|'link_description'|'link_id'|'link_image'|'link_name'|'link_notes'|'link_owner'|'link_rating'|'link_rel'|'link_rss'|'link_target'|'link_updated'|'link_url'|'link_visible'"; @@ -124,6 +139,21 @@ public function testCheckAjaxReferer(): void ); } + public function testDoAction(): void + { + $this->analyse( + __DIR__ . '/data/param/do-action.php', + [ + ["Parameter #1 \$hook_name of function do_action expects non-empty-string, '' given.", 8], + ["Parameter #1 \$hook_name of function do_action_ref_array expects non-empty-string, '' given.", 9], + ["Parameter #1 \$hook_name of function do_action_deprecated expects non-empty-string, '' given.", 10], + ['Parameter #1 $hook_name of function do_action expects non-empty-string, string given.', 13], + ['Parameter #1 $hook_name of function do_action_ref_array expects non-empty-string, string given.', 14], + ['Parameter #1 $hook_name of function do_action_deprecated expects non-empty-string, string given.', 15], + ] + ); + } + public function testRegisterNavMenus(): void { $this->analyse( diff --git a/tests/data/param/apply-filters.php b/tests/data/param/apply-filters.php new file mode 100644 index 0000000..b5dbcfd --- /dev/null +++ b/tests/data/param/apply-filters.php @@ -0,0 +1,20 @@ +