Make WordPress Core

Changeset 54134


Ignore:
Timestamp:
09/12/2022 05:50:36 PM (21 months ago)
Author:
SergeyBiryukov
Message:

Code Modernization: Replace deprecated string interpolation patterns.

PHP 8.2 deprecates string interpolation patterns that place the dollar sign outside the curly braces:

echo "Hello ${name}";

This commit fixes such patterns by replacing them with proper curly braced patterns:

echo "Hello {$name}";

This addresses Deprecated: Using ${var} in strings is deprecated, use {$var} instead notices when running tests on PHP 8.2.

References:

Follow-up to [10584], [31733], [42360], [53922].

Props ayeshrajans, jrf.
Fixes #55787.

Location:
trunk
Files:
3 edited

Legend:

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

    r53888 r54134  
    17391739
    17401740        foreach ( $data_attributes as $name => $value ) {
    1741             $data_attribute_string .= " data-${name}=\"" . esc_attr( $value ) . '"';
     1741            $data_attribute_string .= " data-{$name}=\"" . esc_attr( $value ) . '"';
    17421742        }
    17431743
  • trunk/src/wp-includes/pomo/po.php

    r52640 r54134  
    127127            $string = str_replace( array_keys( $replaces ), array_values( $replaces ), $string );
    128128
    129             $po = $quote . implode( "${slash}n$quote$newline$quote", explode( $newline, $string ) ) . $quote;
     129            $po = $quote . implode( "{$slash}n{$quote}{$newline}{$quote}", explode( $newline, $string ) ) . $quote;
    130130            // Add empty string on first line for readbility.
    131131            if ( false !== strpos( $string, $newline ) &&
  • trunk/tests/phpunit/tests/formatting/convertSmilies.php

    r53562 r54134  
    2020            array(
    2121                'Lorem ipsum dolor sit amet mauris ;-) Praesent gravida sodales. :lol: Vivamus nec diam in faucibus eu, bibendum varius nec, imperdiet purus est, at augue at lacus malesuada elit dapibus a, :eek: mauris. Cras mauris viverra elit. Nam laoreet viverra. Pellentesque tortor. Nam libero ante, porta urna ut turpis. Nullam wisi magna, :mrgreen: tincidunt nec, sagittis non, fringilla enim. Nam consectetuer nec, ullamcorper pede eu dui odio consequat vel, vehicula tortor quis pede turpis cursus quis, egestas ipsum ultricies ut, eleifend velit. Mauris vestibulum iaculis. Sed in nunc. Vivamus elit porttitor egestas. Mauris purus :?:',
    22                 "Lorem ipsum dolor sit amet mauris \xf0\x9f\x98\x89 Praesent gravida sodales. \xf0\x9f\x98\x86 Vivamus nec diam in faucibus eu, bibendum varius nec, imperdiet purus est, at augue at lacus malesuada elit dapibus a, \xf0\x9f\x98\xae mauris. Cras mauris viverra elit. Nam laoreet viverra. Pellentesque tortor. Nam libero ante, porta urna ut turpis. Nullam wisi magna, <img src=\"${includes_path}mrgreen.png\" alt=\":mrgreen:\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" /> tincidunt nec, sagittis non, fringilla enim. Nam consectetuer nec, ullamcorper pede eu dui odio consequat vel, vehicula tortor quis pede turpis cursus quis, egestas ipsum ultricies ut, eleifend velit. Mauris vestibulum iaculis. Sed in nunc. Vivamus elit porttitor egestas. Mauris purus \xe2\x9d\x93",
     22                "Lorem ipsum dolor sit amet mauris \xf0\x9f\x98\x89 Praesent gravida sodales. \xf0\x9f\x98\x86 Vivamus nec diam in faucibus eu, bibendum varius nec, imperdiet purus est, at augue at lacus malesuada elit dapibus a, \xf0\x9f\x98\xae mauris. Cras mauris viverra elit. Nam laoreet viverra. Pellentesque tortor. Nam libero ante, porta urna ut turpis. Nullam wisi magna, <img src=\"{$includes_path}mrgreen.png\" alt=\":mrgreen:\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" /> tincidunt nec, sagittis non, fringilla enim. Nam consectetuer nec, ullamcorper pede eu dui odio consequat vel, vehicula tortor quis pede turpis cursus quis, egestas ipsum ultricies ut, eleifend velit. Mauris vestibulum iaculis. Sed in nunc. Vivamus elit porttitor egestas. Mauris purus \xe2\x9d\x93",
    2323            ),
    2424            array(
Note: See TracChangeset for help on using the changeset viewer.