Make WordPress Core

Changeset 53287


Ignore:
Timestamp:
04/26/2022 03:26:17 PM (2 years ago)
Author:
SergeyBiryukov
Message:

Code Modernization: Rename parameters that use reserved keywords in wp-includes/deprecated.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 $echo parameter to $display in:
    • the_category_ID()
    • get_author_link()
    • get_links()
    • get_category_rss_link()
    • get_author_rss_link()
  • Renames the $string parameter to $text in wp_specialchars().
  • Renames the $string parameter to $message in debug_fwrite().
  • Renames the $string parameter to $content in wp_kses_js_entities().

Follow-up to [52946], [52996], [52997], [52998], [53003], [53014], [53029], [53039], [53116], [53117], [53137], [53174], [53184], [53185], [53192], [53193], [53198], [53203], [53207], [53215], [53216], [53220], [53230], [53232], [53236], [53239], [53240], [53242], [53243], [53245], [53246], [53257], [53269], [53270], [53271], [53272], [53273], [53274], [53275], [53276], [53277], [53281], [53283], [53284], [53285].

Props jrf, aristath, poena, justinahinon, SergeyBiryukov.
See #55327.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/deprecated.php

    r53160 r53287  
    7777 * @see get_the_category()
    7878 *
    79  * @param bool $echo Optional. Whether to echo the output. Default true.
     79 * @param bool $display Optional. Whether to display the output. Default true.
    8080 * @return int Category ID.
    8181 */
    82 function the_category_ID($echo = true) {
     82function the_category_ID($display = true) {
    8383    _deprecated_function( __FUNCTION__, '0.71', 'get_the_category()' );
    8484
     
    8787    $cat = $categories[0]->term_id;
    8888
    89     if ( $echo )
     89    if ( $display )
    9090        echo $cat;
    9191
     
    796796 * @see get_author_posts_url()
    797797 *
    798  * @param bool $echo
     798 * @param bool $display
    799799 * @param int $author_id
    800800 * @param string $author_nicename Optional.
    801801 * @return string|null
    802802 */
    803 function get_author_link($echo, $author_id, $author_nicename = '') {
     803function get_author_link($display, $author_id, $author_nicename = '') {
    804804    _deprecated_function( __FUNCTION__, '2.1.0', 'get_author_posts_url()' );
    805805
    806806    $link = get_author_posts_url($author_id, $author_nicename);
    807807
    808     if ( $echo )
     808    if ( $display )
    809809        echo $link;
    810810    return $link;
     
    940940 *                                 Default -1.
    941941 * @param int    $show_updated     Optional. Whether to show last updated timestamp. Default 1.
    942  * @param bool   $echo             Whether to echo the results, or return them instead.
     942 * @param bool   $display          Whether to display the results, or return them instead.
    943943 * @return null|string
    944944 */
    945945function get_links($category = -1, $before = '', $after = '<br />', $between = ' ', $show_images = true, $orderby = 'name',
    946             $show_description = true, $show_rating = false, $limit = -1, $show_updated = 1, $echo = true) {
     946            $show_description = true, $show_rating = false, $limit = -1, $show_updated = 1, $display = true) {
    947947    _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' );
    948948
     
    10191019    } // End while.
    10201020
    1021     if ( !$echo )
     1021    if ( !$display )
    10221022        return $output;
    10231023    echo $output;
     
    11501150 * @see get_category_feed_link()
    11511151 *
    1152  * @param bool $echo
     1152 * @param bool $display
    11531153 * @param int $cat_ID
    11541154 * @return string
    11551155 */
    1156 function get_category_rss_link($echo = false, $cat_ID = 1) {
     1156function get_category_rss_link($display = false, $cat_ID = 1) {
    11571157    _deprecated_function( __FUNCTION__, '2.5.0', 'get_category_feed_link()' );
    11581158
    11591159    $link = get_category_feed_link($cat_ID, 'rss2');
    11601160
    1161     if ( $echo )
     1161    if ( $display )
    11621162        echo $link;
    11631163    return $link;
     
    11711171 * @see get_author_feed_link()
    11721172 *
    1173  * @param bool $echo
     1173 * @param bool $display
    11741174 * @param int $author_id
    11751175 * @return string
    11761176 */
    1177 function get_author_rss_link($echo = false, $author_id = 1) {
     1177function get_author_rss_link($display = false, $author_id = 1) {
    11781178    _deprecated_function( __FUNCTION__, '2.5.0', 'get_author_feed_link()' );
    11791179
    11801180    $link = get_author_feed_link($author_id);
    1181     if ( $echo )
     1181    if ( $display )
    11821182        echo $link;
    11831183    return $link;
     
    20712071 * @see esc_html()
    20722072 *
    2073  * @param string       $string        String to escape.
     2073 * @param string       $text          Text to escape.
    20742074 * @param string       $quote_style   Unused.
    20752075 * @param false|string $charset       Unused.
    20762076 * @param false        $double_encode Whether to double encode. Unused.
    2077  * @return string Escaped `$string`.
    2078  */
    2079 function wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false ) {
     2077 * @return string Escaped `$text`.
     2078 */
     2079function wp_specialchars( $text, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false ) {
    20802080    _deprecated_function( __FUNCTION__, '2.8.0', 'esc_html()' );
    20812081    if ( func_num_args() > 1 ) { // Maintain back-compat for people passing additional arguments.
    2082         return _wp_specialchars( $string, $quote_style, $charset, $double_encode );
     2082        return _wp_specialchars( $text, $quote_style, $charset, $double_encode );
    20832083    } else {
    2084         return esc_html( $string );
     2084        return esc_html( $text );
    20852085    }
    20862086}
     
    28592859 * @link https://www.php.net/manual/en/function.error-log.php
    28602860 *
    2861  * @param mixed  $fp     Unused.
    2862  * @param string $string Message to log.
    2863  */
    2864 function debug_fwrite( $fp, $string ) {
     2861 * @param mixed  $fp      Unused.
     2862 * @param string $message Message to log.
     2863 */
     2864function debug_fwrite( $fp, $message ) {
    28652865    _deprecated_function( __FUNCTION__, '3.4.0', 'error_log()' );
    28662866    if ( ! empty( $GLOBALS['debug'] ) )
    2867         error_log( $string );
     2867        error_log( $message );
    28682868}
    28692869
     
    38213821 * @deprecated 4.7.0 Officially dropped security support for Netscape 4.
    38223822 *
    3823  * @param string $string
     3823 * @param string $content
    38243824 * @return string
    38253825 */
    3826 function wp_kses_js_entities( $string ) {
     3826function wp_kses_js_entities( $content ) {
    38273827    _deprecated_function( __FUNCTION__, '4.7.0' );
    38283828
    3829     return preg_replace( '%&\s*\{[^}]*(\}\s*;?|$)%', '', $string );
     3829    return preg_replace( '%&\s*\{[^}]*(\}\s*;?|$)%', '', $content );
    38303830}
    38313831
Note: See TracChangeset for help on using the changeset viewer.