From ff399d17fed2a037f9c59304a58e3e6821ba93a5 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 30 Jan 2023 14:15:16 +0000 Subject: [PATCH] Code Modernization: Rename parameters that use reserved keywords in `wp-includes/formatting.php`. While using reserved PHP keywords as parameter name labels is allowed, in the context of function calls using named parameters in PHP 8.0+, this will easily lead to confusion. To avoid that, it is recommended not to use reserved keywords as function parameter names. This commit renames the `$class` parameter to `$classname` in `sanitize_html_class()`. Follow-up to [54927]. See also: [search:?q=code+modernization+rename+parameters+that+use+reserved+keywords&changeset=on equivalent commits for other files]. Props jrf, aristath, poena, justinahinon, SergeyBiryukov. See #56788. Built from https://develop.svn.wordpress.org/trunk@55162 git-svn-id: http://core.svn.wordpress.org/trunk@54695 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/formatting.php | 16 ++++++++-------- wp-includes/version.php | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index d3d54c422f..c34f61e499 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -2405,14 +2405,14 @@ function sanitize_sql_orderby( $orderby ) { * * @since 2.8.0 * - * @param string $class The classname to be sanitized - * @param string $fallback Optional. The value to return if the sanitization ends up as an empty string. - * Defaults to an empty string. - * @return string The sanitized value + * @param string $classname The classname to be sanitized. + * @param string $fallback Optional. The value to return if the sanitization ends up as an empty string. + * Default empty string. + * @return string The sanitized value. */ -function sanitize_html_class( $class, $fallback = '' ) { +function sanitize_html_class( $classname, $fallback = '' ) { // Strip out any %-encoded octets. - $sanitized = preg_replace( '|%[a-fA-F0-9][a-fA-F0-9]|', '', $class ); + $sanitized = preg_replace( '|%[a-fA-F0-9][a-fA-F0-9]|', '', $classname ); // Limit to A-Z, a-z, 0-9, '_', '-'. $sanitized = preg_replace( '/[^A-Za-z0-9_-]/', '', $sanitized ); @@ -2426,10 +2426,10 @@ function sanitize_html_class( $class, $fallback = '' ) { * @since 2.8.0 * * @param string $sanitized The sanitized HTML class. - * @param string $class HTML class before sanitization. + * @param string $classname HTML class before sanitization. * @param string $fallback The fallback string. */ - return apply_filters( 'sanitize_html_class', $sanitized, $class, $fallback ); + return apply_filters( 'sanitize_html_class', $sanitized, $classname, $fallback ); } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index a60e8c6130..9804c5bb4c 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.2-alpha-55161'; +$wp_version = '6.2-alpha-55162'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.