From 41e25d6802f10bd92600e39a4eee99fa01c01084 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Tue, 3 Jun 2025 16:51:33 +0000 Subject: [PATCH] General: Various fixes to the correctness of code and documentation reported by PHPStan. Props justlevine See #63268 Built from https://develop.svn.wordpress.org/trunk@60275 git-svn-id: http://core.svn.wordpress.org/trunk@59611 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/class-language-pack-upgrader.php | 2 +- wp-admin/includes/class-wp-automatic-updater.php | 2 +- wp-admin/includes/class-wp-filesystem-ftpsockets.php | 4 ++-- wp-admin/includes/post.php | 2 +- wp-admin/includes/taxonomy.php | 2 +- wp-includes/block-template.php | 2 +- wp-includes/category-template.php | 2 +- wp-includes/class-wp-block-pattern-categories-registry.php | 2 +- wp-includes/class-wp-block-patterns-registry.php | 2 +- wp-includes/class-wp-block-styles-registry.php | 2 +- wp-includes/pluggable.php | 4 ++-- wp-includes/script-loader.php | 2 +- wp-includes/version.php | 2 +- 13 files changed, 15 insertions(+), 15 deletions(-) diff --git a/wp-admin/includes/class-language-pack-upgrader.php b/wp-admin/includes/class-language-pack-upgrader.php index 6f7cf742bd..89b9f9ac87 100644 --- a/wp-admin/includes/class-language-pack-upgrader.php +++ b/wp-admin/includes/class-language-pack-upgrader.php @@ -383,7 +383,7 @@ class Language_Pack_Upgrader extends WP_Upgrader { case 'theme': $theme = wp_get_theme( $update->slug ); if ( $theme->exists() ) { - return $theme->Get( 'Name' ); + return $theme->get( 'Name' ); } break; case 'plugin': diff --git a/wp-admin/includes/class-wp-automatic-updater.php b/wp-admin/includes/class-wp-automatic-updater.php index 4dccd94ccd..2facbeb1d5 100644 --- a/wp-admin/includes/class-wp-automatic-updater.php +++ b/wp-admin/includes/class-wp-automatic-updater.php @@ -411,7 +411,7 @@ class WP_Automatic_Updater { case 'theme': $upgrader_item = $item->theme; $theme = wp_get_theme( $upgrader_item ); - $item_name = $theme->Get( 'Name' ); + $item_name = $theme->get( 'Name' ); // Add the current version so that it can be reported in the notification email. $item->current_version = $theme->get( 'Version' ); if ( empty( $item->current_version ) ) { diff --git a/wp-admin/includes/class-wp-filesystem-ftpsockets.php b/wp-admin/includes/class-wp-filesystem-ftpsockets.php index 9a37d88c11..986fccf2cf 100644 --- a/wp-admin/includes/class-wp-filesystem-ftpsockets.php +++ b/wp-admin/includes/class-wp-filesystem-ftpsockets.php @@ -77,7 +77,7 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base { return false; } - $this->ftp->setTimeout( FS_CONNECT_TIMEOUT ); + $this->ftp->SetTimeout( FS_CONNECT_TIMEOUT ); if ( ! $this->ftp->SetServer( $this->options['hostname'], $this->options['port'] ) ) { $this->errors->add( @@ -120,7 +120,7 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base { $this->ftp->SetType( FTP_BINARY ); $this->ftp->Passive( true ); - $this->ftp->setTimeout( FS_TIMEOUT ); + $this->ftp->SetTimeout( FS_TIMEOUT ); return true; } diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php index 40fac43d6e..ebdd61df34 100644 --- a/wp-admin/includes/post.php +++ b/wp-admin/includes/post.php @@ -2186,7 +2186,7 @@ function wp_autosave( $post_data ) { * * @param int $post_id Optional. Post ID. */ -function redirect_post( $post_id = '' ) { +function redirect_post( $post_id = 0 ) { if ( isset( $_POST['save'] ) || isset( $_POST['publish'] ) ) { $status = get_post_status( $post_id ); diff --git a/wp-admin/includes/taxonomy.php b/wp-admin/includes/taxonomy.php index 7765084fa7..359cfafe2f 100644 --- a/wp-admin/includes/taxonomy.php +++ b/wp-admin/includes/taxonomy.php @@ -75,7 +75,7 @@ function wp_create_category( $cat_name, $category_parent = 0 ) { * @param int $post_id Optional. The post ID. Default empty. * @return int[] Array of IDs of categories assigned to the given post. */ -function wp_create_categories( $categories, $post_id = '' ) { +function wp_create_categories( $categories, $post_id = 0 ) { $cat_ids = array(); foreach ( $categories as $category ) { $id = category_exists( $category ); diff --git a/wp-includes/block-template.php b/wp-includes/block-template.php index affae1c09a..eecbe2d61d 100644 --- a/wp-includes/block-template.php +++ b/wp-includes/block-template.php @@ -253,7 +253,7 @@ function get_the_block_template_html() { if ( is_user_logged_in() ) { return '

