From a4b163a674970f9d388f57feb4c30aa129eaf23f Mon Sep 17 00:00:00 2001 From: hellofromTonya Date: Thu, 9 Sep 2021 19:21:57 +0000 Subject: [PATCH] Code Modernization: Fix parameter name mismatches for parent/child classes in `WP_Sitemaps_Provider::get_url_list()`. In each child and grandchild class, renames the second 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. Adds @since to clearly specify why the change happened. Reassigns the generic parameter to the original parameter. Why? Restoring the original name keeps the context intact within the method and makes the code more readable. An inline comment explains why this reassignment is made. Follow-up to [48072]. Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion. See #51553. Built from https://develop.svn.wordpress.org/trunk@51787 git-svn-id: http://core.svn.wordpress.org/trunk@51394 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../sitemaps/providers/class-wp-sitemaps-posts.php | 12 +++++++++--- .../providers/class-wp-sitemaps-taxonomies.php | 10 +++++++--- wp-includes/version.php | 2 +- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/wp-includes/sitemaps/providers/class-wp-sitemaps-posts.php b/wp-includes/sitemaps/providers/class-wp-sitemaps-posts.php index 56acfb7697..c9d982ddce 100644 --- a/wp-includes/sitemaps/providers/class-wp-sitemaps-posts.php +++ b/wp-includes/sitemaps/providers/class-wp-sitemaps-posts.php @@ -53,12 +53,18 @@ class WP_Sitemaps_Posts extends WP_Sitemaps_Provider { * Gets a URL list for a post type sitemap. * * @since 5.5.0 + * @since 5.9.0 Renamed `$post_type` to `$object_subtype` to match parent class + * for PHP 8 named parameter support. + * + * @param int $page_num Page of results. + * @param string $object_subtype Optional. Post type name. Default empty. * - * @param int $page_num Page of results. - * @param string $post_type Optional. Post type name. Default empty. * @return array Array of URLs for a sitemap. */ - public function get_url_list( $page_num, $post_type = '' ) { + public function get_url_list( $page_num, $object_subtype = '' ) { + // Restores the more descriptive, specific name for use within this method. + $post_type = $object_subtype; + // Bail early if the queried post type is not supported. $supported_types = $this->get_object_subtypes(); diff --git a/wp-includes/sitemaps/providers/class-wp-sitemaps-taxonomies.php b/wp-includes/sitemaps/providers/class-wp-sitemaps-taxonomies.php index e8fcc6d5ab..f5b6bb631a 100644 --- a/wp-includes/sitemaps/providers/class-wp-sitemaps-taxonomies.php +++ b/wp-includes/sitemaps/providers/class-wp-sitemaps-taxonomies.php @@ -51,12 +51,16 @@ class WP_Sitemaps_Taxonomies extends WP_Sitemaps_Provider { * Gets a URL list for a taxonomy sitemap. * * @since 5.5.0 + * @since 5.9.0 Renamed `$taxonomy` to `$object_subtype` to match parent class + * for PHP 8 named parameter support. * - * @param int $page_num Page of results. - * @param string $taxonomy Optional. Taxonomy name. Default empty. + * @param int $page_num Page of results. + * @param string $object_subtype Optional. Taxonomy name. Default empty. * @return array Array of URLs for a sitemap. */ - public function get_url_list( $page_num, $taxonomy = '' ) { + public function get_url_list( $page_num, $object_subtype = '' ) { + // Restores the more descriptive, specific name for use within this method. + $taxonomy = $object_subtype; $supported_types = $this->get_object_subtypes(); // Bail early if the queried taxonomy is not supported. diff --git a/wp-includes/version.php b/wp-includes/version.php index 11d347449b..b4a0d52faf 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.9-alpha-51786'; +$wp_version = '5.9-alpha-51787'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.