diff --git a/functionMap.php b/functionMap.php index b7ef789..36c0883 100644 --- a/functionMap.php +++ b/functionMap.php @@ -107,6 +107,7 @@ 'get_user_by' => ["(\$field is 'id'|'ID' ? (\$value is int ? false : \WP_User|false) : \WP_User|false)"], 'has_action' => ['($callback is false ? bool : false|int)'], 'has_filter' => ['($callback is false ? bool : false|int)'], + 'has_shortcode' => ['($tag is empty ? false : ($content is empty ? false : bool))', '@phpstan-assert-if-true =non-falsy-string $content' => '', '@phpstan-assert-if-true =non-empty-string $tag' => ''], 'have_posts' => [null, '@phpstan-impure' => ''], 'image_link_input_fields' => ['non-falsy-string'], 'image_size_input_fields' => ["array{label: string, input: 'html', html: string}"], diff --git a/tests/TypeInferenceTest.php b/tests/TypeInferenceTest.php index c1f2080..9e60af6 100644 --- a/tests/TypeInferenceTest.php +++ b/tests/TypeInferenceTest.php @@ -53,6 +53,7 @@ public function dataFileAsserts(): iterable yield from $this->gatherAssertTypes(__DIR__ . '/data/get_user.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/get_user_by.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/has_filter.php'); + yield from $this->gatherAssertTypes(__DIR__ . '/data/has_shortcode.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/have_posts.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/image_link_input_fields.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/image_size_input_fields.php'); diff --git a/tests/data/has_shortcode.php b/tests/data/has_shortcode.php new file mode 100644 index 0000000..f78abd5 --- /dev/null +++ b/tests/data/has_shortcode.php @@ -0,0 +1,42 @@ +