moodle-cs
moodle-cs copied to clipboard
magic __construct() in anonymous class cause error
Hi
Is usage of magic __construct() in derived classes restricted by policy?
Code:
# auth/emailotp/settings.php
#(...)
$settings->add(new class(
'auth_emailotp/minrequestperiod',
get_string('minrequestperiod', 'auth_emailotp'),
get_string('minrequestperiod_help', 'auth_emailotp')
) extends admin_setting_configtext {
public function __construct($name, $visiblename, $description) {
$logreader = reset(get_log_manager()->get_readers('\core\log\sql_reader'));
parent::__construct($name, $visiblename, $description, $logreader ? 120 : 0, PARAM_INT);
if (!$logreader && !empty($this->get_setting())) {
$this->description .= ' '.get_string('logstorerequired', 'auth_emailotp',
(string)new moodle_url('/admin/settings.php', ['section' => 'managelogging'])
);
}
}
});
gives codechecker error:
moodlehq/moodle-local_codechecker#67: ········public·function·__construct($name,·$visiblename,·$description)·{
Function name "__construct" is invalid; only PHP magic methods should be prefixed with a double underscore
version: 2020100200