diff --git a/functionMap.php b/functionMap.php index 3c5063a..17f0291 100644 --- a/functionMap.php +++ b/functionMap.php @@ -32,6 +32,7 @@ * @link https://github.com/phpstan/phpstan-src/blob/1.10.x/resources/functionMap.php */ return [ + '_wp_json_sanity_check' => ['T', '@phpstan-template' => 'T', 'value' => 'T', 'depth' => 'positive-int'], '_get_list_table' => ["(\$class_name is 'WP_Posts_List_Table'|'WP_Media_List_Table'|'WP_Terms_List_Table'|'WP_Users_List_Table'|'WP_Comments_List_Table'|'WP_Post_Comments_List_Table'|'WP_Links_List_Table'|'WP_Plugin_Install_List_Table'|'WP_Themes_List_Table'|'WP_Theme_Install_List_Table'|'WP_Plugins_List_Table'|'WP_Application_Passwords_List_Table'|'WP_MS_Sites_List_Table'|'WP_MS_Users_List_Table'|'WP_MS_Themes_List_Table'|'WP_Privacy_Data_Export_Requests_List_Table'|'WP_Privacy_Data_Removal_Requests_List_Table' ? T : false)", '@phpstan-template' => 'T', 'class_name' => 'class-string', 'args' => 'array{screen?: string}'], 'addslashes_gpc' => ['T', '@phpstan-template' => 'T', 'gpc' => 'T'], 'add_submenu_page' => [null, 'callback' => "''|callable"], diff --git a/tests/TypeInferenceTest.php b/tests/TypeInferenceTest.php index bdf00c8..b2edf2f 100644 --- a/tests/TypeInferenceTest.php +++ b/tests/TypeInferenceTest.php @@ -10,6 +10,7 @@ class TypeInferenceTest extends \PHPStan\Testing\TypeInferenceTestCase public function dataFileAsserts(): iterable { yield from $this->gatherAssertTypes(__DIR__ . '/data/_get_list_table.php'); + yield from $this->gatherAssertTypes(__DIR__ . '/data/_wp_json_sanity_check.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/current_time.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/echo_parameter.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/get_approved_comments.php'); diff --git a/tests/data/_wp_json_sanity_check.php b/tests/data/_wp_json_sanity_check.php new file mode 100644 index 0000000..ec06d94 --- /dev/null +++ b/tests/data/_wp_json_sanity_check.php @@ -0,0 +1,18 @@ +