' . esc_html__( 'No matching template found' ) . '

'; } - return; + return ''; } $content = $wp_embed->run_shortcode( $_wp_current_template_content ); diff --git a/wp-includes/category-template.php b/wp-includes/category-template.php index b950fab70b..b2c88c9c25 100644 --- a/wp-includes/category-template.php +++ b/wp-includes/category-template.php @@ -793,7 +793,7 @@ function wp_tag_cloud( $args = '' ) { * @return int Scaled count. */ function default_topic_count_scale( $count ) { - return round( log10( $count + 1 ) * 100 ); + return (int) round( log10( $count + 1 ) * 100 ); } /** diff --git a/wp-includes/class-wp-block-pattern-categories-registry.php b/wp-includes/class-wp-block-pattern-categories-registry.php index 3d37a5940a..2d5fbcf2fe 100644 --- a/wp-includes/class-wp-block-pattern-categories-registry.php +++ b/wp-includes/class-wp-block-pattern-categories-registry.php @@ -107,7 +107,7 @@ final class WP_Block_Pattern_Categories_Registry { * @since 5.5.0 * * @param string $category_name Pattern category name including namespace. - * @return array Registered pattern properties. + * @return array|null Registered pattern properties, or `null` if the pattern category is not registered. */ public function get_registered( $category_name ) { if ( ! $this->is_registered( $category_name ) ) { diff --git a/wp-includes/class-wp-block-patterns-registry.php b/wp-includes/class-wp-block-patterns-registry.php index 3b5f053bfd..2afa8a853f 100644 --- a/wp-includes/class-wp-block-patterns-registry.php +++ b/wp-includes/class-wp-block-patterns-registry.php @@ -188,7 +188,7 @@ final class WP_Block_Patterns_Registry { * @since 5.5.0 * * @param string $pattern_name Block pattern name including namespace. - * @return array Registered pattern properties. + * @return array|null Registered pattern properties or `null` if the pattern is not registered. */ public function get_registered( $pattern_name ) { if ( ! $this->is_registered( $pattern_name ) ) { diff --git a/wp-includes/class-wp-block-styles-registry.php b/wp-includes/class-wp-block-styles-registry.php index 9a990173b4..8fb5e2eb23 100644 --- a/wp-includes/class-wp-block-styles-registry.php +++ b/wp-includes/class-wp-block-styles-registry.php @@ -140,7 +140,7 @@ final class WP_Block_Styles_Registry { * * @param string $block_name Block type name including namespace. * @param string $block_style_name Block style name. - * @return array Registered block style properties. + * @return array|null Registered block style properties or `null` if the block style is not registered. */ public function get_registered( $block_name, $block_style_name ) { if ( ! $this->is_registered( $block_name, $block_style_name ) ) { diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php index c6a0c6e24e..9fd6d1d00d 100644 --- a/wp-includes/pluggable.php +++ b/wp-includes/pluggable.php @@ -446,10 +446,10 @@ if ( ! function_exists( 'wp_mail' ) ) : $phpmailer->addAddress( $address, $recipient_name ); break; case 'cc': - $phpmailer->addCc( $address, $recipient_name ); + $phpmailer->addCC( $address, $recipient_name ); break; case 'bcc': - $phpmailer->addBcc( $address, $recipient_name ); + $phpmailer->addBCC( $address, $recipient_name ); break; case 'reply_to': $phpmailer->addReplyTo( $address, $recipient_name ); diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index d439629882..fac13c604c 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -396,7 +396,7 @@ function wp_default_packages_inline_scripts( $scripts ) { "\n", array( '( function() {', - ' var userId = ' . get_current_user_ID() . ';', + ' var userId = ' . get_current_user_id() . ';', ' var storageKey = "WP_DATA_USER_" + userId;', ' wp.data', ' .use( wp.data.plugins.persistence, { storageKey: storageKey } );', diff --git a/wp-includes/version.php b/wp-includes/version.php index a4d35d2b58..6e8679960d 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.9-alpha-60274'; +$wp_version = '6.9-alpha-60275'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.