From bed2ece03ad795f86dea2b790f0b9b10be233411 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Tue, 7 Nov 2023 12:48:01 +0800 Subject: [PATCH] MDL-79890 core: Stop using get_class() without args PHP 8.3 deprecates the use of `get_class()` without arguments. The following alternatives should instead be used as appropriate: - `get_class($this)` - The equivalent for instance methods - `self::class` - The current class Note that the behaviour of `get_class()` in a static method was equivalent to `self::class` and _not_ `static::class`. That is to say that the previous behaviour did not respect late static binding. --- admin/tool/usertours/classes/local/target/block.php | 2 +- admin/tool/usertours/classes/local/target/selector.php | 2 +- admin/tool/usertours/classes/local/target/unattached.php | 2 +- lib/google/readme_moodle.txt | 2 ++ lib/google/src/Google/Http/REST.php | 2 +- 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/admin/tool/usertours/classes/local/target/block.php b/admin/tool/usertours/classes/local/target/block.php index 3f38f0a9062..095e9018c4c 100644 --- a/admin/tool/usertours/classes/local/target/block.php +++ b/admin/tool/usertours/classes/local/target/block.php @@ -102,7 +102,7 @@ class block extends base { */ public static function add_disabled_constraints_to_form(\MoodleQuickForm $mform) { $mform->hideIf('targetvalue_block', 'targettype', 'noteq', - \tool_usertours\target::get_target_constant_for_class(get_class())); + \tool_usertours\target::get_target_constant_for_class(self::class)); } /** diff --git a/admin/tool/usertours/classes/local/target/selector.php b/admin/tool/usertours/classes/local/target/selector.php index 3e3fd58c325..b0cc92682f0 100644 --- a/admin/tool/usertours/classes/local/target/selector.php +++ b/admin/tool/usertours/classes/local/target/selector.php @@ -92,7 +92,7 @@ class selector extends base { */ public static function add_disabled_constraints_to_form(\MoodleQuickForm $mform) { $mform->hideIf('targetvalue_selector', 'targettype', 'noteq', - \tool_usertours\target::get_target_constant_for_class(get_class())); + \tool_usertours\target::get_target_constant_for_class(self::class)); } /** diff --git a/admin/tool/usertours/classes/local/target/unattached.php b/admin/tool/usertours/classes/local/target/unattached.php index 696efe57241..316fdea4b85 100644 --- a/admin/tool/usertours/classes/local/target/unattached.php +++ b/admin/tool/usertours/classes/local/target/unattached.php @@ -81,7 +81,7 @@ class unattached extends base { * @param MoodleQuickForm $mform The form to add configuration to. */ public static function add_disabled_constraints_to_form(\MoodleQuickForm $mform) { - $myvalue = \tool_usertours\target::get_target_constant_for_class(get_class()); + $myvalue = \tool_usertours\target::get_target_constant_for_class(self::class); foreach (array_keys(self::$forcedsettings) as $settingname) { $mform->hideIf($settingname, 'targettype', 'eq', $myvalue); diff --git a/lib/google/readme_moodle.txt b/lib/google/readme_moodle.txt index 16d6f9104bb..7c7f007e020 100644 --- a/lib/google/readme_moodle.txt +++ b/lib/google/readme_moodle.txt @@ -53,6 +53,8 @@ Local changes (to reapply until upstream upgrades contain them): cd lib/google/src for file in `find . -name '*.php' `; do sed -i '/^class /i #[AllowDynamicProperties]' $file; done ``` + * MDL-46563 - PHP 8.3 compliance + - Converted use of `get_class()` to `static::class` Information ----------- diff --git a/lib/google/src/Google/Http/REST.php b/lib/google/src/Google/Http/REST.php index 2d91326f8d5..e3489d28240 100644 --- a/lib/google/src/Google/Http/REST.php +++ b/lib/google/src/Google/Http/REST.php @@ -40,7 +40,7 @@ class Google_Http_REST $runner = new Google_Task_Runner( $client, sprintf('%s %s', $req->getRequestMethod(), $req->getUrl()), - array(get_class(), 'doExecute'), + array(self::class, 'doExecute'), array($client, $req) );