MDL-81634 core: Fix all implicitly defined nullables

Note: This does not impact third-party libraries.
This commit is contained in:
Andrew Nicols 2024-08-02 13:42:14 +08:00
parent 8a6e8563fd
commit 024e36be17
No known key found for this signature in database
GPG Key ID: 6D1E3157C8CFBF14
391 changed files with 782 additions and 782 deletions

View File

@ -62,7 +62,7 @@ class filesize extends \admin_setting {
* @param int|null $defaultunit GB, MB, etc. (in bytes)
*/
public function __construct(string $name, string $visiblename, string $description,
int $defaultvalue = null, int $defaultunit = null) {
?int $defaultvalue = null, ?int $defaultunit = null) {
$defaultsetting = self::parse_bytes($defaultvalue);

View File

@ -424,7 +424,7 @@ class manager_test extends \advanced_testcase {
* @param string|null $expectedpresetname Expected preset name.
*/
public function test_import_preset(string $filecontents, bool $expectedpreset, bool $expectedsettings = false,
bool $expectedplugins = false, bool $expecteddebugging = false, string $expectedexception = null,
bool $expectedplugins = false, bool $expecteddebugging = false, ?string $expectedexception = null,
string $expectedpresetname = 'Imported preset'): void {
global $DB;

View File

@ -1288,7 +1288,7 @@ class core_admin_renderer extends plugin_renderer_base {
* @param null|moodle_url $cancel URL for the cancel link, defaults to the current page
* @return string HTML
*/
public function plugins_management_confirm_buttons(moodle_url $continue=null, moodle_url $cancel=null) {
public function plugins_management_confirm_buttons(?moodle_url $continue=null, ?moodle_url $cancel=null) {
$out = html_writer::start_div('plugins-management-confirm-buttons');

View File

@ -44,7 +44,7 @@ class import_test extends \advanced_testcase {
* @param string|null $expectedpresetname Expected preset name.
*/
public function test_import_execute(string $filecontents, bool $expectedpreset, bool $expectedsettings = false,
bool $expectedplugins = false, bool $expecteddebugging = false, string $expectedexception = null,
bool $expectedplugins = false, bool $expecteddebugging = false, ?string $expectedexception = null,
string $expectedpresetname = 'Imported preset'): void {
global $DB, $USER;

View File

@ -198,7 +198,7 @@ class brickfieldconnect extends curl {
* @param null|string $secretkey The secret key to use
* @return null|string The registration ID if registration was successful, or null if not
*/
protected function get_registration_id_for_credentials(string $apikey = null, string $secretkey = null): string {
protected function get_registration_id_for_credentials(?string $apikey = null, ?string $secretkey = null): string {
$headers = $this->get_common_headers();
if ($apikey || $secretkey) {
$headers['secret'] = $apikey;

View File

@ -157,7 +157,7 @@ class filter {
* @throws \coding_exception
* @throws \dml_exception
*/
public function can_access(\context $context = null, string $capability = ''): bool {
public function can_access(?\context $context = null, string $capability = ''): bool {
if ($capability == '') {
if ($this->has_course_filters()) {
$capability = accessibility::get_capability_name('viewcoursetools');
@ -176,7 +176,7 @@ class filter {
* @throws \coding_exception
* @throws \dml_exception
*/
public function has_capability_in_context(string $capability, \context $context = null): bool {
public function has_capability_in_context(string $capability, ?\context $context = null): bool {
$coursefiltersvalid = $this->has_course_filters();
if ($context === null) {
// If the filter is using a list of courses ($this->>courseids), use the system context.

View File

@ -236,7 +236,7 @@ abstract class tool {
* @throws \coding_exception
* @throws \dml_exception
*/
public function can_access(filter $filter, \context $context = null): bool {
public function can_access(filter $filter, ?\context $context = null): bool {
return $filter->can_access($context);
}
@ -309,7 +309,7 @@ abstract class tool {
* @param filter|null $filter
* @return array
*/
public static function toplevel_arguments(filter $filter = null): array {
public static function toplevel_arguments(?filter $filter = null): array {
if ($filter !== null) {
return ['courseid' => $filter->courseid, 'categoryid' => $filter->categoryid];
} else {

View File

@ -598,7 +598,7 @@ class manager {
* @throws \coding_exception
* @throws \dml_exception
*/
public static function store_result_summary(int $courseid = null) {
public static function store_result_summary(?int $courseid = null) {
global $DB;
if (static::is_okay_to_cache() && ($courseid == null)) {

View File

@ -64,8 +64,8 @@ class langstring {
* @param int $deleted
* @param stdclass $extra
*/
public function __construct(string $id, string $text = '', int $timemodified = null,
int $deleted = 0, stdclass $extra = null) {
public function __construct(string $id, string $text = '', ?int $timemodified = null,
int $deleted = 0, ?stdclass $extra = null) {
if (is_null($timemodified)) {
$timemodified = time();

View File

@ -88,7 +88,7 @@ class tool_customlang_utils {
* @param string $lang language code to checkout
* @param progress_bar $progressbar optionally, the given progress bar can be updated
*/
public static function checkout($lang, progress_bar $progressbar = null) {
public static function checkout($lang, ?progress_bar $progressbar = null) {
global $DB, $CFG;
require_once("{$CFG->libdir}/adminlib.php");

View File

@ -821,7 +821,7 @@ class api {
* @param int|null $userid
* @return bool
*/
public static function can_create_data_download_request_for_self(int $userid = null): bool {
public static function can_create_data_download_request_for_self(?int $userid = null): bool {
global $USER;
$userid = $userid ?: $USER->id;
return has_capability('tool/dataprivacy:downloadownrequest', \context_user::instance($userid), $userid);
@ -834,7 +834,7 @@ class api {
* @return bool
* @throws coding_exception
*/
public static function can_create_data_deletion_request_for_self(int $userid = null): bool {
public static function can_create_data_deletion_request_for_self(?int $userid = null): bool {
global $USER;
$userid = $userid ?: $USER->id;
return has_capability('tool/dataprivacy:requestdelete', \context_user::instance($userid), $userid)
@ -849,7 +849,7 @@ class api {
* @throws coding_exception
* @throws dml_exception
*/
public static function can_create_data_deletion_request_for_other(int $userid = null): bool {
public static function can_create_data_deletion_request_for_other(?int $userid = null): bool {
global $USER;
$userid = $userid ?: $USER->id;
return has_capability('tool/dataprivacy:requestdeleteforotheruser', context_system::instance(), $userid);
@ -863,7 +863,7 @@ class api {
* @return bool
* @throws coding_exception
*/
public static function can_create_data_deletion_request_for_children(int $userid, int $requesterid = null): bool {
public static function can_create_data_deletion_request_for_children(int $userid, ?int $requesterid = null): bool {
global $USER;
$requesterid = $requesterid ?: $USER->id;
return has_capability('tool/dataprivacy:makedatadeletionrequestsforchildren', \context_user::instance($userid),
@ -1363,7 +1363,7 @@ class api {
* @param int $requestid The data request ID.
* @param int $userid Optional. The user ID to run the task as, if necessary.
*/
public static function queue_data_request_task(int $requestid, int $userid = null): void {
public static function queue_data_request_task(int $requestid, ?int $userid = null): void {
$task = new process_data_request_task();
$task->set_custom_data(['requestid' => $requestid]);
if ($userid) {

View File

@ -55,7 +55,7 @@ class expired_contexts_manager {
*
* @param \progress_trace $trace
*/
public function __construct(\progress_trace $trace = null) {
public function __construct(?\progress_trace $trace = null) {
if (null === $trace) {
$trace = new \null_progress_trace();
}

View File

@ -54,7 +54,7 @@ class purpose extends \core\persistent {
* @param int $id If set, this is the id of an existing record, used to load the data.
* @param stdClass $record If set will be passed to {@link self::from_record()}.
*/
public function __construct($id = 0, stdClass $record = null) {
public function __construct($id = 0, ?stdClass $record = null) {
global $CFG;
if ($id) {

View File

@ -2165,7 +2165,7 @@ class api_test extends \advanced_testcase {
* @param string $course Retention policy for courses.
* @param string $activity Retention policy for activities.
*/
protected function setup_basics(string $system, string $user, string $course = null, string $activity = null): \stdClass {
protected function setup_basics(string $system, string $user, ?string $course = null, ?string $activity = null): \stdClass {
$this->resetAfterTest();
$purposes = (object) [

View File

@ -33,7 +33,7 @@ class expired_contexts_test extends \advanced_testcase {
* @param string $course Retention policy for courses.
* @param string $activity Retention policy for activities.
*/
protected function setup_basics(string $system, string $user, string $course = null, string $activity = null): \stdClass {
protected function setup_basics(string $system, string $user, ?string $course = null, ?string $activity = null): \stdClass {
$this->resetAfterTest();
$purposes = (object) [

View File

@ -76,7 +76,7 @@ function tool_dbtransfer_export_xml_database($description, $mdb) {
* @param progress_trace $feedback
* @return void
*/
function tool_dbtransfer_transfer_database(moodle_database $sourcedb, moodle_database $targetdb, progress_trace $feedback = null) {
function tool_dbtransfer_transfer_database(moodle_database $sourcedb, moodle_database $targetdb, ?progress_trace $feedback = null) {
core_php_time_limit::raise();
\core\session\manager::write_close(); // Release session.
@ -94,7 +94,7 @@ function tool_dbtransfer_transfer_database(moodle_database $sourcedb, moodle_dat
* @return void
* @throws Exception on conversion error
*/
function tool_dbtransfer_rebuild_target_log_actions(moodle_database $target, progress_trace $feedback = null) {
function tool_dbtransfer_rebuild_target_log_actions(moodle_database $target, ?progress_trace $feedback = null) {
global $DB, $CFG;
require_once("$CFG->libdir/upgradelib.php");

View File

@ -52,7 +52,7 @@ class tool_installaddon_installer {
* @param array optional parameters
* @return moodle_url
*/
public function index_url(array $params = null) {
public function index_url(?array $params = null) {
return new moodle_url('/admin/tool/installaddon/index.php', $params);
}

View File

@ -233,7 +233,7 @@ class manager {
/**
* View the license manager.
*/
private function view_license_manager(string $message = null): void {
private function view_license_manager(?string $message = null): void {
global $PAGE, $OUTPUT;
$renderer = $PAGE->get_renderer('tool_licensemanager');

View File

@ -128,7 +128,7 @@ class provider implements
* @param string $interface The interface to use. By default uses the logstore_provider.
* @return void
*/
protected static function call_subplugins_method_with_args($method, array $args = [], string $interface = null) {
protected static function call_subplugins_method_with_args($method, array $args = [], ?string $interface = null) {
if (!isset($interface)) {
$interface = \tool_log\local\privacy\logstore_provider::class;
}

View File

@ -101,7 +101,7 @@ class framework_processor {
* @param framework_mapper $mapper The mapper.
* @param \core\progress\base $progress The progress object.
*/
public function __construct(framework_mapper $mapper, \core\progress\base $progress = null) {
public function __construct(framework_mapper $mapper, ?\core\progress\base $progress = null) {
$this->mapper = $mapper;
if ($progress == null) {

View File

@ -41,7 +41,7 @@ class verification_field extends \MoodleQuickForm_text {
* @param boolean $auth is this constructed in auth.php loginform_* definitions. Set to false to prevent autosubmission of form.
* @param string|null $elementlabel Provide a different element label.
*/
public function __construct($attributes = null, $auth = true, string $elementlabel = null) {
public function __construct($attributes = null, $auth = true, ?string $elementlabel = null) {
global $PAGE;
// Force attributes.

View File

@ -59,7 +59,7 @@ class secret_manager {
* @param string $secret an optional provided secret
* @return string the secret code, or 0 if no new code created.
*/
public function create_secret(int $expires, bool $session, string $secret = null): string {
public function create_secret(int $expires, bool $session, ?string $secret = null): string {
// Check if there already an active secret, unless we are forcibly given a code.
if ($this->has_active_secret($session) && empty($secret)) {
return '';
@ -88,7 +88,7 @@ class secret_manager {
* @param string $sessionid an optional sessionID to tie this record to
* @return void
*/
private function add_secret_to_db(string $secret, int $expires, string $sessionid = null): void {
private function add_secret_to_db(string $secret, int $expires, ?string $sessionid = null): void {
global $DB, $USER;
$expirytime = time() + $expires;

View File

@ -178,7 +178,7 @@ class renderer extends \plugin_renderer_base {
* @return string $html
* @throws \coding_exception
*/
public function active_factors(string $filterfactor = null): string {
public function active_factors(?string $filterfactor = null): string {
global $USER, $CFG;
require_once($CFG->dirroot . '/iplookup/lib.php');

View File

@ -144,7 +144,7 @@ class profile_manager {
* @param int $categoryid The category id to check against.
* @return bool True is the category checks out, otherwise false.
*/
private static function check_profile_category(int $categoryid = null): bool {
private static function check_profile_category(?int $categoryid = null): bool {
global $DB;
$categoryname = self::get_category_name();
$categorydata = $DB->get_record('user_info_category', ['name' => $categoryname]);

View File

@ -66,7 +66,7 @@ class issuer extends persistent {
* @param array $ajaxformdata
*/
public function __construct($action = null, $customdata = null, $method = 'post', $target = '', $attributes = null,
$editable = true, array $ajaxformdata = null) {
$editable = true, ?array $ajaxformdata = null) {
// The type variable defines, if we are in the creation process of a standard issuer.
if (array_key_exists('type', $customdata)) {
$this->type = $customdata['type'];

View File

@ -339,7 +339,7 @@ class api {
* @param array $extrafields Extra fields to be included in result
* @return array of objects
*/
public static function get_user_minors($userid, array $extrafields = null) {
public static function get_user_minors($userid, ?array $extrafields = null) {
global $DB;
$ctxfields = context_helper::get_preload_record_columns_sql('c');

View File

@ -110,7 +110,7 @@ class process {
* @param string|null $progresstrackerclass
* @throws \coding_exception
*/
public function __construct(\csv_import_reader $cir, string $progresstrackerclass = null) {
public function __construct(\csv_import_reader $cir, ?string $progresstrackerclass = null) {
$this->cir = $cir;
if ($progresstrackerclass) {
if (!class_exists($progresstrackerclass) || !is_subclass_of($progresstrackerclass, \uu_progress_tracker::class)) {

View File

@ -819,7 +819,7 @@ class tour {
* @param array|null $filters Optional array of filters.
* @return bool
*/
public function matches_all_filters(\context $context, array $filters = null): bool {
public function matches_all_filters(\context $context, ?array $filters = null): bool {
if (!$filters) {
$filters = helper::get_all_filters();
}

View File

@ -29,7 +29,7 @@ trait tool_usertours_helper_trait {
* @param bool $persist Whether to persist the data
* @return \tool_usertours\tour
*/
public function helper_create_tour(\stdClass $tourconfig = null, $persist = true) {
public function helper_create_tour(?\stdClass $tourconfig = null, $persist = true) {
$minvalues = [
'id' => null,
'pathmatch' => '/my/%',
@ -65,7 +65,7 @@ trait tool_usertours_helper_trait {
* @param bool $persist Whether to persist the data
* @return \tool_usertours\step
*/
public function helper_create_step(\stdClass $stepconfig = null, $persist = true) {
public function helper_create_step(?\stdClass $stepconfig = null, $persist = true) {
$minvalues = [
'id' => null,
'title' => '',

View File

@ -432,7 +432,7 @@ abstract class base {
* @param string|null $query Context name filter.
* @return int[]
*/
public static function potential_context_restrictions(string $query = null) {
public static function potential_context_restrictions(?string $query = null) {
return \core_analytics\manager::get_potential_context_restrictions(static::context_restriction_support(), $query);
}

View File

@ -533,7 +533,7 @@ class manager {
* @param int|null $newmodelid A new model to add to the list of models with insights in the provided context.
* @return int[]
*/
public static function cached_models_with_insights(\context $context, int $newmodelid = null) {
public static function cached_models_with_insights(\context $context, ?int $newmodelid = null) {
$cache = \cache::make('core', 'contextwithinsights');
$modelids = $cache->get($context->id);
@ -941,7 +941,7 @@ class manager {
* @param string|null $query
* @return array Associative array with contextid as key and the short version of the context name as value.
*/
public static function get_potential_context_restrictions(?array $contextlevels = null, string $query = null) {
public static function get_potential_context_restrictions(?array $contextlevels = null, ?string $query = null) {
global $DB;
if (empty($contextlevels) && !is_null($contextlevels)) {

View File

@ -187,7 +187,7 @@ class prediction {
* @param int $userid the user id. Current user by default.
* @return array of actions.
*/
public function get_executed_actions(array $actionnamefilter = null, int $userid = 0): array {
public function get_executed_actions(?array $actionnamefilter = null, int $userid = 0): array {
global $USER, $DB;
$conditions[] = "predictionid = :predictionid";

View File

@ -46,7 +46,7 @@ class behat_auth extends behat_base {
* @param string $username the user to log in as.
* @param moodle_url|null $wantsurl optional, URL to go to after logging in.
*/
public function i_log_in_as(string $username, moodle_url $wantsurl = null) {
public function i_log_in_as(string $username, ?moodle_url $wantsurl = null) {
// In the mobile app the required tasks are different (does not support $wantsurl).
if ($this->is_in_app()) {
$this->execute('behat_app::login', [$username]);

View File

@ -50,8 +50,8 @@ abstract class frontend {
* @param \cm_info $cm Course-module currently being edited (null if none)
* @param \section_info $section Section currently being edited (null if none)
*/
protected function allow_add($course, \cm_info $cm = null,
\section_info $section = null) {
protected function allow_add($course, ?\cm_info $cm = null,
?\section_info $section = null) {
return true;
}
@ -78,8 +78,8 @@ abstract class frontend {
* @param \section_info $section Section currently being edited (null if none)
* @return array Array of parameters for the JavaScript function
*/
protected function get_javascript_init_params($course, \cm_info $cm = null,
\section_info $section = null) {
protected function get_javascript_init_params($course, ?\cm_info $cm = null,
?\section_info $section = null) {
return array();
}
@ -99,8 +99,8 @@ abstract class frontend {
* @param \cm_info $cm Course-module currently being edited (null if none)
* @param \section_info $section Section currently being edited (null if none)
*/
public static function include_all_javascript($course, \cm_info $cm = null,
\section_info $section = null) {
public static function include_all_javascript($course, ?\cm_info $cm = null,
?\section_info $section = null) {
global $PAGE;
// Prepare array of required YUI modules. It is bad for performance to

View File

@ -173,7 +173,7 @@ abstract class info {
* @return bool True if this item is available to the user, false otherwise
*/
public function is_available(&$information, $grabthelot = false, $userid = 0,
\course_modinfo $modinfo = null) {
?\course_modinfo $modinfo = null) {
global $USER;
// Default to no information.
@ -262,7 +262,7 @@ abstract class info {
* @return string Information string (for admin) about all restrictions on
* this item
*/
public function get_full_information(\course_modinfo $modinfo = null) {
public function get_full_information(?\course_modinfo $modinfo = null) {
// Do nothing if there are no availability restrictions.
if (is_null($this->availability)) {
return '';

View File

@ -50,7 +50,7 @@ class result {
* @param tree_node $node Node if failed & should be displayed
* @param result[] $failedchildren Array of children who failed too
*/
public function __construct($available, tree_node $node = null,
public function __construct($available, ?tree_node $node = null,
array $failedchildren = array()) {
$this->available = $available;
if (!$available) {

View File

@ -49,8 +49,8 @@ class frontend extends \core_availability\frontend {
'label_cm', 'label_completion'];
}
protected function get_javascript_init_params($course, \cm_info $cm = null,
\section_info $section = null) {
protected function get_javascript_init_params($course, ?\cm_info $cm = null,
?\section_info $section = null) {
// Use cached result if available. The cache is just because we call it
// twice (once from allow_add) so it's nice to avoid doing all the
// print_string calls twice.
@ -86,8 +86,8 @@ class frontend extends \core_availability\frontend {
return $this->cacheinitparams;
}
protected function allow_add($course, \cm_info $cm = null,
\section_info $section = null) {
protected function allow_add($course, ?\cm_info $cm = null,
?\section_info $section = null) {
global $CFG;
// Check if completion is enabled for the course.

View File

@ -84,8 +84,8 @@ class frontend extends \core_availability\frontend {
'hour' => $wrongfields['hours'], 'minute' => $wrongfields['minutes']);
}
protected function get_javascript_init_params($course, \cm_info $cm = null,
\section_info $section = null) {
protected function get_javascript_init_params($course, ?\cm_info $cm = null,
?\section_info $section = null) {
global $CFG, $OUTPUT;
require_once($CFG->libdir . '/formslib.php');

View File

@ -38,8 +38,8 @@ class frontend extends \core_availability\frontend {
return array('option_min', 'option_max', 'label_min', 'label_max');
}
protected function get_javascript_init_params($course, \cm_info $cm = null,
\section_info $section = null) {
protected function get_javascript_init_params($course, ?\cm_info $cm = null,
?\section_info $section = null) {
global $DB, $CFG;
require_once($CFG->libdir . '/gradelib.php');
require_once($CFG->dirroot . '/course/lib.php');

View File

@ -43,8 +43,8 @@ class frontend extends \core_availability\frontend {
return array('anygroup');
}
protected function get_javascript_init_params($course, \cm_info $cm = null,
\section_info $section = null) {
protected function get_javascript_init_params($course, ?\cm_info $cm = null,
?\section_info $section = null) {
// Get all groups for course.
$groups = $this->get_all_groups($course->id);
@ -78,8 +78,8 @@ class frontend extends \core_availability\frontend {
return $this->allgroups;
}
protected function allow_add($course, \cm_info $cm = null,
\section_info $section = null) {
protected function allow_add($course, ?\cm_info $cm = null,
?\section_info $section = null) {
global $CFG;
// Only show this option if there are some groups.

View File

@ -39,8 +39,8 @@ class frontend extends \core_availability\frontend {
/** @var int Course id that $allgroupings is for */
protected $allgroupingscourseid;
protected function get_javascript_init_params($course, \cm_info $cm = null,
\section_info $section = null) {
protected function get_javascript_init_params($course, ?\cm_info $cm = null,
?\section_info $section = null) {
// Get all groups for course.
$groupings = $this->get_all_groupings($course->id);
@ -70,8 +70,8 @@ class frontend extends \core_availability\frontend {
return $this->allgroupings;
}
protected function allow_add($course, \cm_info $cm = null,
\section_info $section = null) {
protected function allow_add($course, ?\cm_info $cm = null,
?\section_info $section = null) {
global $CFG, $DB;
// Check if groupings are in use for the course. (Unlike the 'group'

View File

@ -40,8 +40,8 @@ class frontend extends \core_availability\frontend {
'label_operator', 'label_value');
}
protected function get_javascript_init_params($course, \cm_info $cm = null,
\section_info $section = null) {
protected function get_javascript_init_params($course, ?\cm_info $cm = null,
?\section_info $section = null) {
// Standard user fields.
$standardfields = condition::get_standard_profile_fields();

View File

@ -46,7 +46,7 @@ class mock_info_module extends info_module {
* @param int $userid Userid for modinfo (if used)
* @param \cm_info $cm Course-module object
*/
public function __construct($userid = 0, \cm_info $cm = null) {
public function __construct($userid = 0, ?\cm_info $cm = null) {
parent::__construct($cm);
$this->userid = $userid;
$this->cm = $cm;

View File

@ -46,7 +46,7 @@ class mock_info_section extends info_section {
* @param int $userid Userid for modinfo (if used)
* @param \section_info $section Section object
*/
public function __construct($userid = 0, \section_info $section = null) {
public function __construct($userid = 0, ?\section_info $section = null) {
parent::__construct($section);
$this->userid = $userid;
$this->section = $section;

View File

@ -253,7 +253,7 @@ class cc_version1 extends cc_version_base {
* @param DOMDocument $doc
* @param DOMElement $xmlnode
*/
protected function create_item_folder(cc_i_organization &$org, DOMDocument &$doc, DOMElement &$xmlnode = null) {
protected function create_item_folder(cc_i_organization &$org, DOMDocument &$doc, ?DOMElement &$xmlnode = null) {
$itemfoldernode = $doc->createElementNS($this->ccnamespaces['imscc'], 'item');
$this->update_attribute($doc, 'identifier', "root", $itemfoldernode);

View File

@ -90,7 +90,7 @@ class restore_controller extends base_controller {
* @param bool $releasesession Should release the session? backup::RELEASESESSION_YES or backup::RELEASESESSION_NO
*/
public function __construct($tempdir, $courseid, $interactive, $mode, $userid, $target,
\core\progress\base $progress = null, $releasesession = backup::RELEASESESSION_NO, ?\stdClass $copydata = null) {
?\core\progress\base $progress = null, $releasesession = backup::RELEASESESSION_NO, ?\stdClass $copydata = null) {
if ($mode == backup::MODE_COPY && is_null($copydata)) {
throw new restore_controller_exception('cannot_instantiate_missing_copydata');

View File

@ -2037,7 +2037,7 @@ abstract class moodle1_resource_successor_handler extends moodle1_mod_handler {
* @param array $data pre-cooked legacy resource data
* @param array $raw raw legacy resource data
*/
public function process_legacy_resource(array $data, array $raw = null) {
public function process_legacy_resource(array $data, ?array $raw = null) {
}
/**

View File

@ -52,7 +52,7 @@ class backup_filename_setting extends backup_generic_setting {
parent::__construct($name, $vtype, $value, $visibility, $status);
}
public function set_ui_filename($label, $value, array $options = null) {
public function set_ui_filename($label, $value, ?array $options = null) {
$this->make_ui(self::UI_HTML_TEXTFIELD, $label, null, $options);
$this->set_value($value);
}

View File

@ -364,7 +364,7 @@ abstract class backup_controller_dbops extends backup_dbops {
* @param \core\progress\base $progress Optional progress monitor
*/
public static function get_moodle_backup_information($backupid,
\core\progress\base $progress = null) {
?\core\progress\base $progress = null) {
// Start tracking progress if required (for load_controller).
if ($progress) {

View File

@ -116,7 +116,7 @@ abstract class backup_structure_dbops extends backup_dbops {
* @param \core\progress\base $progress
*/
public static function annotate_files($backupid, $contextid, $component, $filearea, $itemid,
\core\progress\base $progress = null) {
?\core\progress\base $progress = null) {
global $DB;
$sql = 'SELECT id
FROM {files}

View File

@ -117,7 +117,7 @@ abstract class restore_dbops {
* @param \core\progress\base $progress Progress tracker
*/
public static function load_inforef_to_tempids($restoreid, $inforeffile,
\core\progress\base $progress = null) {
?\core\progress\base $progress = null) {
if (!file_exists($inforeffile)) { // Shouldn't happen ever, but...
throw new backup_helper_exception('missing_inforef_xml_file', $inforeffile);
@ -424,7 +424,7 @@ abstract class restore_dbops {
* @param \core\progress\base $progress Progress tracker
*/
public static function load_users_to_tempids($restoreid, $usersfile,
\core\progress\base $progress = null) {
?\core\progress\base $progress = null) {
if (!file_exists($usersfile)) { // Shouldn't happen ever, but...
throw new backup_helper_exception('missing_users_xml_file', $usersfile);
@ -920,7 +920,7 @@ abstract class restore_dbops {
public static function send_files_to_pool($basepath, $restoreid, $component, $filearea,
$oldcontextid, $dfltuserid, $itemname = null, $olditemid = null,
$forcenewcontextid = null, $skipparentitemidctxmatch = false,
\core\progress\base $progress = null) {
?\core\progress\base $progress = null) {
global $DB, $CFG;
$backupinfo = backup_general_helper::get_backup_information(basename($basepath));
@ -1738,7 +1738,7 @@ abstract class restore_dbops {
* @param \core\progress\base $progress Optional progress tracker
*/
public static function process_included_users($restoreid, $courseid, $userid, $samesite,
\core\progress\base $progress = null) {
?\core\progress\base $progress = null) {
global $DB;
// Just let precheck_included_users() to do all the hard work
@ -1905,7 +1905,7 @@ abstract class restore_dbops {
* @param array $options
* @return bool True for success
*/
public static function delete_course_content($courseid, array $options = null) {
public static function delete_course_content($courseid, ?array $options = null) {
return remove_course_contents($courseid, false, $options);
}

View File

@ -260,7 +260,7 @@ abstract class backup_general_helper extends backup_helper {
* @return stdClass containing information.
* @since Moodle 2.4
*/
public static function get_backup_information_from_mbz($filepath, file_progress $progress = null) {
public static function get_backup_information_from_mbz($filepath, ?file_progress $progress = null) {
global $CFG;
if (!is_readable($filepath)) {
throw new backup_helper_exception('missing_moodle_backup_file', $filepath);

View File

@ -48,7 +48,7 @@ abstract class backup_helper {
* @param string $backupid Backup id
* @param \core\progress\base $progress Optional progress reporting object
*/
public static function clear_backup_dir($backupid, \core\progress\base $progress = null) {
public static function clear_backup_dir($backupid, ?\core\progress\base $progress = null) {
$backupiddir = make_backup_temp_directory($backupid, false);
if (!self::delete_dir_contents($backupiddir, '', $progress)) {
throw new backup_helper_exception('cannot_empty_backup_temp_dir');
@ -65,7 +65,7 @@ abstract class backup_helper {
* @param string $backupid Backup id
* @param \core\progress\base $progress Optional progress reporting object
*/
public static function delete_backup_dir($backupid, \core\progress\base $progress = null) {
public static function delete_backup_dir($backupid, ?\core\progress\base $progress = null) {
$backupiddir = make_backup_temp_directory($backupid, false);
self::clear_backup_dir($backupid, $progress);
return rmdir($backupiddir);
@ -83,7 +83,7 @@ abstract class backup_helper {
* @param string $excludedir Exclude this directory
* @param \core\progress\base $progress Optional progress reporting object
*/
public static function delete_dir_contents($dir, $excludeddir='', \core\progress\base $progress = null) {
public static function delete_dir_contents($dir, $excludeddir='', ?\core\progress\base $progress = null) {
global $CFG;
if ($progress) {
@ -156,7 +156,7 @@ abstract class backup_helper {
* @param int $deletebefore Delete files and directories older than this time
* @param \core\progress\base $progress Optional progress reporting object
*/
public static function delete_old_backup_dirs($deletebefore, \core\progress\base $progress = null) {
public static function delete_old_backup_dirs($deletebefore, ?\core\progress\base $progress = null) {
$status = true;
// Get files and directories in the backup temp dir.
$backuptempdir = make_backup_temp_directory('');
@ -219,7 +219,7 @@ abstract class backup_helper {
*
* @throws moodle_exception in case of any problems
*/
public static function store_backup_file($backupid, $filepath, \core\progress\base $progress = null) {
public static function store_backup_file($backupid, $filepath, ?\core\progress\base $progress = null) {
global $CFG;
// First of all, get some information from the backup_controller to help us decide

View File

@ -70,7 +70,7 @@ abstract class backup_setting extends base_setting implements checksumable {
* @param array $attributes
* @param array $options
*/
public function make_ui($type, $label, array $attributes = null, array $options = null) {
public function make_ui($type, $label, ?array $attributes = null, ?array $options = null) {
$this->uisetting = backup_setting_ui::make($this, $type, $label, $attributes, $options);
if (is_array($options) || is_object($options)) {
$options = (array)$options;

View File

@ -48,7 +48,7 @@ class backup_structure_processor extends base_processor {
* @param xml_writer $writer XML writer to save data
* @param c\core\progress\base$progress Progress tracker (optional)
*/
public function __construct(xml_writer $writer, \core\progress\base $progress = null) {
public function __construct(xml_writer $writer, ?\core\progress\base $progress = null) {
$this->writer = $writer;
$this->progress = $progress;
$this->vars = array();

View File

@ -76,7 +76,7 @@ class backup_ui extends base_ui {
* @param array $params
* @return backup_ui_stage_initial|backup_ui_stage_schema|backup_ui_stage_confirmation|backup_ui_stage_final
*/
protected function initialise_stage($stage = null, array $params = null) {
protected function initialise_stage($stage = null, ?array $params = null) {
if ($stage == null) {
$stage = optional_param('stage', self::STAGE_INITIAL, PARAM_INT);
}

View File

@ -245,7 +245,7 @@ abstract class backup_setting_ui extends base_setting_ui {
* @param array $attributes Array of HTML attributes to apply to the element
* @param array $options Array of options to apply to the setting ui object
*/
public function __construct(backup_setting $setting, $label = null, array $attributes = null, array $options = null) {
public function __construct(backup_setting $setting, $label = null, ?array $attributes = null, ?array $options = null) {
parent::__construct($setting);
// Improve the inputs name by appending the level to the name.
switch ($setting->get_level()) {
@ -284,7 +284,7 @@ abstract class backup_setting_ui extends base_setting_ui {
* @param array $options Array of options to apply to the setting ui object
* @return backup_setting_ui_text|backup_setting_ui_checkbox|backup_setting_ui_select|backup_setting_ui_radio
*/
final public static function make(backup_setting $setting, $type, $label, array $attributes = null, array $options = null) {
final public static function make(backup_setting $setting, $type, $label, ?array $attributes = null, ?array $options = null) {
// Base the decision we make on the type that was sent.
switch ($type) {
case backup_setting::UI_HTML_CHECKBOX :
@ -307,7 +307,7 @@ abstract class backup_setting_ui extends base_setting_ui {
* @param renderer_base $output
* @return array
*/
abstract public function get_element_properties(base_task $task = null, renderer_base $output = null);
abstract public function get_element_properties(?base_task $task = null, ?renderer_base $output = null);
/**
* Applies config options to a given properties array and then returns it
@ -327,7 +327,7 @@ abstract class backup_setting_ui extends base_setting_ui {
* $task is used to set the setting label
* @return string
*/
public function get_label(base_task $task = null) {
public function get_label(?base_task $task = null) {
// If a task has been provided and the label is not already set meaningfully
// we will attempt to improve it.
if (!is_null($task) && $this->label == $this->setting->get_name() && strpos($this->setting->get_name(), '_include') !== false) {
@ -401,7 +401,7 @@ class backup_setting_ui_text extends backup_setting_ui {
* @param renderer_base $output
* @return array (element, name, label, attributes)
*/
public function get_element_properties(base_task $task = null, renderer_base $output = null) {
public function get_element_properties(?base_task $task = null, ?renderer_base $output = null) {
$icon = $this->get_icon();
$context = context_course::instance($task->get_courseid());
$label = format_string($this->get_label($task), true, array('context' => $context));
@ -464,7 +464,7 @@ class backup_setting_ui_checkbox extends backup_setting_ui {
* @param renderer_base $output
* @return array (element, name, label, text, attributes);
*/
public function get_element_properties(base_task $task = null, renderer_base $output = null) {
public function get_element_properties(?base_task $task = null, ?renderer_base $output = null) {
// Name, label, text, attributes.
$icon = $this->get_icon();
$context = context_course::instance($task->get_courseid());
@ -580,7 +580,7 @@ class backup_setting_ui_radio extends backup_setting_ui {
* @param renderer_base $output
* @return array (element, name, label, text, value, attributes)
*/
public function get_element_properties(base_task $task = null, renderer_base $output = null) {
public function get_element_properties(?base_task $task = null, ?renderer_base $output = null) {
$icon = $this->get_icon();
$context = context_course::instance($task->get_courseid());
$label = format_string($this->get_label($task), true, array('context' => $context));
@ -658,7 +658,7 @@ class backup_setting_ui_select extends backup_setting_ui {
* @param renderer_base $output
* @return array (element, name, label, options, attributes)
*/
public function get_element_properties(base_task $task = null, renderer_base $output = null) {
public function get_element_properties(?base_task $task = null, ?renderer_base $output = null) {
$icon = $this->get_icon();
$context = context_course::instance($task->get_courseid());
$label = format_string($this->get_label($task), true, array('context' => $context));
@ -731,7 +731,7 @@ class backup_setting_ui_dateselector extends backup_setting_ui_text {
* @param renderer_base $output
* @return array (element, name, label, options, attributes)
*/
public function get_element_properties(base_task $task = null, renderer_base $output = null) {
public function get_element_properties(?base_task $task = null, ?renderer_base $output = null) {
if (!array_key_exists('optional', $this->attributes)) {
$this->attributes['optional'] = false;
}
@ -770,7 +770,7 @@ class backup_setting_ui_defaultcustom extends backup_setting_ui_text {
* @param array $attributes Array of HTML attributes to apply to the element
* @param array $options Array of options to apply to the setting ui object
*/
public function __construct(backup_setting $setting, $label = null, array $attributes = null, array $options = null) {
public function __construct(backup_setting $setting, $label = null, ?array $attributes = null, ?array $options = null) {
if (!is_array($attributes)) {
$attributes = [];
}
@ -785,7 +785,7 @@ class backup_setting_ui_defaultcustom extends backup_setting_ui_text {
* @param renderer_base $output
* @return array (element, name, label, options, attributes)
*/
public function get_element_properties(base_task $task = null, renderer_base $output = null) {
public function get_element_properties(?base_task $task = null, ?renderer_base $output = null) {
return ['element' => 'defaultcustom'] + parent::get_element_properties($task, $output);
}

View File

@ -46,7 +46,7 @@ abstract class backup_ui_stage extends base_ui_stage {
* @param backup_ui $ui
* @param array $params
*/
public function __construct(backup_ui $ui, array $params = null) {
public function __construct(backup_ui $ui, ?array $params = null) {
parent::__construct($ui, $params);
}
@ -81,7 +81,7 @@ class backup_ui_stage_initial extends backup_ui_stage {
* @param backup_ui $ui
* @param array $params
*/
public function __construct(backup_ui $ui, array $params = null) {
public function __construct(backup_ui $ui, ?array $params = null) {
$this->stage = backup_ui::STAGE_INITIAL;
parent::__construct($ui, $params);
}
@ -91,7 +91,7 @@ class backup_ui_stage_initial extends backup_ui_stage {
* @param base_moodleform $m
* @return int The number of changes
*/
public function process(base_moodleform $m = null) {
public function process(?base_moodleform $m = null) {
$form = $this->initialise_stage_form();
@ -244,7 +244,7 @@ class backup_ui_stage_schema extends backup_ui_stage {
* @param backup_ui $ui
* @param array $params
*/
public function __construct(backup_ui $ui, array $params = null) {
public function __construct(backup_ui $ui, ?array $params = null) {
$this->stage = backup_ui::STAGE_SCHEMA;
parent::__construct($ui, $params);
}
@ -255,7 +255,7 @@ class backup_ui_stage_schema extends backup_ui_stage {
* @param base_moodleform $form
* @return int The number of changes the user made
*/
public function process(base_moodleform $form = null) {
public function process(?base_moodleform $form = null) {
$form = $this->initialise_stage_form();
// Check it wasn't cancelled.
if ($form->is_cancelled()) {
@ -397,7 +397,7 @@ class backup_ui_stage_confirmation extends backup_ui_stage {
* @param backup_ui $ui
* @param array $params
*/
public function __construct($ui, array $params = null) {
public function __construct($ui, ?array $params = null) {
$this->stage = backup_ui::STAGE_CONFIRMATION;
parent::__construct($ui, $params);
}
@ -408,7 +408,7 @@ class backup_ui_stage_confirmation extends backup_ui_stage {
* @param base_moodleform $form
* @return int The number of changes the user made
*/
public function process(base_moodleform $form = null) {
public function process(?base_moodleform $form = null) {
$form = $this->initialise_stage_form();
// Check it hasn't been cancelled.
if ($form->is_cancelled()) {
@ -539,7 +539,7 @@ class backup_ui_stage_final extends backup_ui_stage {
* @param backup_ui $ui
* @param array $params
*/
public function __construct(backup_ui $ui, array $params = null) {
public function __construct(backup_ui $ui, ?array $params = null) {
$this->stage = backup_ui::STAGE_FINAL;
parent::__construct($ui, $params);
}
@ -552,7 +552,7 @@ class backup_ui_stage_final extends backup_ui_stage {
* @param base_moodleform $form
* @return bool
*/
public function process(base_moodleform $form = null) {
public function process(?base_moodleform $form = null) {
return true;
}
@ -600,7 +600,7 @@ class backup_ui_stage_complete extends backup_ui_stage_final {
* @param array $params
* @param array $results
*/
public function __construct(backup_ui $ui, array $params = null, array $results = null) {
public function __construct(backup_ui $ui, ?array $params = null, ?array $results = null) {
$this->results = $results;
parent::__construct($ui, $params);
$this->stage = backup_ui::STAGE_COMPLETE;

View File

@ -180,7 +180,7 @@ abstract class base_moodleform extends moodleform {
* @param base_task $task
* @return bool
*/
public function add_setting(backup_setting $setting, base_task $task = null) {
public function add_setting(backup_setting $setting, ?base_task $task = null) {
return $this->add_settings(array(array($setting, $task)));
}

View File

@ -86,7 +86,7 @@ abstract class base_ui {
* @param backup_controller $controller
* @param array $params
*/
public function __construct($controller, array $params = null) {
public function __construct($controller, ?array $params = null) {
$this->controller = $controller;
$this->progress = self::PROGRESS_INTIAL;
$this->stage = $this->initialise_stage(null, $params);
@ -116,7 +116,7 @@ abstract class base_ui {
* @param array $params
* @return base_ui_stage
*/
abstract protected function initialise_stage($stage = null, array $params = null);
abstract protected function initialise_stage($stage = null, ?array $params = null);
/**
* This processes the current stage of the backup

View File

@ -70,7 +70,7 @@ abstract class base_ui_stage {
* @param base_ui $ui
* @param array $params
*/
public function __construct(base_ui $ui, array $params = null) {
public function __construct(base_ui $ui, ?array $params = null) {
$this->ui = $ui;
$this->params = $params;
}
@ -154,7 +154,7 @@ abstract class base_ui_stage {
* @abstract
* @param base_moodleform $form
*/
abstract public function process(base_moodleform $form = null);
abstract public function process(?base_moodleform $form = null);
/**
* Creates an instance of the correct moodleform properly populated and all

View File

@ -94,7 +94,7 @@ class import_ui extends backup_ui {
* @param array $params
* @return backup_ui_stage_initial|backup_ui_stage_schema|backup_ui_stage_confirmation|backup_ui_stage_final
*/
protected function initialise_stage($stage = null, array $params = null) {
protected function initialise_stage($stage = null, ?array $params = null) {
if ($stage == null) {
$stage = optional_param('stage', self::STAGE_PRECHECK, PARAM_INT);
}
@ -150,7 +150,7 @@ class import_ui_stage_precheck extends backup_ui_stage {
* @param backup_ui $ui
* @param array $params
*/
public function __construct(backup_ui $ui, array $params = null) {
public function __construct(backup_ui $ui, ?array $params = null) {
$this->stage = import_ui::STAGE_PRECHECK;
parent::__construct($ui, $params);
}
@ -160,7 +160,7 @@ class import_ui_stage_precheck extends backup_ui_stage {
*
* @param base_moodleform|null $form
*/
public function process(base_moodleform $form = null) {
public function process(?base_moodleform $form = null) {
// Dummy functions. We don't have to do anything here.
return;
}

View File

@ -278,8 +278,8 @@ class core_backup_renderer extends plugin_renderer_base {
* @param int $currentcourse
* @return string
*/
public function course_selector(moodle_url $nextstageurl, $wholecourse = true, restore_category_search $categories = null,
restore_course_search $courses = null, $currentcourse = null) {
public function course_selector(moodle_url $nextstageurl, $wholecourse = true, ?restore_category_search $categories = null,
?restore_course_search $courses = null, $currentcourse = null) {
global $CFG;
require_once($CFG->dirroot.'/course/lib.php');
@ -395,7 +395,7 @@ class core_backup_renderer extends plugin_renderer_base {
* @param import_course_search $courses
* @return string
*/
public function import_course_selector(moodle_url $nextstageurl, import_course_search $courses = null) {
public function import_course_selector(moodle_url $nextstageurl, ?import_course_search $courses = null) {
$html = html_writer::start_tag('div', array('class' => 'import-course-selector backup-restore'));
$html .= html_writer::start_tag('form', array('method' => 'post', 'action' => $nextstageurl->out_omit_querystring()));
foreach ($nextstageurl->params() as $key => $value) {
@ -576,7 +576,7 @@ class core_backup_renderer extends plugin_renderer_base {
* @param array $options
* @return string
*/
public function backup_files_viewer(array $options = null) {
public function backup_files_viewer(?array $options = null) {
$files = new backup_files_viewer($options);
return $this->render($files);
}
@ -1147,7 +1147,7 @@ class backup_files_viewer implements renderable {
* Constructor of backup_files_viewer class
* @param array $options
*/
public function __construct(array $options = null) {
public function __construct(?array $options = null) {
global $CFG, $USER;
$fs = get_file_storage();
$this->currentcontext = $options['currentcontext'];

View File

@ -109,7 +109,7 @@ class restore_ui extends base_ui {
* @param array $params
* @return restore_ui_stage_initial|restore_ui_stage_schema|restore_ui_stage_confirmation|restore_ui_stage_final
*/
protected function initialise_stage($stage = null, array $params = null) {
protected function initialise_stage($stage = null, ?array $params = null) {
if ($stage == null) {
$stage = optional_param('stage', self::STAGE_CONFIRM, PARAM_INT);
}

View File

@ -44,7 +44,7 @@ abstract class restore_ui_stage extends base_ui_stage {
* @param restore_ui $ui
* @param array $params
*/
public function __construct(restore_ui $ui, array $params = null) {
public function __construct(restore_ui $ui, ?array $params = null) {
$this->ui = $ui;
$this->params = $params;
}
@ -601,7 +601,7 @@ class restore_ui_stage_settings extends restore_ui_stage {
* @param restore_ui $ui
* @param array $params
*/
public function __construct(restore_ui $ui, array $params = null) {
public function __construct(restore_ui $ui, ?array $params = null) {
$this->stage = restore_ui::STAGE_SETTINGS;
parent::__construct($ui, $params);
}
@ -612,7 +612,7 @@ class restore_ui_stage_settings extends restore_ui_stage {
* @param base_moodleform $form
* @return bool|int
*/
public function process(base_moodleform $form = null) {
public function process(?base_moodleform $form = null) {
$form = $this->initialise_stage_form();
if ($form->is_cancelled()) {
@ -713,7 +713,7 @@ class restore_ui_stage_schema extends restore_ui_stage {
* @param restore_ui $ui
* @param array $params
*/
public function __construct(restore_ui $ui, array $params = null) {
public function __construct(restore_ui $ui, ?array $params = null) {
$this->stage = restore_ui::STAGE_SCHEMA;
parent::__construct($ui, $params);
}
@ -724,7 +724,7 @@ class restore_ui_stage_schema extends restore_ui_stage {
* @param base_moodleform $form
* @return int The number of changes the user made
*/
public function process(base_moodleform $form = null) {
public function process(?base_moodleform $form = null) {
$form = $this->initialise_stage_form();
// Check it wasn't cancelled.
if ($form->is_cancelled()) {
@ -861,7 +861,7 @@ class restore_ui_stage_review extends restore_ui_stage {
* @param restore_ui $ui
* @param array $params
*/
public function __construct($ui, array $params = null) {
public function __construct($ui, ?array $params = null) {
$this->stage = restore_ui::STAGE_REVIEW;
parent::__construct($ui, $params);
}
@ -872,7 +872,7 @@ class restore_ui_stage_review extends restore_ui_stage {
* @param base_moodleform $form
* @return int The number of changes the user made
*/
public function process(base_moodleform $form = null) {
public function process(?base_moodleform $form = null) {
$form = $this->initialise_stage_form();
// Check it hasn't been cancelled.
if ($form->is_cancelled()) {
@ -968,7 +968,7 @@ class restore_ui_stage_process extends restore_ui_stage {
* @param base_ui $ui
* @param array $params
*/
public function __construct(base_ui $ui, array $params = null) {
public function __construct(base_ui $ui, ?array $params = null) {
$this->stage = restore_ui::STAGE_PROCESS;
parent::__construct($ui, $params);
}
@ -982,7 +982,7 @@ class restore_ui_stage_process extends restore_ui_stage {
*
* @param base_moodleform $form
*/
public function process(base_moodleform $form = null) {
public function process(?base_moodleform $form = null) {
if (optional_param('cancel', false, PARAM_BOOL)) {
redirect(new moodle_url('/course/view.php', array('id' => $this->get_ui()->get_controller()->get_courseid())));
}
@ -1129,7 +1129,7 @@ class restore_ui_stage_complete extends restore_ui_stage_process {
* @param array $params
* @param array $results
*/
public function __construct(restore_ui $ui, array $params = null, array $results = null) {
public function __construct(restore_ui $ui, ?array $params = null, ?array $results = null) {
$this->results = $results;
parent::__construct($ui, $params);
$this->stage = restore_ui::STAGE_COMPLETE;

View File

@ -65,7 +65,7 @@ class channel_image implements \renderable, \templatable {
* @param string $title The title of the image
* @param \moodle_url $link The URL of the image link
*/
public function __construct(\moodle_url $url, $title, \moodle_url $link = null) {
public function __construct(\moodle_url $url, $title, ?\moodle_url $link = null) {
$this->url = $url;
$this->title = $title;
$this->link = $link;

View File

@ -338,7 +338,7 @@ function blog_is_enabled_for_user() {
* @param stdClass $userid Load for a specific user
* @return array An array of options organised by type.
*/
function blog_get_all_options(moodle_page $page, stdClass $userid = null) {
function blog_get_all_options(moodle_page $page, ?stdClass $userid = null) {
global $CFG, $DB, $USER;
$options = array();
@ -400,7 +400,7 @@ function blog_get_all_options(moodle_page $page, stdClass $userid = null) {
* @param stdClass $user
* @return array The array of options for the requested user
*/
function blog_get_options_for_user(stdClass $user=null) {
function blog_get_options_for_user(?stdClass $user=null) {
global $CFG, $USER;
// Cache.
static $useroptions = array();
@ -471,7 +471,7 @@ function blog_get_options_for_user(stdClass $user=null) {
* @param stdClass $user The user to load options for null == current user
* @return array The array of options
*/
function blog_get_options_for_course(stdClass $course, stdClass $user=null) {
function blog_get_options_for_course(stdClass $course, ?stdClass $user=null) {
global $CFG, $USER;
// Cache.
static $courseoptions = array();

View File

@ -551,7 +551,7 @@ class cache_helper {
* @param cache_config $config
* @return bool
*/
public static function purge_store($storename, cache_config $config = null) {
public static function purge_store($storename, ?cache_config $config = null) {
if ($config === null) {
$config = cache_config::instance();
}
@ -856,7 +856,7 @@ class cache_helper {
* @param array|null $stores An array of stores to get warnings for, or null for all.
* @return string[]
*/
public static function warnings(array $stores = null) {
public static function warnings(?array $stores = null) {
global $CFG;
if ($stores === null) {
require_once($CFG->dirroot.'/cache/locallib.php');

View File

@ -318,7 +318,7 @@ class administration_display_helper extends \core_cache\administration_helper {
* @return cache_lock_form
* @throws coding_exception
*/
public function get_add_lock_form(string $plugin, array $lockplugin = null): \cache_lock_form {
public function get_add_lock_form(string $plugin, ?array $lockplugin = null): \cache_lock_form {
global $CFG; // Needed for includes.
$plugins = \core_component::get_plugin_list('cachelock');
if (!array_key_exists($plugin, $plugins)) {

View File

@ -72,7 +72,7 @@ class events_related_objects_cache {
* @param array $events Array of event_interface events
* @param array $courses Array of courses to populate the cache with
*/
public function __construct(array $events, array $courses = null) {
public function __construct(array $events, ?array $courses = null) {
$this->events = $events;
if (!is_null($courses)) {

View File

@ -68,13 +68,13 @@ class api {
$timesortaftereventid = null,
$limitnum = 20,
$type = null,
array $usersfilter = null,
array $groupsfilter = null,
array $coursesfilter = null,
array $categoriesfilter = null,
?array $usersfilter = null,
?array $groupsfilter = null,
?array $coursesfilter = null,
?array $categoriesfilter = null,
$withduration = true,
$ignorehidden = true,
callable $filter = null
?callable $filter = null
) {
global $USER;

View File

@ -88,17 +88,17 @@ class event_vault implements event_vault_interface {
$timestartto = null,
$timesortfrom = null,
$timesortto = null,
event_interface $timestartafterevent = null,
event_interface $timesortafterevent = null,
?event_interface $timestartafterevent = null,
?event_interface $timesortafterevent = null,
$limitnum = 20,
$type = null,
array $usersfilter = null,
array $groupsfilter = null,
array $coursesfilter = null,
array $categoriesfilter = null,
?array $usersfilter = null,
?array $groupsfilter = null,
?array $coursesfilter = null,
?array $categoriesfilter = null,
$withduration = true,
$ignorehidden = true,
callable $filter = null,
?callable $filter = null,
?string $searchvalue = null
) {
@ -202,7 +202,7 @@ class event_vault implements event_vault_interface {
\stdClass $user,
$timesortfrom = null,
$timesortto = null,
event_interface $afterevent = null,
?event_interface $afterevent = null,
$limitnum = 20,
$limittononsuspendedevents = false,
?string $searchvalue = null
@ -247,7 +247,7 @@ class event_vault implements event_vault_interface {
\stdClass $course,
$timesortfrom = null,
$timesortto = null,
event_interface $afterevent = null,
?event_interface $afterevent = null,
$limitnum = 20,
?string $searchvalue = null
) {

View File

@ -70,17 +70,17 @@ interface event_vault_interface {
$timestartto = null,
$timesortfrom = null,
$timesortto = null,
event_interface $timestartafterevent = null,
event_interface $timesortafterevent = null,
?event_interface $timestartafterevent = null,
?event_interface $timesortafterevent = null,
$limitnum = 20,
$type = null,
array $usersfilter = null,
array $groupsfilter = null,
array $coursesfilter = null,
array $categoriesfilter = null,
?array $usersfilter = null,
?array $groupsfilter = null,
?array $coursesfilter = null,
?array $categoriesfilter = null,
$withduration = true,
$ignorehidden = true,
callable $filter = null,
?callable $filter = null,
?string $searchvalue = null
);

View File

@ -144,7 +144,7 @@ class event implements event_interface {
$type,
times_interface $times,
$visible,
proxy_interface $subscription = null,
?proxy_interface $subscription = null,
$location = null,
$component = null
) {

View File

@ -71,7 +71,7 @@ class std_proxy implements proxy_interface {
* @param callable $callback Callback to load the class.
* @param \stdClass $base Class containing base values.
*/
public function __construct($id, callable $callback, \stdClass $base = null) {
public function __construct($id, callable $callback, ?\stdClass $base = null) {
$this->id = $id;
$this->callbackargs = [$id];
$this->callback = $callback;

View File

@ -37,12 +37,12 @@ defined('MOODLE_INTERNAL') || die();
class raw_event_retrieval_strategy implements raw_event_retrieval_strategy_interface {
public function get_raw_events(
array $usersfilter = null,
array $groupsfilter = null,
array $coursesfilter = null,
array $categoriesfilter = null,
array $whereconditions = null,
array $whereparams = null,
?array $usersfilter = null,
?array $groupsfilter = null,
?array $coursesfilter = null,
?array $categoriesfilter = null,
?array $whereconditions = null,
?array $whereparams = null,
$ordersql = null,
$offset = null,
$limitnum = null,

View File

@ -49,12 +49,12 @@ interface raw_event_retrieval_strategy_interface {
* @return \stdClass[] Array of event records.
*/
public function get_raw_events(
array $usersfilter = null,
array $groupsfilter = null,
array $coursesfilter = null,
array $categoriesfilter = null,
array $whereconditions = null,
array $whereparams = null,
?array $usersfilter = null,
?array $groupsfilter = null,
?array $coursesfilter = null,
?array $categoriesfilter = null,
?array $whereconditions = null,
?array $whereparams = null,
$ordersql = null,
$offset = null,
$limitnum = 40,

View File

@ -1121,7 +1121,7 @@ class calendar_information {
* If a courseid is specified, this value is ignored.
* @return calendar_information
*/
public static function create($time, int $courseid, int $categoryid = null): calendar_information {
public static function create($time, int $courseid, ?int $categoryid = null): calendar_information {
$calendar = new static(0, 0, 0, $time);
if ($courseid != SITEID && !empty($courseid)) {
// Course ID must be valid and existing.
@ -1201,7 +1201,7 @@ class calendar_information {
* @param stdClass[] $courses The list of all courses currently accessible.
* @param stdClass $category The current category to show.
*/
public function set_sources(stdClass $course, array $courses, stdClass $category = null) {
public function set_sources(stdClass $course, array $courses, ?stdClass $category = null) {
global $USER;
// A cousre must always be specified.
@ -2139,7 +2139,7 @@ function calendar_events_by_day($events, $month, $year, &$eventsbyday, &$duratio
* @param stdClass $user The user object. This defaults to the global $USER object.
* @return array An array of courses, groups, and user to load calendar events for based upon filters
*/
function calendar_set_filters(array $courseeventsfrom, $ignorefilters = false, stdClass $user = null) {
function calendar_set_filters(array $courseeventsfrom, $ignorefilters = false, ?stdClass $user = null) {
global $CFG, $USER;
if (is_null($user)) {
@ -2455,7 +2455,7 @@ function calendar_delete_event_allowed($event) {
* By default the current user.
* @return array $courses Array of courses to display
*/
function calendar_get_default_courses($courseid = null, $fields = '*', $canmanage = false, int $userid = null) {
function calendar_get_default_courses($courseid = null, $fields = '*', $canmanage = false, ?int $userid = null) {
global $CFG, $USER;
if (!$userid) {
@ -3109,7 +3109,7 @@ function calendar_get_icalendar($url) {
* @param int|null $subscriptionid The subscription ID.
* @return array A log of the import progress, including errors.
*/
function calendar_import_events_from_ical(iCalendar $ical, int $subscriptionid = null): array {
function calendar_import_events_from_ical(iCalendar $ical, ?int $subscriptionid = null): array {
global $DB;
$errors = [];
@ -3833,7 +3833,7 @@ function calendar_is_valid_eventtype($type) {
* @param int|null $courseid The course id.
* @return array The array of allowed types.
*/
function calendar_get_allowed_event_types(int $courseid = null) {
function calendar_get_allowed_event_types(?int $courseid = null) {
global $DB, $CFG, $USER;
$types = [

View File

@ -198,7 +198,7 @@ class core_calendar_renderer extends plugin_renderer_base {
* @param int|null $calendarinstanceid The instance ID of the calendar we're generating this course filter for.
* @return string
*/
public function course_filter_selector(moodle_url $returnurl, $label = null, $courseid = null, int $calendarinstanceid = null) {
public function course_filter_selector(moodle_url $returnurl, $label = null, $courseid = null, ?int $calendarinstanceid = null) {
global $CFG, $DB;
if (!isloggedin() or isguestuser()) {

View File

@ -215,7 +215,7 @@ class provider implements
* @param context $context A context.
* @param int $userid The user ID.
*/
protected static function delete_data(\context $context, int $userid = null) {
protected static function delete_data(\context $context, ?int $userid = null) {
global $DB;
$cohortids = $DB->get_fieldset_select('cohort', 'id', 'contextid = :contextid', ['contextid' => $context->id]);

View File

@ -125,8 +125,8 @@ class provider implements
* @param string $commentarea Comment area to delete.
* @param int $itemid The item ID for use with deletion.
*/
public static function delete_comments_for_all_users(\context $context, string $component, string $commentarea = null,
int $itemid = null) {
public static function delete_comments_for_all_users(\context $context, string $component, ?string $commentarea = null,
?int $itemid = null) {
global $DB;
$params = [
'contextid' => $context->id,
@ -171,7 +171,7 @@ class provider implements
* @param int $itemid The item id to delete from.
*/
public static function delete_comments_for_user(\core_privacy\local\request\approved_contextlist $contextlist,
string $component, string $commentarea = null, int $itemid = null) {
string $component, ?string $commentarea = null, ?int $itemid = null) {
global $DB;
$userid = $contextlist->get_user()->id;
@ -207,7 +207,7 @@ class provider implements
* @param int $itemid The item id to delete from.
*/
public static function delete_comments_for_users(\core_privacy\local\request\approved_userlist $userlist,
string $component, string $commentarea = null, int $itemid = null) {
string $component, ?string $commentarea = null, ?int $itemid = null) {
global $DB;
$context = $userlist->get_context();
@ -244,7 +244,7 @@ class provider implements
* @param array $params The params required for the insql.
*/
public static function get_users_in_context_from_sql(
userlist $userlist, string $alias, string $component, string $area, int $contextid = null, string $insql = '',
userlist $userlist, string $alias, string $component, string $area, ?int $contextid = null, string $insql = '',
array $params = []) {
if ($insql != '') {

View File

@ -246,7 +246,7 @@ class comment {
* @param moodle_page $page The page object to initialise comments within
* If not provided the global $PAGE is used
*/
public static function init(moodle_page $page = null) {
public static function init(?moodle_page $page = null) {
global $PAGE;
if (empty($page)) {
@ -329,7 +329,7 @@ class comment {
* @param moodle_page $page
* @return moodle_url
*/
public function get_nojslink(moodle_page $page = null) {
public function get_nojslink(?moodle_page $page = null) {
if ($page === null) {
global $PAGE;
$page = $PAGE;

View File

@ -200,7 +200,7 @@ class api {
* @param string|null $selecteddefaulprovider
* @return array
*/
public static function get_enabled_providers_and_default(string $selecteddefaulprovider = null): array {
public static function get_enabled_providers_and_default(?string $selecteddefaulprovider = null): array {
$communicationproviders = self::get_communication_plugin_list_for_form();
$defaulprovider = processor::PROVIDER_NONE;
if (!empty($selecteddefaulprovider) && array_key_exists($selecteddefaulprovider, $communicationproviders)) {

View File

@ -98,8 +98,8 @@ trait matrix_client_test_trait {
* @return Response
*/
protected function get_mocked_version_response(
array $versions = null,
array $unstablefeatures = null,
?array $versions = null,
?array $unstablefeatures = null,
): Response {
$data = (object) [
"versions" => array_values(self::get_current_versions()),

View File

@ -904,7 +904,7 @@ class api {
* @param array $hasanycapability Array of capabilities passed to {@link has_any_capability()} in each context.
* @return context[] An array of contexts where keys are context IDs.
*/
public static function get_related_contexts($context, $includes, array $hasanycapability = null) {
public static function get_related_contexts($context, $includes, ?array $hasanycapability = null) {
global $DB;
static::require_enabled();
@ -4563,7 +4563,7 @@ class api {
* @return void
*/
protected static function apply_competency_rules_from_usercompetency(user_competency $usercompetency,
competency $competency = null, $overridegrade = false) {
?competency $competency = null, $overridegrade = false) {
// Perform some basic checks.
if (!$usercompetency->get('proficiency')) {

View File

@ -364,7 +364,7 @@ class competency extends persistent {
* @param competency $parent The parent competency object.
* @return void
*/
protected function set_new_path(competency $parent = null) {
protected function set_new_path(?competency $parent = null) {
$path = '/0/';
if ($this->get('parentid')) {
$parent = $parent !== null ? $parent : $this->get_parent();

View File

@ -485,7 +485,7 @@ class user_competency extends persistent {
* @param array $competenciesorids Limit search to those competencies, or competency IDs.
* @return \core_competency\user_competency[]
*/
public static function get_multiple($userid, array $competenciesorids = null) {
public static function get_multiple($userid, ?array $competenciesorids = null) {
global $DB;
$params = array();

View File

@ -203,7 +203,7 @@ class user_competency_course extends persistent {
* @param array $competenciesorids Limit search to those competencies, or competency IDs.
* @return \core_competency\user_competency_course[]
*/
public static function get_multiple($userid, $courseid, array $competenciesorids = null) {
public static function get_multiple($userid, $courseid, ?array $competenciesorids = null) {
global $DB;
$params = array();

View File

@ -235,7 +235,7 @@ class user_competency_plan extends persistent {
* @param array $competenciesorids Limit search to those competencies, or competency IDs.
* @return \core_competency\user_competency_plan[]
*/
public static function get_multiple($userid, $planid, array $competenciesorids = null) {
public static function get_multiple($userid, $planid, ?array $competenciesorids = null) {
global $DB;
$params = array();

View File

@ -93,7 +93,7 @@ trait form_trait {
* @throws \coding_exception If the form is not moodleform_mod and $modname is null.
*/
protected function add_completion_elements(
string $modname = null,
?string $modname = null,
bool $supportviews = false,
bool $supportgrades = false,
bool $rating = false,

View File

@ -232,7 +232,7 @@ class provider implements
* @param int $courseid The course id. Provide this if you want course completion and activity completion deleted.
* @param int $cmid The course module id. Provide this if you only want activity completion deleted.
*/
public static function delete_completion(\stdClass $user = null, int $courseid = null, int $cmid = null) {
public static function delete_completion(?\stdClass $user = null, ?int $courseid = null, ?int $cmid = null) {
global $DB;
if (isset($cmid)) {
@ -285,7 +285,7 @@ class provider implements
* @param int $courseid The course id. Provide this if you want course completion and activity completion deleted.
* @param int $cmid The course module id. Provide this if you only want activity completion deleted.
*/
public static function delete_completion_by_approved_userlist(approved_userlist $userlist, int $courseid = null, int $cmid = null) {
public static function delete_completion_by_approved_userlist(approved_userlist $userlist, ?int $courseid = null, ?int $cmid = null) {
global $DB;
$userids = $userlist->get_userids();

View File

@ -247,7 +247,7 @@ abstract class completion_criteria extends data_object {
* @param array $attributes html attributes
* @return pix_icon
*/
public function get_icon($alt, array $attributes = null) {
public function get_icon($alt, ?array $attributes = null) {
global $COMPLETION_CRITERIA_TYPES;
$criteriatype = $COMPLETION_CRITERIA_TYPES[$this->criteriatype];

View File

@ -260,7 +260,7 @@ class completion_criteria_activity extends completion_criteria {
* @param array $attributes html attributes
* @return pix_icon
*/
public function get_icon($alt, array $attributes = null) {
public function get_icon($alt, ?array $attributes = null) {
return new pix_icon('monologo', $alt, "mod_{$this->module}", $attributes);
}
}

View File

@ -213,7 +213,7 @@ class completion_criteria_date extends completion_criteria {
* @param array $attributes html attributes
* @return pix_icon
*/
public function get_icon($alt, array $attributes = null) {
public function get_icon($alt, ?array $attributes = null) {
return new pix_icon('i/calendar', $alt, 'moodle', $attributes);
}

View File

@ -269,7 +269,7 @@ class completion_criteria_grade extends completion_criteria {
* @param array $attributes html attributes
* @return pix_icon
*/
public function get_icon($alt, array $attributes = null) {
public function get_icon($alt, ?array $attributes = null) {
return new pix_icon('i/grades', $alt, 'moodle', $attributes);
}
}

View File

@ -157,7 +157,7 @@ class completion_criteria_self extends completion_criteria {
* @param array $attributes html attributes
* @return pix_icon
*/
public function get_icon($alt, array $attributes = null) {
public function get_icon($alt, ?array $attributes = null) {
return new pix_icon('i/completion_self', $alt, 'moodle', $attributes);
}
}

View File

@ -139,7 +139,7 @@ class completion_criteria_unenrol extends completion_criteria {
* @param array $attributes html attributes
* @return pix_icon
*/
public function get_icon($alt, array $attributes = null) {
public function get_icon($alt, ?array $attributes = null) {
return new pix_icon('i/user', $alt, 'moodle', $attributes);
}
}

View File

@ -58,7 +58,7 @@ class cm_completion_details_test extends advanced_testcase {
* @return cm_completion_details
*/
protected function setup_data(?int $completion, array $completionoptions = [],
object $mockcompletiondata = null, $modname = 'somenonexistentmod'): cm_completion_details {
?object $mockcompletiondata = null, $modname = 'somenonexistentmod'): cm_completion_details {
if (is_null($completion)) {
$completion = COMPLETION_TRACKING_AUTOMATIC;
}

View File

@ -103,7 +103,7 @@ class contentbank {
* @param context $context Optional context to check (default null)
* @return array The array with all the extensions supported and the supporting plugin names.
*/
public function load_context_supported_extensions(context $context = null): array {
public function load_context_supported_extensions(?context $context = null): array {
$extensionscache = \cache::make('core', 'contentbank_context_extensions');
$contextextensions = $extensionscache->get($context->id);
@ -132,7 +132,7 @@ class contentbank {
* @param context $context Optional context to check (default null)
* @return string A string with all the extensions supported.
*/
public function get_supported_extensions_as_string(context $context = null) {
public function get_supported_extensions_as_string(?context $context = null) {
$supported = $this->load_context_supported_extensions($context);
$extensions = array_keys($supported);
return implode(',', $extensions);
@ -159,7 +159,7 @@ class contentbank {
* @param context $context $context Optional context to check (default null)
* @return string contenttype name supports the file extension or null if the extension is not supported by any allowed plugin.
*/
public function get_extension_supporter(string $extension, context $context = null): ?string {
public function get_extension_supporter(string $extension, ?context $context = null): ?string {
$supporters = $this->load_context_supported_extensions($context);
if (array_key_exists($extension, $supporters)) {
return $supporters[$extension];
@ -335,7 +335,7 @@ class contentbank {
*
* @return string[] List of content types where the user has permission to access the feature.
*/
public function get_contenttypes_with_capability_feature(string $feature, \context $context = null, bool $enabled = true): array {
public function get_contenttypes_with_capability_feature(string $feature, ?\context $context = null, bool $enabled = true): array {
$contenttypes = [];
// Check enabled content types or all of them.
if ($enabled) {

View File

@ -57,7 +57,7 @@ abstract class contenttype {
*
* @param \context $context Optional context to check (default null)
*/
public function __construct(\context $context = null) {
public function __construct(?\context $context = null) {
if (empty($context)) {
$context = \context_system::instance();
}
@ -71,7 +71,7 @@ abstract class contenttype {
* @param \stdClass $record An optional content record compatible object (default null)
* @return content Object with content bank information.
*/
public function create_content(\stdClass $record = null): content {
public function create_content(?\stdClass $record = null): content {
global $USER, $DB, $CFG;
$entry = new \stdClass();
@ -109,7 +109,7 @@ abstract class contenttype {
* @param \stdClass|null $record an optional content record
* @return content Object with content bank information.
*/
public function upload_content(stored_file $file, \stdClass $record = null): content {
public function upload_content(stored_file $file, ?\stdClass $record = null): content {
if (empty($record)) {
$record = new \stdClass();
$record->name = $file->get_filename();

Some files were not shown because too many files have changed in this diff Show More