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:
* [https://php.watch/versions/8.2/$%7Bvar%7D-string-interpolation-deprecated PHP.Watch: PHP 8.2: ${var} string interpolation deprecated]
* [https://wiki.php.net/rfc/deprecate_dollar_brace_string_interpolation PHP RFC: Deprecate ${} string interpolation]

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

Props ayeshrajans, jrf.
Fixes #55787.
Built from https://develop.svn.wordpress.org/trunk@54134


git-svn-id: http://core.svn.wordpress.org/trunk@53693 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2022-09-12 17:52:08 +00:00
parent c03305852e
commit ca57157a39
3 changed files with 3 additions and 3 deletions

View File

@ -1738,7 +1738,7 @@ function get_comment_reply_link( $args = array(), $comment = null, $post = null
$data_attribute_string = '';
foreach ( $data_attributes as $name => $value ) {
$data_attribute_string .= " data-${name}=\"" . esc_attr( $value ) . '"';
$data_attribute_string .= " data-{$name}=\"" . esc_attr( $value ) . '"';
}
$data_attribute_string = trim( $data_attribute_string );

View File

@ -126,7 +126,7 @@ if ( ! class_exists( 'PO', false ) ) :
$string = str_replace( array_keys( $replaces ), array_values( $replaces ), $string );
$po = $quote . implode( "${slash}n$quote$newline$quote", explode( $newline, $string ) ) . $quote;
$po = $quote . implode( "{$slash}n{$quote}{$newline}{$quote}", explode( $newline, $string ) ) . $quote;
// Add empty string on first line for readbility.
if ( false !== strpos( $string, $newline ) &&
( substr_count( $string, $newline ) > 1 || substr( $string, -strlen( $newline ) ) !== $newline ) ) {

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.1-alpha-54133';
$wp_version = '6.1-alpha-54134';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.