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
This commit is contained in:
John Blackbourn
2025-06-03 16:51:33 +00:00
parent f11ca907a0
commit 41e25d6802
13 changed files with 15 additions and 15 deletions

View File

@@ -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':

View File

@@ -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 ) ) {

View File

@@ -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;
}

View File

@@ -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 );

View File

@@ -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 );

View File

@@ -253,7 +253,7 @@ function get_the_block_template_html() {
if ( is_user_logged_in() ) {
return '<h1>' . esc_html__( 'No matching template found' ) . '</h1>';
}
return;
return '';
}
$content = $wp_embed->run_shortcode( $_wp_current_template_content );

View File

@@ -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 );
}
/**

View File

@@ -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 ) ) {

View File

@@ -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 ) ) {

View File

@@ -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 ) ) {

View File

@@ -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 );

View File

@@ -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 } );',

View File

@@ -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.