From 7ed2467c3afa1a869e0c70acd362c96ba35d7c1a Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 26 Aug 2023 04:47:09 +0000 Subject: [PATCH] Docs: Fix typo in a translator comment in `_deprecated_class()`. Includes a few other formatting adjustments for consistency. Follow-up to [48327], [56467], [56471]. See #58833. git-svn-id: https://develop.svn.wordpress.org/trunk@56474 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/functions.php | 73 ++++++++++++++++++++++++----------- 1 file changed, 50 insertions(+), 23 deletions(-) diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index aa214eb4e5954..d2304f4d55c53 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -5413,9 +5413,8 @@ function absint( $maybeint ) { /** * Marks a function as deprecated and inform when it has been used. * - * There is a hook {@see 'deprecated_function_run'} that will be called that can be used - * to get the backtrace up to what file and function called the deprecated - * function. + * There is a {@see 'deprecated_function_run'} hook that will be called that can be used + * to get the backtrace up to what file and function called the deprecated function. * * The current behavior is to trigger a user error if `WP_DEBUG` is true. * @@ -5502,11 +5501,11 @@ function _deprecated_function( $function_name, $version, $replacement = '' ) { * Marks a constructor as deprecated and informs when it has been used. * * Similar to _deprecated_function(), but with different strings. Used to - * remove PHP4 style constructors. + * remove PHP4-style constructors. * * The current behavior is to trigger a user error if `WP_DEBUG` is true. * - * This function is to be used in every PHP4 style constructor method that is deprecated. + * This function is to be used in every PHP4-style constructor method that is deprecated. * * @since 4.3.0 * @since 4.5.0 Added the `$parent_class` parameter. @@ -5604,7 +5603,7 @@ function _deprecated_constructor( $class_name, $version, $parent_class = '' ) { * The current behavior is to trigger a user error if `WP_DEBUG` is true. * * This function is to be used in the class constructor for every deprecated class. - * See {@see _deprecated_constructor()} for deprecating PHP4 style constructors. + * See {@see _deprecated_constructor()} for deprecating PHP4-style constructors. * * @since 6.4.0 * @@ -5635,18 +5634,48 @@ function _deprecated_class( $class, $version, $replacement = '' ) { */ if ( WP_DEBUG && apply_filters( 'deprecated_class_trigger_error', true ) ) { if ( function_exists( '__' ) ) { - if ( ! is_null( $replacement ) ) { - /* translators: 1: PHP class name, 2: version number, 3: alternative clas or function name */ - trigger_error( sprintf( __( 'Class %1$s is deprecated since version %2$s! Use %3$s instead.' ), $class, $version, $replacement ), E_USER_DEPRECATED ); + if ( $replacement ) { + trigger_error( + sprintf( + /* translators: 1: PHP class name, 2: Version number, 3: Alternative class or function name. */ + __( 'Class %1$s is deprecated since version %2$s! Use %3$s instead.' ), + $class, + $version, + $replacement + ), + E_USER_DEPRECATED + ); } else { - /* translators: 1: PHP class name, 2: version number */ - trigger_error( sprintf( __( 'Class %1$s is deprecated since version %2$s with no alternative available.' ), $class, $version ), E_USER_DEPRECATED ); + trigger_error( + sprintf( + /* translators: 1: PHP class name, 2: Version number. */ + __( 'Class %1$s is deprecated since version %2$s with no alternative available.' ), + $class, + $version + ), + E_USER_DEPRECATED + ); } } else { - if ( ! is_null( $replacement ) ) { - trigger_error( sprintf( 'Class %1$s is deprecated since version %2$s! Use %3$s instead.', $class, $version, $replacement ), E_USER_DEPRECATED ); + if ( $replacement ) { + trigger_error( + sprintf( + 'Class %1$s is deprecated since version %2$s! Use %3$s instead.', + $class, + $version, + $replacement + ), + E_USER_DEPRECATED + ); } else { - trigger_error( sprintf( 'Class %1$s is deprecated since version %2$s with no alternative available.', $class, $version ), E_USER_DEPRECATED ); + trigger_error( + sprintf( + 'Class %1$s is deprecated since version %2$s with no alternative available.', + $class, + $version + ), + E_USER_DEPRECATED + ); } } } @@ -5655,9 +5684,8 @@ function _deprecated_class( $class, $version, $replacement = '' ) { /** * Marks a file as deprecated and inform when it has been used. * - * There is a hook {@see 'deprecated_file_included'} that will be called that can be used - * to get the backtrace up to what file and function included the deprecated - * file. + * There is a {@see 'deprecated_file_included'} hook that will be called that can be used + * to get the backtrace up to what file and function included the deprecated file. * * The current behavior is to trigger a user error if `WP_DEBUG` is true. * @@ -5750,15 +5778,15 @@ function _deprecated_file( $file, $version, $replacement = '', $message = '' ) { * This function is to be used whenever a deprecated function argument is used. * Before this function is called, the argument must be checked for whether it was * used by comparing it to its default value or evaluating whether it is empty. + * * For example: * * if ( ! empty( $deprecated ) ) { * _deprecated_argument( __FUNCTION__, '3.0.0' ); * } * - * There is a hook deprecated_argument_run that will be called that can be used - * to get the backtrace up to what file and function used the deprecated - * argument. + * There is a {@see 'deprecated_argument_run'} hook that will be called that can be used + * to get the backtrace up to what file and function used the deprecated argument. * * The current behavior is to trigger a user error if WP_DEBUG is true. * @@ -5911,9 +5939,8 @@ function _deprecated_hook( $hook, $version, $replacement = '', $message = '' ) { /** * Marks something as being incorrectly called. * - * There is a hook {@see 'doing_it_wrong_run'} that will be called that can be used - * to get the backtrace up to what file and function called the deprecated - * function. + * There is a {@see 'doing_it_wrong_run'} hook that will be called that can be used + * to get the backtrace up to what file and function called the deprecated function. * * The current behavior is to trigger a user error if `WP_DEBUG` is true. *