From 9de11ea641a713c6f765d514573a3cfe3ab491ef Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Mon, 22 Aug 2022 15:01:02 +0100 Subject: [PATCH] MDL-75548 misc: final Required parameter follows optional notices --- .../tool/brickfield/classes/accessibility.php | 4 +-- availability/classes/tree.php | 4 +-- .../classes/local/event/entities/event.php | 26 +++++++++---------- contentbank/classes/output/bankcontent.php | 4 +-- lib/dml/moodle_database.php | 4 +-- lib/dml/moodle_read_slave_trait.php | 4 +-- lib/dml/oci_native_moodle_database.php | 4 +-- lib/dml/pdo_moodle_database.php | 4 +-- lib/dml/pgsql_native_moodle_database.php | 4 +-- lib/dml/sqlsrv_native_moodle_database.php | 4 +-- .../fixtures/read_slave_moodle_database.php | 4 +-- .../fixtures/test_moodle_read_slave_trait.php | 4 +-- lib/filestorage/tgz_packer.php | 4 +-- lib/moodlelib.php | 4 +-- lib/outputcomponents.php | 12 ++++----- message/classes/search/base_message.php | 2 +- search/classes/base.php | 2 +- search/classes/base_mod.php | 2 +- 18 files changed, 48 insertions(+), 48 deletions(-) diff --git a/admin/tool/brickfield/classes/accessibility.php b/admin/tool/brickfield/classes/accessibility.php index 877511ff649..35f3510b9e8 100644 --- a/admin/tool/brickfield/classes/accessibility.php +++ b/admin/tool/brickfield/classes/accessibility.php @@ -323,7 +323,7 @@ class accessibility { /** * This function runs one specified check on the html item * - * @param string $html The html string to be analysed; might be NULL. + * @param string|null $html The html string to be analysed; might be NULL. * @param int $contentid The content area ID * @param int $errid The error ID * @param string $check The check name to run @@ -333,7 +333,7 @@ class accessibility { * @throws \dml_exception */ public static function run_one_check( - string $html = null, + ?string $html, int $contentid, int $errid, string $check, diff --git a/availability/classes/tree.php b/availability/classes/tree.php index 6f5d08b3711..36e759e763a 100644 --- a/availability/classes/tree.php +++ b/availability/classes/tree.php @@ -482,13 +482,13 @@ class tree extends tree_node { * * @param bool $not True if there is a NOT in effect * @param info $info Information about location of condition tree - * @param result $result Result object if this is a student display, else null + * @param result|null $result Result object if this is a student display, else null * @param bool $root True if this is the root item * @param bool $hidden Staff display; true if this tree has show=false (from parent) * @return string|renderable Information to render */ protected function get_full_information_recursive( - $not, info $info, result $result = null, $root, $hidden = false) { + $not, info $info, ?result $result, $root, $hidden = false) { // Get list of children - either full list, or those which are shown. $children = $this->children; $staff = true; diff --git a/calendar/classes/local/event/entities/event.php b/calendar/classes/local/event/entities/event.php index b3a7c748768..b0f3f428b14 100644 --- a/calendar/classes/local/event/entities/event.php +++ b/calendar/classes/local/event/entities/event.php @@ -118,16 +118,16 @@ class event implements event_interface { * @param int $id The event's ID in the database. * @param string $name The event's name. * @param description_interface $description The event's description. - * @param proxy_interface $category The category associated with the event. - * @param proxy_interface $course The course associated with the event. - * @param proxy_interface $group The group associated with the event. - * @param proxy_interface $user The user associated with the event. - * @param event_collection_interface $repeats Collection of repeat events. - * @param proxy_interface $coursemodule The course module that created the event. + * @param proxy_interface|null $category The category associated with the event. + * @param proxy_interface|null $course The course associated with the event. + * @param proxy_interface|null $group The group associated with the event. + * @param proxy_interface|null $user The user associated with the event. + * @param event_collection_interface|null $repeats Collection of repeat events. + * @param proxy_interface|null $coursemodule The course module that created the event. * @param string $type The event's type. * @param times_interface $times The times associated with the event. * @param bool $visible The event's visibility. True for visible, false for invisible. - * @param proxy_interface $subscription The event's subscription. + * @param proxy_interface|null $subscription The event's subscription. * @param string $location The event's location. * @param string $component The event's component. */ @@ -135,12 +135,12 @@ class event implements event_interface { $id, $name, description_interface $description, - proxy_interface $category = null, - proxy_interface $course = null, - proxy_interface $group = null, - proxy_interface $user = null, - event_collection_interface $repeats = null, - proxy_interface $coursemodule = null, + ?proxy_interface $category, + ?proxy_interface $course, + ?proxy_interface $group, + ?proxy_interface $user, + ?event_collection_interface $repeats, + ?proxy_interface $coursemodule, $type, times_interface $times, $visible, diff --git a/contentbank/classes/output/bankcontent.php b/contentbank/classes/output/bankcontent.php index 2678eaf41e9..29ea8bd6d08 100644 --- a/contentbank/classes/output/bankcontent.php +++ b/contentbank/classes/output/bankcontent.php @@ -58,9 +58,9 @@ class bankcontent implements renderable, templatable { * * @param \core_contentbank\content[] $contents Array of content bank contents. * @param array $toolbar List of content bank toolbar options. - * @param \context $context Optional context to check (default null) + * @param \context|null $context Optional context to check (default null) */ - public function __construct(array $contents, array $toolbar, \context $context = null) { + public function __construct(array $contents, array $toolbar, ?\context $context) { $this->contents = $contents; $this->toolbar = $toolbar; $this->context = $context; diff --git a/lib/dml/moodle_database.php b/lib/dml/moodle_database.php index 97a41bc1bed..091fdeff374 100644 --- a/lib/dml/moodle_database.php +++ b/lib/dml/moodle_database.php @@ -415,12 +415,12 @@ abstract class moodle_database { /** * This should be called before each db query. * @param string $sql The query string. - * @param array $params An array of parameters. + * @param array|null $params An array of parameters. * @param int $type The type of query. ( SQL_QUERY_SELECT | SQL_QUERY_AUX | SQL_QUERY_INSERT | SQL_QUERY_UPDATE | SQL_QUERY_STRUCTURE ) * @param mixed $extrainfo This is here for any driver specific extra information. * @return void */ - protected function query_start($sql, array $params=null, $type, $extrainfo=null) { + protected function query_start($sql, ?array $params, $type, $extrainfo=null) { if ($this->loggingquery) { return; } diff --git a/lib/dml/moodle_read_slave_trait.php b/lib/dml/moodle_read_slave_trait.php index 0b3bf126439..b920f5ace02 100644 --- a/lib/dml/moodle_read_slave_trait.php +++ b/lib/dml/moodle_read_slave_trait.php @@ -264,12 +264,12 @@ trait moodle_read_slave_trait { /** * Called before each db query. * @param string $sql - * @param array $params array of parameters + * @param array|null $params An array of parameters. * @param int $type type of query * @param mixed $extrainfo driver specific extra information * @return void */ - protected function query_start($sql, array $params = null, $type, $extrainfo = null) { + protected function query_start($sql, ?array $params, $type, $extrainfo = null) { parent::query_start($sql, $params, $type, $extrainfo); $this->select_db_handle($type, $sql); } diff --git a/lib/dml/oci_native_moodle_database.php b/lib/dml/oci_native_moodle_database.php index 6db6a7bca86..711306a295f 100644 --- a/lib/dml/oci_native_moodle_database.php +++ b/lib/dml/oci_native_moodle_database.php @@ -245,12 +245,12 @@ class oci_native_moodle_database extends moodle_database { /** * Called before each db query. * @param string $sql - * @param array array of parameters + * @param array|null $params An array of parameters. * @param int $type type of query * @param mixed $extrainfo driver specific extra information * @return void */ - protected function query_start($sql, array $params=null, $type, $extrainfo=null) { + protected function query_start($sql, ?array $params, $type, $extrainfo=null) { parent::query_start($sql, $params, $type, $extrainfo); // oci driver tents to send debug to output, we do not need that ;-) $this->last_error_reporting = error_reporting(0); diff --git a/lib/dml/pdo_moodle_database.php b/lib/dml/pdo_moodle_database.php index 2fef5493c25..90f013b330c 100644 --- a/lib/dml/pdo_moodle_database.php +++ b/lib/dml/pdo_moodle_database.php @@ -614,12 +614,12 @@ abstract class pdo_moodle_database extends moodle_database { * Overridden to ensure $this->lastErorr is reset each query * * @param string $sql - * @param array array of parameters + * @param array|null $params An array of parameters. * @param int $type type of query * @param mixed $extrainfo driver specific extra information * @return void */ - protected function query_start($sql, array $params=null, $type, $extrainfo=null) { + protected function query_start($sql, ?array $params, $type, $extrainfo=null) { $this->lastError = null; parent::query_start($sql, $params, $type, $extrainfo); } diff --git a/lib/dml/pgsql_native_moodle_database.php b/lib/dml/pgsql_native_moodle_database.php index 80e4a57ab4f..f7b8960f8da 100644 --- a/lib/dml/pgsql_native_moodle_database.php +++ b/lib/dml/pgsql_native_moodle_database.php @@ -315,12 +315,12 @@ class pgsql_native_moodle_database extends moodle_database { /** * Called before each db query. * @param string $sql - * @param array array of parameters + * @param array|null $params An array of parameters. * @param int $type type of query * @param mixed $extrainfo driver specific extra information * @return void */ - protected function query_start($sql, array $params=null, $type, $extrainfo=null) { + protected function query_start($sql, ?array $params, $type, $extrainfo=null) { $this->read_slave_query_start($sql, $params, $type, $extrainfo); // pgsql driver tends to send debug to output, we do not need that. $this->last_error_reporting = error_reporting(0); diff --git a/lib/dml/sqlsrv_native_moodle_database.php b/lib/dml/sqlsrv_native_moodle_database.php index 3eef334224b..21601e96572 100644 --- a/lib/dml/sqlsrv_native_moodle_database.php +++ b/lib/dml/sqlsrv_native_moodle_database.php @@ -306,12 +306,12 @@ class sqlsrv_native_moodle_database extends moodle_database { /** * Called before each db query. * @param string $sql - * @param array $params array of parameters + * @param array|null $params An array of parameters. * @param int $type type of query * @param mixed $extrainfo driver specific extra information * @return void */ - protected function query_start($sql, array $params = null, $type, $extrainfo = null) { + protected function query_start($sql, ?array $params, $type, $extrainfo = null) { parent::query_start($sql, $params, $type, $extrainfo); } diff --git a/lib/dml/tests/fixtures/read_slave_moodle_database.php b/lib/dml/tests/fixtures/read_slave_moodle_database.php index 7eddb91355f..067e279e081 100644 --- a/lib/dml/tests/fixtures/read_slave_moodle_database.php +++ b/lib/dml/tests/fixtures/read_slave_moodle_database.php @@ -89,12 +89,12 @@ class read_slave_moodle_database extends test_moodle_database { /** * Query wrapper that calls query_start() and query_end() * @param string $sql - * @param array $params + * @param array|null $params * @param int $querytype * @param ?callable $callback * @return string $handle handle property */ - public function with_query_start_end($sql, array $params = null, $querytype, $callback = null) { + public function with_query_start_end($sql, ?array $params, $querytype, $callback = null) { $this->query_start($sql, $params, $querytype); $ret = $this->handle; if ($callback) { diff --git a/lib/dml/tests/fixtures/test_moodle_read_slave_trait.php b/lib/dml/tests/fixtures/test_moodle_read_slave_trait.php index f8ca1d54e94..78e40193998 100644 --- a/lib/dml/tests/fixtures/test_moodle_read_slave_trait.php +++ b/lib/dml/tests/fixtures/test_moodle_read_slave_trait.php @@ -97,11 +97,11 @@ trait test_moodle_read_slave_trait { /** * Upgrade to public * @param string $sql - * @param array $params + * @param array|null $params * @param int $type * @param array $extrainfo */ - public function query_start($sql, array $params = null, $type, $extrainfo = null) { + public function query_start($sql, ?array $params, $type, $extrainfo = null) { return parent::query_start($sql, $params, $type); } diff --git a/lib/filestorage/tgz_packer.php b/lib/filestorage/tgz_packer.php index 23a8cd3c64e..2d67ade7b10 100644 --- a/lib/filestorage/tgz_packer.php +++ b/lib/filestorage/tgz_packer.php @@ -544,12 +544,12 @@ class tgz_packer extends file_packer { * @param array $expandedfiles List of all files to archive (output) * @param string $archivepath Current path within archive * @param string $path OS path on disk - * @param file_progress $progress Progress indicator or null if none + * @param file_progress|null $progress Progress indicator or null if none * @param int $done Value for progress indicator * @return bool True if successful */ protected function list_files_path(array &$expandedfiles, $archivepath, $path, - file_progress $progress = null, $done) { + ?file_progress $progress , $done) { if (is_dir($path)) { // Unless we're using this directory as archive root, add a // directory entry. diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 6d2c427231e..92e1085fc2b 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -765,13 +765,13 @@ function validate_param($param, $type, $allownull=NULL_NOT_ALLOWED, $debuginfo=' * $options = clean_param($options, PARAM_INT); * * - * @param array $param the variable array we are cleaning + * @param array|null $param the variable array we are cleaning * @param string $type expected format of param after cleaning. * @param bool $recursive clean recursive arrays * @return array * @throws coding_exception */ -function clean_param_array(array $param = null, $type, $recursive = false) { +function clean_param_array(?array $param, $type, $recursive = false) { // Convert null to empty array. $param = (array)$param; foreach ($param as $key => $value) { diff --git a/lib/outputcomponents.php b/lib/outputcomponents.php index 767d88db0b1..b2d6125a90b 100644 --- a/lib/outputcomponents.php +++ b/lib/outputcomponents.php @@ -4698,12 +4698,12 @@ class action_menu_link extends action_link implements renderable { * Constructs the object. * * @param moodle_url $url The URL for the action. - * @param pix_icon $icon The icon to represent the action. + * @param pix_icon|null $icon The icon to represent the action. * @param string $text The text to represent the action. * @param bool $primary Whether this is a primary action or not. * @param array $attributes Any attribtues associated with the action. */ - public function __construct(moodle_url $url, pix_icon $icon = null, $text, $primary = true, array $attributes = array()) { + public function __construct(moodle_url $url, ?pix_icon $icon, $text, $primary = true, array $attributes = array()) { parent::__construct($url, $text, null, $attributes, $icon); $this->primary = (bool)$primary; $this->add_class('menu-action'); @@ -4769,11 +4769,11 @@ class action_menu_link_primary extends action_menu_link { * Constructs the object. * * @param moodle_url $url - * @param pix_icon $icon + * @param pix_icon|null $icon * @param string $text * @param array $attributes */ - public function __construct(moodle_url $url, pix_icon $icon = null, $text, array $attributes = array()) { + public function __construct(moodle_url $url, ?pix_icon $icon, $text, array $attributes = array()) { parent::__construct($url, $icon, $text, true, $attributes); } } @@ -4791,11 +4791,11 @@ class action_menu_link_secondary extends action_menu_link { * Constructs the object. * * @param moodle_url $url - * @param pix_icon $icon + * @param pix_icon|null $icon * @param string $text * @param array $attributes */ - public function __construct(moodle_url $url, pix_icon $icon = null, $text, array $attributes = array()) { + public function __construct(moodle_url $url, ?pix_icon $icon, $text, array $attributes = array()) { parent::__construct($url, $icon, $text, false, $attributes); } } diff --git a/message/classes/search/base_message.php b/message/classes/search/base_message.php index a4aa6fe125d..bcb7dd882bf 100644 --- a/message/classes/search/base_message.php +++ b/message/classes/search/base_message.php @@ -141,7 +141,7 @@ abstract class base_message extends \core_search\base { * @return \moodle_recordset|null Recordset or null if no results possible * @throws \coding_exception If context invalid */ - protected function get_document_recordset_helper($modifiedfrom, \context $context = null, + protected function get_document_recordset_helper($modifiedfrom, ?\context $context, $userfield) { global $DB; diff --git a/search/classes/base.php b/search/classes/base.php index 78c1fe25186..c3678125ff1 100644 --- a/search/classes/base.php +++ b/search/classes/base.php @@ -452,7 +452,7 @@ abstract class base { * @return array Array with SQL and parameters; both null if no need to query * @throws \coding_exception If called with invalid params */ - protected function get_course_level_context_restriction_sql(\context $context = null, + protected function get_course_level_context_restriction_sql(?\context $context, $coursetable, $paramtype = SQL_PARAMS_QM) { global $DB; diff --git a/search/classes/base_mod.php b/search/classes/base_mod.php index ae5e4590a0a..d9516925693 100644 --- a/search/classes/base_mod.php +++ b/search/classes/base_mod.php @@ -109,7 +109,7 @@ abstract class base_mod extends base { * @return array Array with SQL and parameters; both null if no need to query * @throws \coding_exception If called with invalid params */ - protected function get_context_restriction_sql(\context $context = null, $modname, $modtable, + protected function get_context_restriction_sql(?\context $context, $modname, $modtable, $paramtype = SQL_PARAMS_QM) { global $DB;