Code Modernization: Fix parameter name mismatches for parent/child classes in `WP_Upgrader_Skin::error()`.

In each child class: renames the parameter to match the parent's method signature.

Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.

Changes for readability:

- `@since` clearly specifies the original parameter name and its new name as well as why the change happened.

Follow-up to [11005], [25806], [32655], [38199].

Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51782


git-svn-id: http://core.svn.wordpress.org/trunk@51389 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
hellofromTonya 2021-09-09 13:59:56 +00:00
parent 03331f52ff
commit 5887edee86
4 changed files with 17 additions and 13 deletions

View File

@ -89,18 +89,20 @@ class Bulk_Upgrader_Skin extends WP_Upgrader_Skin {
}
/**
* @param string|WP_Error $error
* @since 5.9.0 Renamed `$error` to `$errors` for PHP 8 named parameter support.
*
* @param string|WP_Error $errors Errors.
*/
public function error( $error ) {
if ( is_string( $error ) && isset( $this->upgrader->strings[ $error ] ) ) {
$this->error = $this->upgrader->strings[ $error ];
public function error( $errors ) {
if ( is_string( $errors ) && isset( $this->upgrader->strings[ $errors ] ) ) {
$this->error = $this->upgrader->strings[ $errors ];
}
if ( is_wp_error( $error ) ) {
if ( is_wp_error( $errors ) ) {
$messages = array();
foreach ( $error->get_error_messages() as $emessage ) {
if ( $error->get_error_data() && is_string( $error->get_error_data() ) ) {
$messages[] = $emessage . ' ' . esc_html( strip_tags( $error->get_error_data() ) );
foreach ( $errors->get_error_messages() as $emessage ) {
if ( $errors->get_error_data() && is_string( $errors->get_error_data() ) ) {
$messages[] = $emessage . ' ' . esc_html( strip_tags( $errors->get_error_data() ) );
} else {
$messages[] = $emessage;
}

View File

@ -52,11 +52,13 @@ class Language_Pack_Upgrader_Skin extends WP_Upgrader_Skin {
}
/**
* @param string|WP_Error $error
* @since 5.9.0 Renamed `$error` to `$errors` for PHP 8 named parameter support.
*
* @param string|WP_Error $errors Errors.
*/
public function error( $error ) {
public function error( $errors ) {
echo '<div class="lp-error">';
parent::error( $error );
parent::error( $errors );
echo '</div>';
}

View File

@ -165,7 +165,7 @@ class WP_Upgrader_Skin {
/**
* @since 2.8.0
*
* @param string|WP_Error $errors
* @param string|WP_Error $errors Errors.
*/
public function error( $errors ) {
if ( ! $this->done_header ) {

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.9-alpha-51781';
$wp_version = '5.9-alpha-51782';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.