diff --git a/functionMap.php b/functionMap.php index 85de493..59ea17c 100644 --- a/functionMap.php +++ b/functionMap.php @@ -40,6 +40,7 @@ 'absint' => ['($maybeint is T&int<0, max> ? T : ($maybeint is int ? int<1, max> : ($maybeint is empty ? 0 : ($maybeint is numeric-string ? int<0, max> : ($maybeint is string ? 0 : ($maybeint is true|non-empty-array ? 1 : ($maybeint is bool ? 0|1 : int<0, max>)))))))', '@phpstan-template T' => 'of int', 'maybeint' => 'T|scalar|array|resource|null', '@phpstan-pure' => ''], 'add_comments_page' => [null, 'callback' => "''|callable"], 'add_dashboard_page' => [null, 'callback' => "''|callable"], + 'add_feed' => ['non-falsy-string', 'callback' => 'callable(bool, string): void'], 'add_link' => ['int<0, max>'], 'add_links_page' => [null, 'callback' => "''|callable"], 'add_management_page' => [null, 'callback' => "''|callable"], diff --git a/tests/ParameterTypeTest.php b/tests/ParameterTypeTest.php index c6a615e..cad087a 100644 --- a/tests/ParameterTypeTest.php +++ b/tests/ParameterTypeTest.php @@ -28,6 +28,22 @@ public function testAbsint(): void ); } + public function testAddFeed(): void + { + $this->analyse( + __DIR__ . '/data/param/add-feed.php', + [ + ["Parameter #2 \$callback of function add_feed expects callable(bool, string): void, '' given.", 19], + ['Parameter #2 $callback of function add_feed expects callable(bool, string): void, Closure(int): void given.', 20], + ['Parameter #2 $callback of function add_feed expects callable(bool, string): void, Closure(bool, int): void given.', 21], + ['Parameter #2 $callback of function add_feed expects callable(bool, string): void, Closure(bool, string): int given.', 22], + ["Parameter #2 \$callback of function add_feed expects callable(bool, string): void, 'addFeedNotOkFirst' given.", 23], + ["Parameter #2 \$callback of function add_feed expects callable(bool, string): void, 'addFeedNotOkSecond' given.", 24], + ["Parameter #2 \$callback of function add_feed expects callable(bool, string): void, 'addFeedNotOkReturn' given.", 25], + ] + ); + } + public function testAddMenuPage(): void { $this->analyse( diff --git a/tests/data/param/add-feed.php b/tests/data/param/add-feed.php new file mode 100644 index 0000000..b21bfcf --- /dev/null +++ b/tests/data/param/add-feed.php @@ -0,0 +1,33 @@ +