PHP 8.2: fix "Using ${var} in strings is deprecated, use {$var} instead" (https://github.com/woocommerce/woocommerce-blocks/pull/7782)

PHP 8.2 deprecated using ${var} in strings
(https://kinsta.com/blog/php-8-2/#deprecate--string-interpolation). {$var}
should be used instead. This commit fixes the occurrences of ${var} in
woocommerce-blocks to prepare for the next version of PHP which is
scheduled to be released early in December.

I found this in the context of testing MailPoet with PHP 8.2. I'm not
familiar with the woocommerce-blocks so I might be missing something. I did
not test the changes in this commit.
This commit is contained in:
Rodrigo Primo 2022-12-29 09:13:15 -03:00 committed by GitHub
parent 78d8f1a626
commit 077c8fa3ff
2 changed files with 3 additions and 3 deletions

View File

@ -83,7 +83,7 @@ class RoutesController {
$route = $this->routes[ $version ][ $name ] ?? false;
if ( ! $route ) {
throw new \Exception( "${name} {$version} route does not exist" );
throw new \Exception( "{$name} {$version} route does not exist" );
}
return new $route(

View File

@ -63,10 +63,10 @@ class SchemaController {
* @return Schemas\V1\AbstractSchema A new instance of the requested schema.
*/
public function get( $name, $version = 1 ) {
$schema = $this->schemas[ "v${version}" ][ $name ] ?? false;
$schema = $this->schemas[ "v{$version}" ][ $name ] ?? false;
if ( ! $schema ) {
throw new \Exception( "${name} v{$version} schema does not exist" );
throw new \Exception( "{$name} v{$version} schema does not exist" );
}
return new $schema( $this->extend, $this );