Skip to content

Commit

Permalink
MDL-79890 core: Stop using get_class() without args
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
andrewnicols committed Nov 15, 2023
1 parent 4e03a11 commit bed2ece
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion admin/tool/usertours/classes/local/target/block.php
Expand Up @@ -102,7 +102,7 @@ public static function add_config_to_form(\MoodleQuickForm $mform) {
*/
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));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/usertours/classes/local/target/selector.php
Expand Up @@ -92,7 +92,7 @@ public static function add_config_to_form(\MoodleQuickForm $mform) {
*/
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));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/usertours/classes/local/target/unattached.php
Expand Up @@ -81,7 +81,7 @@ public static function add_config_to_form(\MoodleQuickForm $mform) {
* @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);
Expand Down
2 changes: 2 additions & 0 deletions lib/google/readme_moodle.txt
Expand Up @@ -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
-----------
Expand Down
2 changes: 1 addition & 1 deletion lib/google/src/Google/Http/REST.php
Expand Up @@ -40,7 +40,7 @@ public static function execute(Google_Client $client, Google_Http_Request $req)
$runner = new Google_Task_Runner(
$client,
sprintf('%s %s', $req->getRequestMethod(), $req->getUrl()),
array(get_class(), 'doExecute'),
array(self::class, 'doExecute'),
array($client, $req)
);

Expand Down

0 comments on commit bed2ece

Please sign in to comment.