From 51e9aed3b70a2bc793761d876f58c5d799e4d733 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 30 Jan 2023 14:13:49 +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. git-svn-id: https://develop.svn.wordpress.org/trunk@55162 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/formatting.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php index d3d54c422f..c34f61e499 100644 --- a/src/wp-includes/formatting.php +++ b/src/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 ); } /**