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
This commit is contained in:
Sergey Biryukov 2023-01-30 14:15:16 +00:00
parent 5edb22187d
commit ff399d17fe
2 changed files with 9 additions and 9 deletions

View File

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

View File

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