Skip to content

Make PHPDoc type compatible with default value #289

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions functionMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,19 @@
'_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' ? new<T> : false)", '@phpstan-template T' => 'of string', 'class_name' => 'T', 'args' => 'array{screen?: string}'],
'absint' => ['($maybeint is T&int<0, max> ? T : ($maybeint is int<min, -1> ? 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'],
'addslashes_gpc' => ['T', '@phpstan-template' => 'T', 'gpc' => 'T'],
'add_menu_page' => [null, 'callback' => "''|callable"],
'add_links_page' => [null, 'callback' => "''|callable"],
'add_media_page' => [null, 'callback' => "''|callable"],
'add_pages_page' => [null, 'callback' => "''|callable"],
'add_posts_page' => [null, 'callback' => "''|callable"],
'add_theme_page' => [null, 'callback' => "''|callable"],
'add_users_page' => [null, 'callback' => "''|callable"],
'add_options_page' => [null, 'callback' => "''|callable"],
'add_plugins_page' => [null, 'callback' => "''|callable"],
'add_submenu_page' => [null, 'callback' => "''|callable"],
'add_comments_page' => [null, 'callback' => "''|callable"],
'add_dashboard_page' => [null, 'callback' => "''|callable"],
'add_management_page' => [null, 'callback' => "''|callable"],
'bool_from_yn' => ["(\$yn is 'y' ? true : false)"],
'have_posts' => [null, '@phpstan-impure' => ''],
'is_new_day' => ['0|1'],
Expand Down
12 changes: 12 additions & 0 deletions wordpress-stubs.php
Original file line number Diff line number Diff line change
Expand Up @@ -87838,6 +87838,7 @@ function uninstall_plugin($plugin)
* * Pass 'none' to leave div.wp-menu-image empty so an icon can be added via CSS.
* @param int|float $position Optional. The position in the menu order this item should appear.
* @return string The resulting page's hook_suffix.
* @phpstan-param ''|callable $callback
*/
function add_menu_page($page_title, $menu_title, $capability, $menu_slug, $callback = '', $icon_url = '', $position = \null)
{
Expand Down Expand Up @@ -87897,6 +87898,7 @@ function add_submenu_page($parent_slug, $page_title, $menu_title, $capability, $
* @param callable $callback Optional. The function to be called to output the content for this page.
* @param int $position Optional. The position in the menu order this item should appear.
* @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
* @phpstan-param ''|callable $callback
*/
function add_management_page($page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = \null)
{
Expand All @@ -87920,6 +87922,7 @@ function add_management_page($page_title, $menu_title, $capability, $menu_slug,
* @param callable $callback Optional. The function to be called to output the content for this page.
* @param int $position Optional. The position in the menu order this item should appear.
* @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
* @phpstan-param ''|callable $callback
*/
function add_options_page($page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = \null)
{
Expand All @@ -87943,6 +87946,7 @@ function add_options_page($page_title, $menu_title, $capability, $menu_slug, $ca
* @param callable $callback Optional. The function to be called to output the content for this page.
* @param int $position Optional. The position in the menu order this item should appear.
* @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
* @phpstan-param ''|callable $callback
*/
function add_theme_page($page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = \null)
{
Expand All @@ -87966,6 +87970,7 @@ function add_theme_page($page_title, $menu_title, $capability, $menu_slug, $call
* @param callable $callback Optional. The function to be called to output the content for this page.
* @param int $position Optional. The position in the menu order this item should appear.
* @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
* @phpstan-param ''|callable $callback
*/
function add_plugins_page($page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = \null)
{
Expand All @@ -87989,6 +87994,7 @@ function add_plugins_page($page_title, $menu_title, $capability, $menu_slug, $ca
* @param callable $callback Optional. The function to be called to output the content for this page.
* @param int $position Optional. The position in the menu order this item should appear.
* @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
* @phpstan-param ''|callable $callback
*/
function add_users_page($page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = \null)
{
Expand All @@ -88012,6 +88018,7 @@ function add_users_page($page_title, $menu_title, $capability, $menu_slug, $call
* @param callable $callback Optional. The function to be called to output the content for this page.
* @param int $position Optional. The position in the menu order this item should appear.
* @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
* @phpstan-param ''|callable $callback
*/
function add_dashboard_page($page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = \null)
{
Expand All @@ -88035,6 +88042,7 @@ function add_dashboard_page($page_title, $menu_title, $capability, $menu_slug, $
* @param callable $callback Optional. The function to be called to output the content for this page.
* @param int $position Optional. The position in the menu order this item should appear.
* @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
* @phpstan-param ''|callable $callback
*/
function add_posts_page($page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = \null)
{
Expand All @@ -88058,6 +88066,7 @@ function add_posts_page($page_title, $menu_title, $capability, $menu_slug, $call
* @param callable $callback Optional. The function to be called to output the content for this page.
* @param int $position Optional. The position in the menu order this item should appear.
* @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
* @phpstan-param ''|callable $callback
*/
function add_media_page($page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = \null)
{
Expand All @@ -88081,6 +88090,7 @@ function add_media_page($page_title, $menu_title, $capability, $menu_slug, $call
* @param callable $callback Optional. The function to be called to output the content for this page.
* @param int $position Optional. The position in the menu order this item should appear.
* @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
* @phpstan-param ''|callable $callback
*/
function add_links_page($page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = \null)
{
Expand All @@ -88104,6 +88114,7 @@ function add_links_page($page_title, $menu_title, $capability, $menu_slug, $call
* @param callable $callback Optional. The function to be called to output the content for this page.
* @param int $position Optional. The position in the menu order this item should appear.
* @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
* @phpstan-param ''|callable $callback
*/
function add_pages_page($page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = \null)
{
Expand All @@ -88127,6 +88138,7 @@ function add_pages_page($page_title, $menu_title, $capability, $menu_slug, $call
* @param callable $callback Optional. The function to be called to output the content for this page.
* @param int $position Optional. The position in the menu order this item should appear.
* @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
* @phpstan-param ''|callable $callback
*/
function add_comments_page($page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = \null)
{
Expand Down