Skip to content
Draft
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
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"phpcompatibility/phpcompatibility-wp": "~2.1.3",
"phpstan/phpstan": "2.2.13",
"phpstan/phpstan-phpunit": "2.0.18",
"szepeviktor/phpstan-wordpress": "^2.0.4",
"yoast/phpunit-polyfills": "^1.1.0"
},
"config": {
Expand Down
2 changes: 2 additions & 0 deletions src/wp-admin/customize.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,10 @@
$wp_scripts = new WP_Scripts();
$wp_scripts->registered = $registered;

// @phpstan-ignore return.void (WordPress discards an action callback's return value.)
add_action( 'customize_controls_print_scripts', 'print_head_scripts', 20 );
add_action( 'customize_controls_print_footer_scripts', '_wp_footer_scripts' );
// @phpstan-ignore return.void (WordPress discards an action callback's return value.)
add_action( 'customize_controls_print_styles', 'print_admin_styles', 20 );

/**
Expand Down
9 changes: 9 additions & 0 deletions src/wp-admin/includes/admin-filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,21 @@
add_action( 'admin_page_access_denied', 'wp_link_manager_disabled_message' );

// Dashboard hooks.
// @phpstan-ignore return.void (WordPress discards an action callback's return value.)
add_action( 'activity_box_end', 'wp_dashboard_quota' );
add_action( 'welcome_panel', 'wp_welcome_panel' );

// Media hooks.
add_action( 'attachment_submitbox_misc_actions', 'attachment_submitbox_metadata' );
add_filter( 'plupload_init', 'wp_show_heic_upload_error' );

// @phpstan-ignore return.void (WordPress discards an action callback's return value.)
add_action( 'media_upload_image', 'wp_media_upload_handler' );
// @phpstan-ignore return.void (WordPress discards an action callback's return value.)
add_action( 'media_upload_audio', 'wp_media_upload_handler' );
// @phpstan-ignore return.void (WordPress discards an action callback's return value.)
add_action( 'media_upload_video', 'wp_media_upload_handler' );
// @phpstan-ignore return.void (WordPress discards an action callback's return value.)
add_action( 'media_upload_file', 'wp_media_upload_handler' );

add_action( 'post-plupload-upload-ui', 'media_upload_flash_bypass' );
Expand Down Expand Up @@ -57,10 +62,12 @@
}

add_action( 'admin_print_scripts', 'print_emoji_detection_script' );
// @phpstan-ignore return.void (WordPress discards an action callback's return value.)
add_action( 'admin_print_scripts', 'print_head_scripts', 20 );
add_action( 'admin_print_footer_scripts', '_wp_footer_scripts' );
add_action( 'admin_enqueue_scripts', 'wp_enqueue_emoji_styles' );
add_action( 'admin_print_styles', 'print_emoji_styles' ); // Retained for backwards-compatibility. Unhooked by wp_enqueue_emoji_styles().
// @phpstan-ignore return.void (WordPress discards an action callback's return value.)
add_action( 'admin_print_styles', 'print_admin_styles', 20 );

add_action( 'admin_print_scripts-index.php', 'wp_localize_community_events' );
Expand Down Expand Up @@ -130,10 +137,12 @@
add_action( 'load-plugins.php', 'wp_plugin_update_rows', 20 ); // After wp_update_plugins() is called.
add_action( 'load-themes.php', 'wp_theme_update_rows', 20 ); // After wp_update_themes() is called.

// @phpstan-ignore return.void (WordPress discards an action callback's return value.)
add_action( 'admin_notices', 'update_nag', 3 );
add_action( 'admin_notices', 'deactivated_plugins_notice', 5 );
add_action( 'admin_notices', 'paused_plugins_notice', 5 );
add_action( 'admin_notices', 'paused_themes_notice', 5 );
// @phpstan-ignore return.void (WordPress discards an action callback's return value.)
add_action( 'admin_notices', 'maintenance_nag', 10 );
add_action( 'admin_notices', 'wp_recovery_mode_nag', 1 );

Expand Down
14 changes: 7 additions & 7 deletions src/wp-admin/includes/class-wp-posts-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -1856,7 +1856,7 @@ public function inline_edit() {
* @param array $users_opt An array of arguments passed to wp_dropdown_users().
* @param bool $bulk A flag to denote if it's a bulk action.
*/
$users_opt = apply_filters( 'quick_edit_dropdown_authors_args', $users_opt, $bulk );
$users_opt = apply_filters( 'quick_edit_dropdown_authors_args', $users_opt, (bool) $bulk );

$authors = wp_dropdown_users( $users_opt );

Expand Down Expand Up @@ -1961,7 +1961,7 @@ public function inline_edit() {
* @param array $dropdown_args An array of arguments passed to wp_dropdown_pages().
* @param bool $bulk A flag to denote if it's a bulk action.
*/
$dropdown_args = apply_filters( 'quick_edit_dropdown_pages_args', $dropdown_args, $bulk );
$dropdown_args = apply_filters( 'quick_edit_dropdown_pages_args', $dropdown_args, (bool) $bulk );

wp_dropdown_pages( $dropdown_args );
?>
Expand Down Expand Up @@ -2108,12 +2108,12 @@ public function inline_edit() {
*
* @since 6.9.0
*
* @param array<string,string> $inline_edit_statuses An array of statuses available in the Quick Edit UI.
* @param string $post_type The post type slug.
* @param bool $bulk A flag to denote if it's a bulk action.
* @param bool $can_publish A flag to denote if the user can publish posts.
* @param string[] $inline_edit_statuses An array of statuses available in the Quick Edit UI.
* @param string $post_type The post type slug.
* @param bool $bulk A flag to denote if it's a bulk action.
* @param bool $can_publish A flag to denote if the user can publish posts.
*/
$inline_edit_statuses = apply_filters( 'quick_edit_statuses', $inline_edit_statuses, $screen->post_type, $bulk, $can_publish );
$inline_edit_statuses = apply_filters( 'quick_edit_statuses', $inline_edit_statuses, $screen->post_type, (bool) $bulk, $can_publish );

foreach ( $inline_edit_statuses as $inline_status_value => $inline_status_text ) :
?>
Expand Down
2 changes: 2 additions & 0 deletions src/wp-admin/includes/class-wp-upgrader.php
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,7 @@ public function run( $options ) {
* internally during actions, causing an error because
* `WP_Upgrader::restore_temp_backup()` expects an array.
*/
// @phpstan-ignore return.void (WordPress discards an action callback's return value.)
add_action( 'shutdown', array( $this, 'restore_temp_backup' ), 10, 0 );
}
$this->skin->error( $result );
Expand All @@ -950,6 +951,7 @@ public function run( $options ) {
// Clean up the backup kept in the temporary backup directory.
if ( ! empty( $options['hook_extra']['temp_backup'] ) ) {
// Delete the backup on `shutdown` to avoid a PHP timeout.
// @phpstan-ignore return.void (WordPress discards an action callback's return value.)
add_action( 'shutdown', array( $this, 'delete_temp_backup' ), 100, 0 );
}

Expand Down
2 changes: 1 addition & 1 deletion src/wp-admin/includes/dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -1622,7 +1622,7 @@ function wp_dashboard_primary() {
*
* @since 4.4.0
*
* @param string $items How many items to show in the secondary feed.
* @param int $items How many items to show in the secondary feed.
*/
'items' => apply_filters( 'dashboard_secondary_items', 3 ),
'show_summary' => 0,
Expand Down
4 changes: 2 additions & 2 deletions src/wp-admin/includes/media.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,9 @@ function image_add_caption( $html, $id, $caption, $title, $align, $url, $size, $
* @since 2.6.0
*
* @param bool $bool Whether to disable appending captions. Returning true from the filter
* will disable captions. Default empty string.
* will disable captions. Default false.
*/
if ( empty( $caption ) || apply_filters( 'disable_captions', '' ) ) {
if ( empty( $caption ) || apply_filters( 'disable_captions', false ) ) {
return $html;
}

Expand Down
4 changes: 4 additions & 0 deletions src/wp-admin/includes/ms-admin-filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@
add_filter( 'import_allow_create_users', 'check_import_new_users' );

// Notices hooks.
// @phpstan-ignore return.void (WordPress discards an action callback's return value.)
add_action( 'admin_notices', 'site_admin_notice' );
// @phpstan-ignore return.void (WordPress discards an action callback's return value.)
add_action( 'network_admin_notices', 'site_admin_notice' );

// Update hooks.
// @phpstan-ignore return.void (WordPress discards an action callback's return value.)
add_action( 'network_admin_notices', 'update_nag', 3 );
// @phpstan-ignore return.void (WordPress discards an action callback's return value.)
add_action( 'network_admin_notices', 'maintenance_nag', 10 );

// Network Admin hooks.
Expand Down
2 changes: 2 additions & 0 deletions src/wp-admin/includes/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ function wp_plugin_update_rows() {
$plugins = array_keys( $plugins->response );

foreach ( $plugins as $plugin_file ) {
// @phpstan-ignore return.void (WordPress discards an action callback's return value.)
add_action( "after_plugin_row_{$plugin_file}", 'wp_plugin_update_row', 10, 2 );
}
}
Expand Down Expand Up @@ -657,6 +658,7 @@ function wp_theme_update_rows() {
$themes = array_keys( $themes->response );

foreach ( $themes as $theme ) {
// @phpstan-ignore return.void (WordPress discards an action callback's return value.)
add_action( "after_theme_row_{$theme}", 'wp_theme_update_row', 10, 2 );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function twenty_twenty_one_post_classes( $classes ) {

return $classes;
}
add_filter( 'post_class', 'twenty_twenty_one_post_classes', 10, 3 );
add_filter( 'post_class', 'twenty_twenty_one_post_classes' );

/**
* Adds a pingback url auto-discovery header for single posts, pages, or attachments.
Expand Down
2 changes: 1 addition & 1 deletion src/wp-includes/block-supports/block-style-variations.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ function wp_enqueue_block_style_variation_styles() {
// Register the block support.
WP_Block_Supports::get_instance()->register( 'block-style-variation', array() );

add_filter( 'render_block_data', 'wp_render_block_style_variation_support_styles', 10, 2 );
add_filter( 'render_block_data', 'wp_render_block_style_variation_support_styles' );
add_filter( 'render_block', 'wp_render_block_style_variation_class_name', 10, 2 );
add_action( 'wp_enqueue_scripts', 'wp_enqueue_block_style_variation_styles', 1 );

Expand Down
1 change: 1 addition & 0 deletions src/wp-includes/class-wp-customize-setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ public function preview() {
// If the setting does not need previewing now, defer to when it has a value to preview.
if ( ! $needs_preview ) {
if ( ! has_action( "customize_post_value_set_{$this->id}", array( $this, 'preview' ) ) ) {
// @phpstan-ignore return.void (WordPress discards an action callback's return value.)
add_action( "customize_post_value_set_{$this->id}", array( $this, 'preview' ) );
}
return false;
Expand Down
1 change: 1 addition & 0 deletions src/wp-includes/class-wp-recovery-mode.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public function __construct() {
public function initialize() {
$this->is_initialized = true;

// @phpstan-ignore return.void (WordPress discards an action callback's return value.)
add_action( 'wp_logout', array( $this, 'exit_recovery_mode' ) );
add_action( 'login_form_' . self::EXIT_ACTION, array( $this, 'handle_exit_recovery_mode' ) );
add_action( 'recovery_mode_clean_expired_keys', array( $this, 'clean_expired_keys' ) );
Expand Down
3 changes: 2 additions & 1 deletion src/wp-includes/comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ function wp_allow_comment( $commentdata, $wp_error = false ) {
wp_unslash( $commentdata['comment_content'] )
);

$dupe_id = $wpdb->get_var( $dupe );
$dupe_id = (int) $wpdb->get_var( $dupe );

/**
* Filters the ID, if any, of the duplicate comment found when creating a new comment.
Expand Down Expand Up @@ -2815,6 +2815,7 @@ function wp_set_comment_status( $comment_id, $comment_status, $wp_error = false
case 'approve':
case '1':
$status = '1';
// @phpstan-ignore return.void (WordPress discards an action callback's return value.)
add_action( 'wp_set_comment_status', 'wp_new_comment_notify_postauthor' );
break;
case 'spam':
Expand Down
2 changes: 2 additions & 0 deletions src/wp-includes/cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -1021,11 +1021,13 @@ function wp_cron(): void {
if ( did_action( 'wp_loaded' ) ) {
_wp_cron();
} else {
// @phpstan-ignore return.void (WordPress discards an action callback's return value.)
add_action( 'wp_loaded', '_wp_cron', 20 );
}
} elseif ( doing_action( 'shutdown' ) ) {
_wp_cron();
} else {
// @phpstan-ignore return.void (WordPress discards an action callback's return value.)
add_action( 'shutdown', '_wp_cron' );
}
}
Expand Down
22 changes: 21 additions & 1 deletion src/wp-includes/default-filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
add_action( 'admin_init', 'wp_schedule_update_user_counts' );
add_action( 'wp_update_user_counts', 'wp_schedule_update_user_counts', 10, 0 );
foreach ( array( 'user_register', 'deleted_user' ) as $action ) {
// @phpstan-ignore return.void (WordPress discards an action callback's return value.)
add_action( $action, 'wp_maybe_update_user_counts', 10, 0 );
}

Expand Down Expand Up @@ -307,7 +308,7 @@
add_filter( 'pre_kses', 'wp_pre_kses_less_than' );
add_filter( 'pre_kses', 'wp_pre_kses_block_attributes', 10, 3 );
add_filter( 'sanitize_title', 'sanitize_title_with_dashes', 10, 3 );
add_action( 'check_comment_flood', 'check_comment_flood_db', 10, 4 );
add_action( 'check_comment_flood', 'check_comment_flood_db' );
add_filter( 'comment_flood_filter', 'wp_throttle_comment_flood', 10, 3 );
add_filter( 'pre_comment_content', 'wp_rel_ugc', 15 );

Expand Down Expand Up @@ -360,7 +361,9 @@
add_action( 'publish_future_post', 'check_and_publish_future_post', 10, 1 );
add_action( 'wp_head', 'wp_robots', 1 );
add_action( 'wp_head', 'print_emoji_detection_script', 7 );
// @phpstan-ignore return.void (WordPress discards an action callback's return value.)
add_action( 'wp_head', 'wp_print_styles', 8 );
// @phpstan-ignore return.void (WordPress discards an action callback's return value.)
add_action( 'wp_head', 'wp_print_head_scripts', 9 );
add_action( 'wp_head', 'wp_generator' );
add_action( 'wp_head', 'rel_canonical' );
Expand Down Expand Up @@ -394,7 +397,9 @@
// Login actions.
add_action( 'login_head', 'wp_robots', 1 );
add_action( 'login_head', 'wp_resource_hints', 8 );
// @phpstan-ignore return.void (WordPress discards an action callback's return value.)
add_action( 'login_head', 'wp_print_head_scripts', 9 );
// @phpstan-ignore return.void (WordPress discards an action callback's return value.)
add_action( 'login_head', 'print_admin_styles', 9 );
add_action( 'login_head', 'wp_site_icon', 99 );
add_action( 'login_footer', 'wp_print_footer_scripts', 20 );
Expand Down Expand Up @@ -428,6 +433,7 @@
add_action( 'do_all_pings', 'do_all_pingbacks', 10, 0 );
add_action( 'do_all_pings', 'do_all_enclosures', 10, 0 );
add_action( 'do_all_pings', 'do_all_trackbacks', 10, 0 );
// @phpstan-ignore return.void (WordPress discards an action callback's return value.)
add_action( 'do_all_pings', 'generic_ping', 10, 0 );

// Disable pings (pingbacks, trackbacks, and ping service notifications) in non-production environments.
Expand All @@ -437,6 +443,7 @@

add_action( 'do_robots', 'do_robots' );
add_action( 'do_favicon', 'do_favicon' );
// @phpstan-ignore return.void (WordPress discards an action callback's return value.)
add_action( 'wp_before_include_template', 'wp_start_template_enhancement_output_buffer', 1000 ); // Late priority to let `wp_template_enhancement_output_buffer` filters and `wp_finalized_template_enhancement_output_buffer` actions be registered.
add_action( 'set_comment_cookies', 'wp_set_comment_cookies', 10, 3 );
add_action( 'sanitize_comment_cookies', 'sanitize_comment_cookies' );
Expand All @@ -446,6 +453,7 @@
add_action( 'shutdown', 'wp_ob_end_flush_all', 1 );
// Create a revision whenever a post is updated.
add_action( 'wp_after_insert_post', 'wp_save_post_revision_on_insert', 9, 3 );
// @phpstan-ignore return.void (WordPress discards an action callback's return value.)
add_action( 'post_updated', 'wp_save_post_revision', 10, 1 );
add_action( 'publish_post', '_publish_post_hook', 5, 1 );
add_action( 'transition_post_status', '_transition_post_status', 5, 3 );
Expand All @@ -467,7 +475,9 @@
// Cron tasks.
add_action( 'wp_scheduled_delete', 'wp_scheduled_delete' );
add_action( 'wp_scheduled_auto_draft_delete', 'wp_delete_auto_drafts' );
// @phpstan-ignore return.void (WordPress discards an action callback's return value.)
add_action( 'importer_scheduled_cleanup', 'wp_delete_attachment' );
// @phpstan-ignore return.void (WordPress discards an action callback's return value.)
add_action( 'upgrader_scheduled_cleanup', 'wp_delete_attachment' );
add_action( 'delete_expired_transients', 'delete_expired_transients' );

Expand Down Expand Up @@ -536,7 +546,9 @@
add_action( 'wp_update_comment_type_batch', '_wp_batch_update_comment_type' );

// Email notifications.
// @phpstan-ignore return.void (WordPress discards an action callback's return value.)
add_action( 'comment_post', 'wp_new_comment_notify_moderator' );
// @phpstan-ignore return.void (WordPress discards an action callback's return value.)
add_action( 'comment_post', 'wp_new_comment_notify_postauthor' );
add_action( 'rest_insert_comment', 'wp_new_comment_via_rest_notify_postauthor' );
add_action( 'rest_insert_comment', 'wp_notify_note_mentions', 10, 3 );
Expand All @@ -560,6 +572,7 @@
add_action( 'init', '_wp_connectors_init', 15 );

// Sitemaps actions.
// @phpstan-ignore return.void (WordPress discards an action callback's return value.)
add_action( 'init', 'wp_sitemaps_get_server' );

/**
Expand Down Expand Up @@ -688,6 +701,7 @@
add_action( 'change_locale', 'create_initial_taxonomies' );

// Canonical.
// @phpstan-ignore return.void (WordPress discards an action callback's return value.)
add_action( 'template_redirect', 'redirect_canonical' );
add_action( 'template_redirect', 'wp_redirect_admin_locations', 1000 );

Expand Down Expand Up @@ -716,12 +730,16 @@

// Admin Bar.
// Don't remove. Wrong way to disable.
// @phpstan-ignore return.void (WordPress discards an action callback's return value.)
add_action( 'template_redirect', '_wp_admin_bar_init', 0 );
// @phpstan-ignore return.void (WordPress discards an action callback's return value.)
add_action( 'admin_init', '_wp_admin_bar_init' );
add_action( 'wp_enqueue_scripts', 'wp_enqueue_admin_bar_bump_styles' );
add_action( 'wp_enqueue_scripts', 'wp_enqueue_admin_bar_header_styles' );
add_action( 'admin_enqueue_scripts', 'wp_enqueue_admin_bar_header_styles' );
// @phpstan-ignore return.void (WordPress discards an action callback's return value.)
add_action( 'before_signup_header', '_wp_admin_bar_init' );
// @phpstan-ignore return.void (WordPress discards an action callback's return value.)
add_action( 'activate_header', '_wp_admin_bar_init' );
add_action( 'wp_body_open', 'wp_admin_bar_render', 0 );
add_action( 'wp_footer', 'wp_admin_bar_render', 1000 ); // Back-compat for themes not using `wp_body_open`.
Expand All @@ -745,7 +763,9 @@
add_action( 'embed_head', 'print_emoji_detection_script' );
add_action( 'embed_head', 'wp_enqueue_embed_styles', 9 );
add_action( 'embed_head', 'print_embed_styles' ); // Retained for backwards-compatibility. Unhooked by wp_enqueue_embed_styles().
// @phpstan-ignore return.void (WordPress discards an action callback's return value.)
add_action( 'embed_head', 'wp_print_head_scripts', 20 );
// @phpstan-ignore return.void (WordPress discards an action callback's return value.)
add_action( 'embed_head', 'wp_print_styles', 20 );
add_action( 'embed_head', 'wp_robots' );
add_action( 'embed_head', 'rel_canonical' );
Expand Down
Loading
Loading