From e2cd808b34e0b02225876207ca4d7a50e328a2b4 Mon Sep 17 00:00:00 2001 From: Meirza Date: Thu, 26 Jan 2023 09:58:14 +0700 Subject: [PATCH] MDL-76415 core: Fixed ${var} string interpolation deprecations. Since PHP 8.2, placing the dollar sign outside the curly brace is deprecated when the expression inside the braces resolves to a variable or an expression. --- lib/classes/lock/lock_config.php | 2 +- lib/dml/tests/dml_test.php | 8 ++++---- .../atto/tests/behat/behat_editor_atto.php | 8 ++++---- .../tests/behat/behat_editor_textarea.php | 4 ++-- lib/editor/tiny/classes/editor.php | 4 ++-- .../tiny/tests/behat/behat_editor_tiny.php | 16 ++++++++-------- lib/phpminimumversionlib.php | 2 +- lib/tests/component_test.php | 2 +- lib/tests/weblib_test.php | 2 +- 9 files changed, 24 insertions(+), 24 deletions(-) diff --git a/lib/classes/lock/lock_config.php b/lib/classes/lock/lock_config.php index 2c00028bc1f..30178089009 100644 --- a/lib/classes/lock/lock_config.php +++ b/lib/classes/lock/lock_config.php @@ -60,7 +60,7 @@ class lock_config { $dbtype = clean_param($DB->get_dbfamily(), PARAM_ALPHA); // DB Specific lock factory is preferred - should support auto-release. - $lockfactoryclass = "\\core\\lock\\${dbtype}_lock_factory"; + $lockfactoryclass = "\\core\\lock\\{$dbtype}_lock_factory"; if (!class_exists($lockfactoryclass)) { $lockfactoryclass = '\core\lock\file_lock_factory'; } diff --git a/lib/dml/tests/dml_test.php b/lib/dml/tests/dml_test.php index fc96ae168b2..0667f73b517 100644 --- a/lib/dml/tests/dml_test.php +++ b/lib/dml/tests/dml_test.php @@ -6292,10 +6292,10 @@ EOD; ['description' => $description, 'version' => $version] = $DB->get_server_info(); // MariaDB RPL_VERSION_HACK sanity check: "5.5.5" has never been released! $this->assertNotSame('5.5.5', $version, - "Found invalid DB server version i.e. RPL_VERSION_HACK: '${version}' (${description})."); + "Found invalid DB server version i.e. RPL_VERSION_HACK: '{$version}' ({$description})."); // DB version format is: "X.Y.Z". $this->assertMatchesRegularExpression('/^\d+\.\d+\.\d+$/', $version, - "Found invalid DB server version format: '${version}' (${description})."); + "Found invalid DB server version format: '{$version}' ({$description})."); // Alter the DB options to force the read from DB and check for the same assertions above. $cfg->dboptions['versionfromdb'] = true; @@ -6309,9 +6309,9 @@ EOD; $this->assertTrue($rcm->invokeArgs($db2, []), 'Invalid test state!'); ['description' => $description, 'version' => $version] = $db2->get_server_info(); $this->assertNotSame('5.5.5', $version, - "Found invalid DB server version when reading version from DB i.e. RPL_VERSION_HACK: '${version}' (${description})."); + "Found invalid DB server version when reading version from DB i.e. RPL_VERSION_HACK: '{$version}' ({$description})."); $this->assertMatchesRegularExpression('/^\d+\.\d+\.\d+$/', $version, - "Found invalid DB server version format when reading version from DB: '${version}' (${description})."); + "Found invalid DB server version format when reading version from DB: '{$version}' ({$description})."); $db2->dispose(); } } diff --git a/lib/editor/atto/tests/behat/behat_editor_atto.php b/lib/editor/atto/tests/behat/behat_editor_atto.php index 66aae827e91..c4969f09555 100644 --- a/lib/editor/atto/tests/behat/behat_editor_atto.php +++ b/lib/editor/atto/tests/behat/behat_editor_atto.php @@ -49,13 +49,13 @@ class behat_editor_atto extends behat_base implements \core_behat\settable_edito public function set_editor_value(string $editorid, string $value): void { $js = << { Tiny.setupForElementId({ - elementId: "${elementid}", - options: ${configoptions}, + elementId: "{$elementid}", + options: {$configoptions}, }); M.util.js_complete('editor_tiny/editor'); }); diff --git a/lib/editor/tiny/tests/behat/behat_editor_tiny.php b/lib/editor/tiny/tests/behat/behat_editor_tiny.php index f0213ba7649..2eb915db282 100644 --- a/lib/editor/tiny/tests/behat/behat_editor_tiny.php +++ b/lib/editor/tiny/tests/behat/behat_editor_tiny.php @@ -50,7 +50,7 @@ class behat_editor_tiny extends behat_base implements \core_behat\settable_edito protected function execute_javascript_for_editor(string $editorid, string $code): void { $js = << { - const instance = editor.getInstanceForElementId('${editorid}'); + const instance = editor.getInstanceForElementId('{$editorid}'); {$code} }); EOF; @@ -72,9 +72,9 @@ class behat_editor_tiny extends behat_base implements \core_behat\settable_edito $js = << { require(['editor_tiny/editor'], (editor) => { - const instance = editor.getInstanceForElementId('${editorid}'); + const instance = editor.getInstanceForElementId('{$editorid}'); if (!instance) { - reject("Instance '${editorid}' not found"); + reject("Instance '{$editorid}' not found"); } {$code} @@ -101,7 +101,7 @@ class behat_editor_tiny extends behat_base implements \core_behat\settable_edito } $this->execute_javascript_for_editor($editorid, << $attributes) { // Message, to be used later and easier finding the problem. - $message = "Validation problem found with API: ${apiname}"; + $message = "Validation problem found with API: {$apiname}"; $this->assertIsObject($attributes, $message); $this->assertMatchesRegularExpression('/^[a-z][a-z0-9]+$/', $apiname, $message); diff --git a/lib/tests/weblib_test.php b/lib/tests/weblib_test.php index 561b64a48df..202ac33cc30 100644 --- a/lib/tests/weblib_test.php +++ b/lib/tests/weblib_test.php @@ -881,7 +881,7 @@ EXPECTED; $url1 = "{$CFG->wwwroot}/draftfile.php/5/user/draft/99999999/test1.jpg"; $url2 = "{$CFG->wwwroot}/draftfile.php/5/user/draft/99999998/test2.jpg"; - $html = "

This is a test.

\"\"

+ $html = "

This is a test.

\"\"


Test content.

\"\"

"; $draftareas = array(