diff --git a/functionMap.php b/functionMap.php index 475d83a..261912b 100644 --- a/functionMap.php +++ b/functionMap.php @@ -137,8 +137,11 @@ 'prep_atom_text_construct' => ["array{'html'|'text'|'xhtml', string}"], 'previous_posts' => ['($display is true ? void : string)'], 'rawurlencode_deep' => ['T', '@phpstan-template' => 'T', 'value' => 'T'], + 'register_activation_hook' => ['void', 'callback' => 'callable(bool): void'], + 'register_deactivation_hook' => ['void', 'callback' => 'callable(bool): void'], 'register_nav_menus' => [null, 'locations' => 'array'], 'register_post_type' => [null, 'post_type' => 'lowercase-string&non-empty-string'], + 'register_uninstall_hook' => ['void', 'callback' => 'callable(): void'], 'render_block_core_categories' => ['non-falsy-string'], 'rest_authorization_required_code' => ['401|403'], 'rest_sanitize_boolean' => ["(T is bool ? T : (T is ''|'false'|'FALSE'|'0'|0 ? false : true))", '@phpstan-template T' => 'of bool|string|int', 'value' => 'T', '@phpstan-pure' => ''], diff --git a/tests/ParameterTypeTest.php b/tests/ParameterTypeTest.php index 853112f..2b5aee8 100644 --- a/tests/ParameterTypeTest.php +++ b/tests/ParameterTypeTest.php @@ -155,6 +155,28 @@ public function testCheckAjaxReferer(): void ); } + public function testRegisterActivationHook(): void + { + $this->analyse( + __DIR__ . '/data/param/register-activation-hook.php', + [ + ['Parameter #2 $callback of function register_activation_hook expects callable(bool): void, Closure(string): void given.', 10], + ['Parameter #2 $callback of function register_activation_hook expects callable(bool): void, Closure(bool): int given.', 11], + ] + ); + } + + public function testRegisterDeactivationHook(): void + { + $this->analyse( + __DIR__ . '/data/param/register-deactivation-hook.php', + [ + ['Parameter #2 $callback of function register_deactivation_hook expects callable(bool): void, Closure(string): void given.', 10], + ['Parameter #2 $callback of function register_deactivation_hook expects callable(bool): void, Closure(bool): int given.', 11], + ] + ); + } + public function testDoAction(): void { $this->analyse( @@ -199,6 +221,17 @@ public function testRegisterPostType(): void ); } + public function testRegisterUninstallHook(): void + { + $this->analyse( + __DIR__ . '/data/param/register-uninstall-hook.php', + [ + ['Parameter #2 $callback of function register_uninstall_hook expects callable(): void, Closure(bool): void given.', 10], + ['Parameter #2 $callback of function register_uninstall_hook expects callable(): void, Closure(): int given.', 11], + ] + ); + } + public function testWpdbGetRow(): void { $this->analyse( diff --git a/tests/data/param/register-activation-hook.php b/tests/data/param/register-activation-hook.php new file mode 100644 index 0000000..ed5ea2e --- /dev/null +++ b/tests/data/param/register-activation-hook.php @@ -0,0 +1,15 @@ +