From 024e36be173aa99c290d7e91ed088c645e523ee6 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Fri, 2 Aug 2024 13:42:14 +0800 Subject: [PATCH] MDL-81634 core: Fix all implicitly defined nullables Note: This does not impact third-party libraries. --- admin/classes/local/settings/filesize.php | 2 +- admin/presets/tests/manager_test.php | 2 +- admin/renderer.php | 2 +- .../tests/local/action/import_test.php | 2 +- .../brickfield/classes/brickfieldconnect.php | 2 +- .../brickfield/classes/local/tool/filter.php | 4 +- .../brickfield/classes/local/tool/tool.php | 4 +- admin/tool/brickfield/classes/manager.php | 2 +- .../classes/local/mlang/langstring.php | 4 +- admin/tool/customlang/locallib.php | 2 +- admin/tool/dataprivacy/classes/api.php | 10 +-- .../classes/expired_contexts_manager.php | 2 +- admin/tool/dataprivacy/classes/purpose.php | 2 +- admin/tool/dataprivacy/tests/api_test.php | 2 +- .../tests/expired_contexts_test.php | 2 +- admin/tool/dbtransfer/locallib.php | 4 +- admin/tool/installaddon/classes/installer.php | 2 +- admin/tool/licensemanager/classes/manager.php | 2 +- admin/tool/log/classes/privacy/provider.php | 2 +- .../lpmigrate/classes/framework_processor.php | 2 +- .../classes/local/form/verification_field.php | 2 +- .../tool/mfa/classes/local/secret_manager.php | 4 +- admin/tool/mfa/classes/output/renderer.php | 2 +- .../moodlenet/classes/profile_manager.php | 2 +- admin/tool/oauth2/classes/form/issuer.php | 2 +- admin/tool/policy/classes/api.php | 2 +- admin/tool/uploaduser/classes/process.php | 2 +- admin/tool/usertours/classes/tour.php | 2 +- admin/tool/usertours/tests/helper_trait.php | 4 +- analytics/classes/local/analyser/base.php | 2 +- analytics/classes/manager.php | 4 +- analytics/classes/prediction.php | 2 +- auth/tests/behat/behat_auth.php | 2 +- availability/classes/frontend.php | 12 ++-- availability/classes/info.php | 4 +- availability/classes/result.php | 2 +- .../condition/completion/classes/frontend.php | 8 +-- .../condition/date/classes/frontend.php | 4 +- .../condition/grade/classes/frontend.php | 4 +- .../condition/group/classes/frontend.php | 8 +-- .../condition/grouping/classes/frontend.php | 8 +-- .../condition/profile/classes/frontend.php | 4 +- .../tests/fixtures/mock_info_module.php | 2 +- .../tests/fixtures/mock_info_section.php | 2 +- backup/cc/cc_lib/cc_version1.php | 2 +- .../controller/restore_controller.class.php | 2 +- backup/converter/moodle1/handlerlib.php | 2 +- backup/moodle2/backup_settingslib.php | 2 +- .../dbops/backup_controller_dbops.class.php | 2 +- .../dbops/backup_structure_dbops.class.php | 2 +- backup/util/dbops/restore_dbops.class.php | 10 +-- .../helper/backup_general_helper.class.php | 2 +- backup/util/helper/backup_helper.class.php | 10 +-- backup/util/settings/backup_setting.class.php | 2 +- .../backup_structure_processor.class.php | 2 +- backup/util/ui/backup_ui.class.php | 2 +- backup/util/ui/backup_ui_setting.class.php | 22 +++---- backup/util/ui/backup_ui_stage.class.php | 20 +++--- backup/util/ui/base_moodleform.class.php | 2 +- backup/util/ui/base_ui.class.php | 4 +- backup/util/ui/base_ui_stage.class.php | 4 +- backup/util/ui/import_extensions.php | 6 +- backup/util/ui/renderer.php | 10 +-- backup/util/ui/restore_ui.class.php | 2 +- backup/util/ui/restore_ui_stage.class.php | 20 +++--- .../classes/output/channel_image.php | 2 +- blog/lib.php | 6 +- cache/classes/helper.php | 4 +- .../local/administration_display_helper.php | 2 +- .../external/events_related_objects_cache.php | 2 +- calendar/classes/local/api.php | 10 +-- .../local/event/data_access/event_vault.php | 18 +++--- .../data_access/event_vault_interface.php | 14 ++--- .../classes/local/event/entities/event.php | 2 +- .../classes/local/event/proxies/std_proxy.php | 2 +- .../raw_event_retrieval_strategy.php | 12 ++-- ...raw_event_retrieval_strategy_interface.php | 12 ++-- calendar/lib.php | 12 ++-- calendar/renderer.php | 2 +- cohort/classes/privacy/provider.php | 2 +- comment/classes/privacy/provider.php | 10 +-- comment/lib.php | 4 +- communication/classes/api.php | 2 +- .../matrix/tests/matrix_client_test_trait.php | 4 +- competency/classes/api.php | 4 +- competency/classes/competency.php | 2 +- competency/classes/user_competency.php | 2 +- competency/classes/user_competency_course.php | 2 +- competency/classes/user_competency_plan.php | 2 +- completion/classes/form/form_trait.php | 2 +- completion/classes/privacy/provider.php | 4 +- completion/criteria/completion_criteria.php | 2 +- .../criteria/completion_criteria_activity.php | 2 +- .../criteria/completion_criteria_date.php | 2 +- .../criteria/completion_criteria_grade.php | 2 +- .../criteria/completion_criteria_self.php | 2 +- .../criteria/completion_criteria_unenrol.php | 2 +- .../tests/cm_completion_details_test.php | 2 +- contentbank/classes/contentbank.php | 8 +-- contentbank/classes/contenttype.php | 6 +- contentbank/classes/form/edit_content.php | 2 +- contentbank/tests/contentbank_test.php | 2 +- ...tion_events_by_timeline_classification.php | 12 ++-- .../helper_for_get_mods_by_courses.php | 2 +- course/classes/management_renderer.php | 20 +++--- course/classes/search/course.php | 2 +- course/classes/search/customfield.php | 2 +- course/classes/search/section.php | 2 +- course/externallib.php | 10 +-- course/format/classes/base.php | 2 +- course/lib.php | 18 +++--- course/renderer.php | 2 +- customfield/classes/category_controller.php | 4 +- customfield/classes/data_controller.php | 2 +- customfield/classes/field_controller.php | 4 +- customfield/classes/handler.php | 2 +- customfield/classes/privacy/provider.php | 2 +- .../textarea/classes/field_controller.php | 2 +- enrol/cohort/lib.php | 2 +- enrol/fee/classes/plugin.php | 2 +- enrol/guest/lib.php | 2 +- enrol/ldap/lib.php | 2 +- enrol/locallib.php | 8 +-- .../entity/application_registration.php | 6 +- .../local/ltiadvantage/entity/context.php | 2 +- .../local/ltiadvantage/entity/deployment.php | 2 +- .../ltiadvantage/entity/resource_link.php | 4 +- .../local/ltiadvantage/entity/user.php | 2 +- enrol/lti/classes/task/sync_members.php | 2 +- enrol/lti/lib.php | 2 +- ...plication_registration_repository_test.php | 4 +- .../repository/deployment_repository_test.php | 2 +- enrol/lti/tests/sync_members_test.php | 2 +- enrol/manual/lib.php | 2 +- enrol/meta/lib.php | 2 +- enrol/paypal/lib.php | 2 +- enrol/self/lib.php | 2 +- .../service/component_favourite_service.php | 2 +- .../local/service/user_favourite_service.php | 4 +- favourites/classes/privacy/provider.php | 4 +- files/renderer.php | 4 +- grade/classes/component_gradeitem.php | 2 +- .../privacy/grade_grade_with_history.php | 2 +- grade/classes/privacy/provider.php | 2 +- grade/grading/classes/privacy/provider.php | 2 +- grade/grading/form/guide/lib.php | 4 +- grade/grading/form/lib.php | 6 +- grade/grading/form/rubric/lib.php | 4 +- grade/grading/lib.php | 6 +- grade/report/history/classes/helper.php | 2 +- .../classes/local/screen/screen.php | 2 +- grade/report/user/classes/report/user.php | 2 +- grade/tests/component_gradeitem_test.php | 2 +- h5p/classes/framework.php | 2 +- h5p/classes/helper.php | 6 +- h5p/tests/generator/lib.php | 6 +- lib/accesslib.php | 6 +- lib/adminlib.php | 6 +- .../MoodleProgressFormatterFactory.php | 2 +- .../ServiceContainer/BehatExtension.php | 2 +- .../check/external/get_result_admintree.php | 4 +- lib/classes/content/export/zipwriter.php | 6 +- lib/classes/dataformat.php | 6 +- lib/classes/event/base.php | 2 +- .../lock/timing_wrapper_lock_factory.php | 2 +- .../inbound/processing_failed_exception.php | 2 +- lib/classes/output/action_menu/subpanel.php | 4 +- lib/classes/output/chooser_item.php | 2 +- lib/classes/output/external.php | 2 +- .../mustache_template_source_loader.php | 4 +- lib/classes/output/select_menu.php | 2 +- lib/classes/persistent.php | 4 +- lib/classes/shutdown_manager.php | 4 +- lib/classes/user.php | 10 +-- lib/clilib.php | 4 +- lib/completionlib.php | 4 +- lib/datalib.php | 14 ++--- lib/ddl/database_manager.php | 2 +- lib/dml/moodle_database.php | 62 +++++++++---------- lib/dml/moodle_read_slave_trait.php | 4 +- lib/dml/mysqli_native_moodle_database.php | 18 +++--- lib/dml/oci_native_moodle_database.php | 18 +++--- lib/dml/pdo_moodle_database.php | 14 ++--- lib/dml/pgsql_native_moodle_database.php | 14 ++--- lib/dml/pgsql_native_moodle_recordset.php | 2 +- lib/dml/sqlite3_pdo_moodle_database.php | 4 +- lib/dml/sqlsrv_native_moodle_database.php | 18 +++--- lib/dml/tests/dml_test.php | 14 ++--- .../fixtures/read_slave_moodle_database.php | 8 +-- .../read_slave_moodle_database_special.php | 8 +-- .../tests/fixtures/test_moodle_database.php | 12 ++-- lib/dmllib.php | 8 +-- lib/dtl/database_mover.php | 2 +- lib/editor/atto/lib.php | 4 +- lib/editor/textarea/lib.php | 2 +- lib/editor/tiny/classes/editor.php | 2 +- lib/editorlib.php | 2 +- lib/enrollib.php | 4 +- lib/filelib.php | 8 +-- lib/filestorage/file_packer.php | 8 +-- lib/filestorage/file_storage.php | 4 +- lib/filestorage/file_system.php | 4 +- lib/filestorage/mbz_packer.php | 8 +-- lib/filestorage/stored_file.php | 4 +- lib/filestorage/tgz_extractor.php | 8 +-- lib/filestorage/tgz_packer.php | 12 ++-- lib/filestorage/zip_packer.php | 12 ++-- lib/form/choicedropdown.php | 2 +- lib/formslib.php | 2 +- lib/grade/grade_grade.php | 4 +- lib/grade/grade_item.php | 2 +- lib/grade/grade_object.php | 4 +- lib/gradelib.php | 2 +- lib/grouplib.php | 8 +-- lib/moodlelib.php | 2 +- lib/navigationlib.php | 16 ++--- lib/pagelib.php | 2 +- lib/portfolio/formats.php | 2 +- lib/questionlib.php | 4 +- lib/testing/classes/util.php | 2 +- lib/testing/generator/data_generator.php | 20 +++--- lib/testing/generator/module_generator.php | 2 +- .../generator/repository_generator.php | 4 +- lib/tests/behat/behat_navigation.php | 4 +- lib/tests/navigationlib_test.php | 2 +- lib/userkey/classes/privacy/provider.php | 2 +- lib/xapi/classes/iri.php | 4 +- .../classes/local/statement/item_activity.php | 4 +- .../classes/local/statement/item_result.php | 2 +- lib/xapi/tests/iri_test.php | 4 +- lib/xmldb/xmldb_field.php | 2 +- lib/xmldb/xmldb_index.php | 2 +- lib/xmldb/xmldb_object.php | 2 +- lib/xmldb/xmldb_table.php | 2 +- message/classes/api.php | 12 ++-- message/classes/helper.php | 6 +- message/classes/search/message_received.php | 2 +- message/classes/search/message_sent.php | 2 +- message/classes/tests/helper.php | 2 +- message/externallib.php | 2 +- .../output/airnotifier/classes/manager.php | 2 +- message/tests/privacy/provider_test.php | 4 +- mod/assign/classes/external/external_api.php | 2 +- mod/assign/classes/output/assign_header.php | 2 +- .../classes/output/grading_actionmenu.php | 2 +- .../output/user_submission_actionmenu.php | 4 +- .../privacy/assign_plugin_request_data.php | 4 +- .../feedback/editpdf/classes/annotation.php | 2 +- .../feedback/editpdf/classes/comment.php | 2 +- mod/assign/lib.php | 2 +- mod/assign/locallib.php | 2 +- mod/assign/renderable.php | 2 +- mod/assign/tests/generator/lib.php | 2 +- mod/bigbluebuttonbn/classes/extension.php | 2 +- .../classes/external/update_recording.php | 2 +- .../recordings/recording_data.php | 2 +- .../local/extension/mod_form_addons.php | 2 +- .../classes/local/helpers/roles.php | 2 +- .../local/proxy/bigbluebutton_proxy.php | 2 +- mod/bigbluebuttonbn/classes/recording.php | 2 +- mod/bigbluebuttonbn/classes/search/tags.php | 2 +- mod/bigbluebuttonbn/tests/generator/lib.php | 4 +- .../output/recording_row_playback_test.php | 2 +- mod/book/classes/search/chapter.php | 2 +- mod/book/tests/generator/lib.php | 4 +- mod/chat/tests/generator/lib.php | 2 +- mod/choice/tests/generator/lib.php | 2 +- mod/data/classes/local/exporter/utils.php | 2 +- mod/data/classes/search/entry.php | 2 +- mod/data/classes/template.php | 2 +- mod/data/lib.php | 2 +- mod/data/tests/generator/lib.php | 8 +-- mod/feedback/lib.php | 2 +- mod/feedback/tests/generator/lib.php | 2 +- mod/folder/backup/moodle1/lib.php | 2 +- mod/folder/tests/generator/lib.php | 2 +- mod/forum/classes/grades/forum_gradeitem.php | 2 +- mod/forum/classes/local/entities/author.php | 10 +-- .../classes/local/factories/exporter.php | 2 +- .../classes/local/factories/renderer.php | 2 +- mod/forum/classes/local/factories/url.php | 2 +- .../classes/local/managers/capability.php | 4 +- .../classes/local/renderers/discussion.php | 2 +- .../local/renderers/discussion_list.php | 4 +- mod/forum/classes/local/renderers/posts.php | 2 +- mod/forum/classes/local/vaults/author.php | 2 +- .../classes/local/vaults/db_table_vault.php | 2 +- mod/forum/classes/local/vaults/discussion.php | 4 +- .../classes/local/vaults/discussion_list.php | 4 +- mod/forum/classes/local/vaults/forum.php | 2 +- mod/forum/classes/local/vaults/post.php | 2 +- .../vaults/post_read_receipt_collection.php | 2 +- mod/forum/classes/search/post.php | 2 +- mod/forum/lib.php | 2 +- mod/forum/tests/generator/lib.php | 2 +- mod/glossary/classes/search/entry.php | 2 +- mod/glossary/tests/generator/lib.php | 2 +- .../classes/external/log_report_viewed.php | 2 +- mod/h5pactivity/classes/local/attempt.php | 2 +- mod/h5pactivity/classes/local/manager.php | 10 +-- mod/h5pactivity/classes/output/attempt.php | 6 +- .../classes/output/reportattempts.php | 2 +- mod/h5pactivity/classes/output/result.php | 2 +- mod/h5pactivity/classes/privacy/provider.php | 2 +- mod/h5pactivity/lib.php | 6 +- mod/h5pactivity/tests/generator/lib.php | 2 +- mod/imscp/backup/moodle1/lib.php | 2 +- mod/imscp/tests/generator/lib.php | 2 +- mod/label/tests/generator/lib.php | 2 +- mod/lesson/renderer.php | 2 +- mod/lesson/tests/generator/lib.php | 6 +- .../local/ltiopenid/registration_helper.php | 2 +- .../local/service/gradebookservices.php | 2 +- .../tests/gradebookservices_test.php | 2 +- mod/lti/tests/generator/lib.php | 2 +- mod/page/backup/moodle1/lib.php | 2 +- mod/page/tests/generator/lib.php | 2 +- mod/quiz/accessrule/seb/classes/helper.php | 2 +- .../seb/classes/template_controller.php | 2 +- mod/quiz/accessrule/seb/rule.php | 2 +- .../seb/tests/test_helper_trait.php | 2 +- .../local/reports/attempts_report_table.php | 2 +- mod/quiz/classes/output/renderer.php | 2 +- .../classes/question/bank/qbank_helper.php | 2 +- .../bank/quiz_managecategories_feature.php | 2 +- mod/quiz/classes/quiz_settings.php | 6 +- mod/quiz/report/reportlib.php | 2 +- .../report/statistics/classes/calculator.php | 2 +- .../report/statistics/statistics_table.php | 4 +- mod/quiz/tests/generator/lib.php | 2 +- mod/resource/tests/generator/lib.php | 2 +- mod/scorm/tests/generator/lib.php | 2 +- mod/survey/classes/search/activity.php | 2 +- mod/survey/tests/generator/lib.php | 2 +- mod/url/backup/moodle1/lib.php | 2 +- mod/url/tests/generator/lib.php | 2 +- .../classes/search/collaborative_page.php | 2 +- mod/wiki/tests/generator/lib.php | 2 +- mod/workshop/eval/best/lib.php | 2 +- mod/workshop/eval/lib.php | 2 +- mod/workshop/form/accumulative/lib.php | 2 +- mod/workshop/form/comments/lib.php | 2 +- mod/workshop/form/lib.php | 2 +- mod/workshop/form/numerrors/lib.php | 2 +- mod/workshop/form/rubric/lib.php | 2 +- mod/workshop/lib.php | 2 +- mod/workshop/locallib.php | 4 +- mod/workshop/tests/generator/lib.php | 2 +- .../deletequestion/classes/plugin_feature.php | 2 +- .../classes/editquestion_helper.php | 2 +- .../editquestion/classes/qbank_chooser.php | 2 +- .../history/classes/question_history_view.php | 2 +- .../classes/category_condition.php | 2 +- .../classes/plugin_feature.php | 2 +- .../classes/question_category_object.php | 2 +- .../tagquestion/classes/plugin_feature.php | 2 +- question/classes/local/bank/condition.php | 2 +- .../local/bank/plugin_features_base.php | 2 +- question/classes/privacy/provider.php | 2 +- .../questions/calculated_question_summary.php | 4 +- .../responses/analysis_for_question.php | 2 +- .../responses/analysis_for_subpart.php | 2 +- question/engine/datalib.php | 2 +- question/engine/lib.php | 6 +- question/engine/questionattempt.php | 2 +- question/engine/questionusage.php | 4 +- question/engine/tests/helpers.php | 4 +- question/type/ordering/question.php | 8 +-- question/type/ordering/questiontype.php | 4 +- rating/classes/privacy/provider.php | 4 +- report/log/tests/renderable_test.php | 2 +- report/stats/classes/privacy/provider.php | 2 +- .../classes/local/helpers/database.php | 2 +- .../local/helpers/user_filter_manager.php | 10 +-- repository/dropbox/lib.php | 2 +- repository/equella/lib.php | 2 +- repository/filesystem/lib.php | 2 +- repository/googledocs/lib.php | 2 +- repository/lib.php | 2 +- repository/nextcloud/lib.php | 2 +- repository/onedrive/lib.php | 2 +- search/classes/base.php | 2 +- search/classes/base_activity.php | 2 +- search/classes/base_block.php | 4 +- search/classes/manager.php | 6 +- search/engine/solr/classes/schema.php | 2 +- user/classes/search/course_teacher.php | 2 +- user/classes/search/user.php | 2 +- user/filters/lib.php | 2 +- webservice/soap/classes/wsdl.php | 2 +- webservice/soap/lib.php | 2 +- 391 files changed, 782 insertions(+), 782 deletions(-) diff --git a/admin/classes/local/settings/filesize.php b/admin/classes/local/settings/filesize.php index 14721504606..1a9cb375d4b 100644 --- a/admin/classes/local/settings/filesize.php +++ b/admin/classes/local/settings/filesize.php @@ -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); diff --git a/admin/presets/tests/manager_test.php b/admin/presets/tests/manager_test.php index 1690968221f..6444b513e9e 100644 --- a/admin/presets/tests/manager_test.php +++ b/admin/presets/tests/manager_test.php @@ -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; diff --git a/admin/renderer.php b/admin/renderer.php index 6e53a42ad2e..e5c6c93542e 100644 --- a/admin/renderer.php +++ b/admin/renderer.php @@ -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'); diff --git a/admin/tool/admin_presets/tests/local/action/import_test.php b/admin/tool/admin_presets/tests/local/action/import_test.php index db31668f2c9..d36cca2430e 100644 --- a/admin/tool/admin_presets/tests/local/action/import_test.php +++ b/admin/tool/admin_presets/tests/local/action/import_test.php @@ -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; diff --git a/admin/tool/brickfield/classes/brickfieldconnect.php b/admin/tool/brickfield/classes/brickfieldconnect.php index 0b1657109a9..faf77a58cf8 100644 --- a/admin/tool/brickfield/classes/brickfieldconnect.php +++ b/admin/tool/brickfield/classes/brickfieldconnect.php @@ -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; diff --git a/admin/tool/brickfield/classes/local/tool/filter.php b/admin/tool/brickfield/classes/local/tool/filter.php index e308464ace4..afa51766cdb 100644 --- a/admin/tool/brickfield/classes/local/tool/filter.php +++ b/admin/tool/brickfield/classes/local/tool/filter.php @@ -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. diff --git a/admin/tool/brickfield/classes/local/tool/tool.php b/admin/tool/brickfield/classes/local/tool/tool.php index 2050262152d..6c70b002333 100644 --- a/admin/tool/brickfield/classes/local/tool/tool.php +++ b/admin/tool/brickfield/classes/local/tool/tool.php @@ -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 { diff --git a/admin/tool/brickfield/classes/manager.php b/admin/tool/brickfield/classes/manager.php index 0c67267a169..cb606f00a49 100644 --- a/admin/tool/brickfield/classes/manager.php +++ b/admin/tool/brickfield/classes/manager.php @@ -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)) { diff --git a/admin/tool/customlang/classes/local/mlang/langstring.php b/admin/tool/customlang/classes/local/mlang/langstring.php index f380cd6bf06..f40cc685d9b 100644 --- a/admin/tool/customlang/classes/local/mlang/langstring.php +++ b/admin/tool/customlang/classes/local/mlang/langstring.php @@ -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(); diff --git a/admin/tool/customlang/locallib.php b/admin/tool/customlang/locallib.php index 80c7c2da137..c76ff7829fb 100644 --- a/admin/tool/customlang/locallib.php +++ b/admin/tool/customlang/locallib.php @@ -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"); diff --git a/admin/tool/dataprivacy/classes/api.php b/admin/tool/dataprivacy/classes/api.php index bfa1b96ddc7..5e649d14532 100644 --- a/admin/tool/dataprivacy/classes/api.php +++ b/admin/tool/dataprivacy/classes/api.php @@ -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) { diff --git a/admin/tool/dataprivacy/classes/expired_contexts_manager.php b/admin/tool/dataprivacy/classes/expired_contexts_manager.php index 26d8931b104..856bf4dcffb 100644 --- a/admin/tool/dataprivacy/classes/expired_contexts_manager.php +++ b/admin/tool/dataprivacy/classes/expired_contexts_manager.php @@ -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(); } diff --git a/admin/tool/dataprivacy/classes/purpose.php b/admin/tool/dataprivacy/classes/purpose.php index 2e4ef7292af..3d74f86d3ec 100644 --- a/admin/tool/dataprivacy/classes/purpose.php +++ b/admin/tool/dataprivacy/classes/purpose.php @@ -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) { diff --git a/admin/tool/dataprivacy/tests/api_test.php b/admin/tool/dataprivacy/tests/api_test.php index ee44389e967..e2c2dce5678 100644 --- a/admin/tool/dataprivacy/tests/api_test.php +++ b/admin/tool/dataprivacy/tests/api_test.php @@ -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) [ diff --git a/admin/tool/dataprivacy/tests/expired_contexts_test.php b/admin/tool/dataprivacy/tests/expired_contexts_test.php index d851000ba6a..daa8cdf4750 100644 --- a/admin/tool/dataprivacy/tests/expired_contexts_test.php +++ b/admin/tool/dataprivacy/tests/expired_contexts_test.php @@ -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) [ diff --git a/admin/tool/dbtransfer/locallib.php b/admin/tool/dbtransfer/locallib.php index d0ea4e74bec..3bc0826c6c7 100644 --- a/admin/tool/dbtransfer/locallib.php +++ b/admin/tool/dbtransfer/locallib.php @@ -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"); diff --git a/admin/tool/installaddon/classes/installer.php b/admin/tool/installaddon/classes/installer.php index 07e1fe402e5..e8a4e150fb8 100644 --- a/admin/tool/installaddon/classes/installer.php +++ b/admin/tool/installaddon/classes/installer.php @@ -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); } diff --git a/admin/tool/licensemanager/classes/manager.php b/admin/tool/licensemanager/classes/manager.php index 1b6571e3200..6d0088a05e9 100644 --- a/admin/tool/licensemanager/classes/manager.php +++ b/admin/tool/licensemanager/classes/manager.php @@ -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'); diff --git a/admin/tool/log/classes/privacy/provider.php b/admin/tool/log/classes/privacy/provider.php index b1cfbe5780a..9c6f1e0e1be 100644 --- a/admin/tool/log/classes/privacy/provider.php +++ b/admin/tool/log/classes/privacy/provider.php @@ -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; } diff --git a/admin/tool/lpmigrate/classes/framework_processor.php b/admin/tool/lpmigrate/classes/framework_processor.php index 0dac5e7607f..e264cd59555 100644 --- a/admin/tool/lpmigrate/classes/framework_processor.php +++ b/admin/tool/lpmigrate/classes/framework_processor.php @@ -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) { diff --git a/admin/tool/mfa/classes/local/form/verification_field.php b/admin/tool/mfa/classes/local/form/verification_field.php index 43cbae5e930..82aebe74b9d 100644 --- a/admin/tool/mfa/classes/local/form/verification_field.php +++ b/admin/tool/mfa/classes/local/form/verification_field.php @@ -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. diff --git a/admin/tool/mfa/classes/local/secret_manager.php b/admin/tool/mfa/classes/local/secret_manager.php index 53b78fd3dbc..f62c7d36681 100644 --- a/admin/tool/mfa/classes/local/secret_manager.php +++ b/admin/tool/mfa/classes/local/secret_manager.php @@ -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; diff --git a/admin/tool/mfa/classes/output/renderer.php b/admin/tool/mfa/classes/output/renderer.php index 978732a277f..32f093cc83c 100644 --- a/admin/tool/mfa/classes/output/renderer.php +++ b/admin/tool/mfa/classes/output/renderer.php @@ -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'); diff --git a/admin/tool/moodlenet/classes/profile_manager.php b/admin/tool/moodlenet/classes/profile_manager.php index d4096b71b9b..94ab64de549 100644 --- a/admin/tool/moodlenet/classes/profile_manager.php +++ b/admin/tool/moodlenet/classes/profile_manager.php @@ -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]); diff --git a/admin/tool/oauth2/classes/form/issuer.php b/admin/tool/oauth2/classes/form/issuer.php index cb838da60a3..93ab537bd48 100644 --- a/admin/tool/oauth2/classes/form/issuer.php +++ b/admin/tool/oauth2/classes/form/issuer.php @@ -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']; diff --git a/admin/tool/policy/classes/api.php b/admin/tool/policy/classes/api.php index 887147b912a..e511f15c3ad 100644 --- a/admin/tool/policy/classes/api.php +++ b/admin/tool/policy/classes/api.php @@ -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'); diff --git a/admin/tool/uploaduser/classes/process.php b/admin/tool/uploaduser/classes/process.php index f817797bb52..a13013f59a4 100644 --- a/admin/tool/uploaduser/classes/process.php +++ b/admin/tool/uploaduser/classes/process.php @@ -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)) { diff --git a/admin/tool/usertours/classes/tour.php b/admin/tool/usertours/classes/tour.php index 61001c5745d..211c0fd53e4 100644 --- a/admin/tool/usertours/classes/tour.php +++ b/admin/tool/usertours/classes/tour.php @@ -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(); } diff --git a/admin/tool/usertours/tests/helper_trait.php b/admin/tool/usertours/tests/helper_trait.php index 988ace5abcd..5ec99d624db 100644 --- a/admin/tool/usertours/tests/helper_trait.php +++ b/admin/tool/usertours/tests/helper_trait.php @@ -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' => '', diff --git a/analytics/classes/local/analyser/base.php b/analytics/classes/local/analyser/base.php index 6908c19369a..778098af7cf 100644 --- a/analytics/classes/local/analyser/base.php +++ b/analytics/classes/local/analyser/base.php @@ -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); } diff --git a/analytics/classes/manager.php b/analytics/classes/manager.php index 8bee35d30aa..5433c434c7e 100644 --- a/analytics/classes/manager.php +++ b/analytics/classes/manager.php @@ -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)) { diff --git a/analytics/classes/prediction.php b/analytics/classes/prediction.php index 3b0aced6c9d..501283bdbbc 100644 --- a/analytics/classes/prediction.php +++ b/analytics/classes/prediction.php @@ -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"; diff --git a/auth/tests/behat/behat_auth.php b/auth/tests/behat/behat_auth.php index 08d75997f31..b775252e771 100644 --- a/auth/tests/behat/behat_auth.php +++ b/auth/tests/behat/behat_auth.php @@ -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]); diff --git a/availability/classes/frontend.php b/availability/classes/frontend.php index 831f6f91b02..b3b894c6604 100644 --- a/availability/classes/frontend.php +++ b/availability/classes/frontend.php @@ -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 diff --git a/availability/classes/info.php b/availability/classes/info.php index 52b64a2c292..a12307f18f5 100644 --- a/availability/classes/info.php +++ b/availability/classes/info.php @@ -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 ''; diff --git a/availability/classes/result.php b/availability/classes/result.php index d69a00901de..08b9e6cf9b9 100644 --- a/availability/classes/result.php +++ b/availability/classes/result.php @@ -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) { diff --git a/availability/condition/completion/classes/frontend.php b/availability/condition/completion/classes/frontend.php index b2c36e5078e..9ca1b2408fa 100644 --- a/availability/condition/completion/classes/frontend.php +++ b/availability/condition/completion/classes/frontend.php @@ -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. diff --git a/availability/condition/date/classes/frontend.php b/availability/condition/date/classes/frontend.php index ce91d037990..567ebaeca81 100644 --- a/availability/condition/date/classes/frontend.php +++ b/availability/condition/date/classes/frontend.php @@ -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'); diff --git a/availability/condition/grade/classes/frontend.php b/availability/condition/grade/classes/frontend.php index aee9f9f7739..7a9707dbb6c 100644 --- a/availability/condition/grade/classes/frontend.php +++ b/availability/condition/grade/classes/frontend.php @@ -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'); diff --git a/availability/condition/group/classes/frontend.php b/availability/condition/group/classes/frontend.php index 26d7830282c..9478c15963e 100644 --- a/availability/condition/group/classes/frontend.php +++ b/availability/condition/group/classes/frontend.php @@ -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. diff --git a/availability/condition/grouping/classes/frontend.php b/availability/condition/grouping/classes/frontend.php index 0890eea6020..626fe7ee673 100644 --- a/availability/condition/grouping/classes/frontend.php +++ b/availability/condition/grouping/classes/frontend.php @@ -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' diff --git a/availability/condition/profile/classes/frontend.php b/availability/condition/profile/classes/frontend.php index 288ad9e69ee..2a4d4747244 100644 --- a/availability/condition/profile/classes/frontend.php +++ b/availability/condition/profile/classes/frontend.php @@ -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(); diff --git a/availability/tests/fixtures/mock_info_module.php b/availability/tests/fixtures/mock_info_module.php index 5c13f3b864e..97007be3a22 100644 --- a/availability/tests/fixtures/mock_info_module.php +++ b/availability/tests/fixtures/mock_info_module.php @@ -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; diff --git a/availability/tests/fixtures/mock_info_section.php b/availability/tests/fixtures/mock_info_section.php index 2dde1240622..2444690d289 100644 --- a/availability/tests/fixtures/mock_info_section.php +++ b/availability/tests/fixtures/mock_info_section.php @@ -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; diff --git a/backup/cc/cc_lib/cc_version1.php b/backup/cc/cc_lib/cc_version1.php index b6b30779d90..3d7186a25ec 100644 --- a/backup/cc/cc_lib/cc_version1.php +++ b/backup/cc/cc_lib/cc_version1.php @@ -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); diff --git a/backup/controller/restore_controller.class.php b/backup/controller/restore_controller.class.php index 61032de826a..a4fefc426b7 100644 --- a/backup/controller/restore_controller.class.php +++ b/backup/controller/restore_controller.class.php @@ -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'); diff --git a/backup/converter/moodle1/handlerlib.php b/backup/converter/moodle1/handlerlib.php index a32e4365829..a13dc2014d6 100644 --- a/backup/converter/moodle1/handlerlib.php +++ b/backup/converter/moodle1/handlerlib.php @@ -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) { } /** diff --git a/backup/moodle2/backup_settingslib.php b/backup/moodle2/backup_settingslib.php index 770c3813ce5..4b96aad42f6 100644 --- a/backup/moodle2/backup_settingslib.php +++ b/backup/moodle2/backup_settingslib.php @@ -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); } diff --git a/backup/util/dbops/backup_controller_dbops.class.php b/backup/util/dbops/backup_controller_dbops.class.php index f022b76b70d..a199a56b657 100644 --- a/backup/util/dbops/backup_controller_dbops.class.php +++ b/backup/util/dbops/backup_controller_dbops.class.php @@ -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) { diff --git a/backup/util/dbops/backup_structure_dbops.class.php b/backup/util/dbops/backup_structure_dbops.class.php index 249a55d27da..a57dd9e7ced 100644 --- a/backup/util/dbops/backup_structure_dbops.class.php +++ b/backup/util/dbops/backup_structure_dbops.class.php @@ -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} diff --git a/backup/util/dbops/restore_dbops.class.php b/backup/util/dbops/restore_dbops.class.php index 0633fd8567c..cb3ff984c03 100644 --- a/backup/util/dbops/restore_dbops.class.php +++ b/backup/util/dbops/restore_dbops.class.php @@ -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); } diff --git a/backup/util/helper/backup_general_helper.class.php b/backup/util/helper/backup_general_helper.class.php index e84b6f81a18..fe7f92e392e 100644 --- a/backup/util/helper/backup_general_helper.class.php +++ b/backup/util/helper/backup_general_helper.class.php @@ -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); diff --git a/backup/util/helper/backup_helper.class.php b/backup/util/helper/backup_helper.class.php index 89ef8298f8e..f377fb138b1 100644 --- a/backup/util/helper/backup_helper.class.php +++ b/backup/util/helper/backup_helper.class.php @@ -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 diff --git a/backup/util/settings/backup_setting.class.php b/backup/util/settings/backup_setting.class.php index 7856dd46774..c6dcba9f765 100644 --- a/backup/util/settings/backup_setting.class.php +++ b/backup/util/settings/backup_setting.class.php @@ -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; diff --git a/backup/util/structure/backup_structure_processor.class.php b/backup/util/structure/backup_structure_processor.class.php index 9085af0b442..0208c30ed46 100644 --- a/backup/util/structure/backup_structure_processor.class.php +++ b/backup/util/structure/backup_structure_processor.class.php @@ -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(); diff --git a/backup/util/ui/backup_ui.class.php b/backup/util/ui/backup_ui.class.php index 02b71dbd25f..6816571d23c 100644 --- a/backup/util/ui/backup_ui.class.php +++ b/backup/util/ui/backup_ui.class.php @@ -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); } diff --git a/backup/util/ui/backup_ui_setting.class.php b/backup/util/ui/backup_ui_setting.class.php index ed82227e23c..9249c691fde 100644 --- a/backup/util/ui/backup_ui_setting.class.php +++ b/backup/util/ui/backup_ui_setting.class.php @@ -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); } diff --git a/backup/util/ui/backup_ui_stage.class.php b/backup/util/ui/backup_ui_stage.class.php index be9dd2b769f..1ae525b326b 100644 --- a/backup/util/ui/backup_ui_stage.class.php +++ b/backup/util/ui/backup_ui_stage.class.php @@ -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; diff --git a/backup/util/ui/base_moodleform.class.php b/backup/util/ui/base_moodleform.class.php index f4a0ed5cebd..0cfd07b6205 100644 --- a/backup/util/ui/base_moodleform.class.php +++ b/backup/util/ui/base_moodleform.class.php @@ -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))); } diff --git a/backup/util/ui/base_ui.class.php b/backup/util/ui/base_ui.class.php index 46e25a854b5..dea64624a98 100644 --- a/backup/util/ui/base_ui.class.php +++ b/backup/util/ui/base_ui.class.php @@ -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 diff --git a/backup/util/ui/base_ui_stage.class.php b/backup/util/ui/base_ui_stage.class.php index 6cd368af931..6e3762bbefa 100644 --- a/backup/util/ui/base_ui_stage.class.php +++ b/backup/util/ui/base_ui_stage.class.php @@ -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 diff --git a/backup/util/ui/import_extensions.php b/backup/util/ui/import_extensions.php index f39e0dce40d..684b5e473fd 100644 --- a/backup/util/ui/import_extensions.php +++ b/backup/util/ui/import_extensions.php @@ -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; } diff --git a/backup/util/ui/renderer.php b/backup/util/ui/renderer.php index 87c137a757a..ec461e6fb9b 100644 --- a/backup/util/ui/renderer.php +++ b/backup/util/ui/renderer.php @@ -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']; diff --git a/backup/util/ui/restore_ui.class.php b/backup/util/ui/restore_ui.class.php index 98a105704a3..9f00cad2302 100644 --- a/backup/util/ui/restore_ui.class.php +++ b/backup/util/ui/restore_ui.class.php @@ -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); } diff --git a/backup/util/ui/restore_ui_stage.class.php b/backup/util/ui/restore_ui_stage.class.php index 937e38e9866..82c85be1992 100644 --- a/backup/util/ui/restore_ui_stage.class.php +++ b/backup/util/ui/restore_ui_stage.class.php @@ -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; diff --git a/blocks/rss_client/classes/output/channel_image.php b/blocks/rss_client/classes/output/channel_image.php index af9e22fef14..1017351276c 100644 --- a/blocks/rss_client/classes/output/channel_image.php +++ b/blocks/rss_client/classes/output/channel_image.php @@ -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; diff --git a/blog/lib.php b/blog/lib.php index b98ac2e4766..c47c0f7ba44 100644 --- a/blog/lib.php +++ b/blog/lib.php @@ -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(); diff --git a/cache/classes/helper.php b/cache/classes/helper.php index a88372e77e1..d65b55252fc 100644 --- a/cache/classes/helper.php +++ b/cache/classes/helper.php @@ -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'); diff --git a/cache/classes/local/administration_display_helper.php b/cache/classes/local/administration_display_helper.php index 6d4409c724f..900cb89f437 100644 --- a/cache/classes/local/administration_display_helper.php +++ b/cache/classes/local/administration_display_helper.php @@ -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)) { diff --git a/calendar/classes/external/events_related_objects_cache.php b/calendar/classes/external/events_related_objects_cache.php index dd38cb1cfe1..f4cc50fe258 100644 --- a/calendar/classes/external/events_related_objects_cache.php +++ b/calendar/classes/external/events_related_objects_cache.php @@ -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)) { diff --git a/calendar/classes/local/api.php b/calendar/classes/local/api.php index a29a429b099..96fd21c4a03 100644 --- a/calendar/classes/local/api.php +++ b/calendar/classes/local/api.php @@ -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; diff --git a/calendar/classes/local/event/data_access/event_vault.php b/calendar/classes/local/event/data_access/event_vault.php index 1a79f1f19fc..f7c513307a3 100644 --- a/calendar/classes/local/event/data_access/event_vault.php +++ b/calendar/classes/local/event/data_access/event_vault.php @@ -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 ) { diff --git a/calendar/classes/local/event/data_access/event_vault_interface.php b/calendar/classes/local/event/data_access/event_vault_interface.php index 78dbf91fabf..fd907acec9a 100644 --- a/calendar/classes/local/event/data_access/event_vault_interface.php +++ b/calendar/classes/local/event/data_access/event_vault_interface.php @@ -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 ); diff --git a/calendar/classes/local/event/entities/event.php b/calendar/classes/local/event/entities/event.php index b0f3f428b14..25f91c67244 100644 --- a/calendar/classes/local/event/entities/event.php +++ b/calendar/classes/local/event/entities/event.php @@ -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 ) { diff --git a/calendar/classes/local/event/proxies/std_proxy.php b/calendar/classes/local/event/proxies/std_proxy.php index 04c892d2ff3..46a04b89a6d 100644 --- a/calendar/classes/local/event/proxies/std_proxy.php +++ b/calendar/classes/local/event/proxies/std_proxy.php @@ -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; diff --git a/calendar/classes/local/event/strategies/raw_event_retrieval_strategy.php b/calendar/classes/local/event/strategies/raw_event_retrieval_strategy.php index 794ea3e9ae1..3c3ad7cf54b 100644 --- a/calendar/classes/local/event/strategies/raw_event_retrieval_strategy.php +++ b/calendar/classes/local/event/strategies/raw_event_retrieval_strategy.php @@ -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, diff --git a/calendar/classes/local/event/strategies/raw_event_retrieval_strategy_interface.php b/calendar/classes/local/event/strategies/raw_event_retrieval_strategy_interface.php index 9225a397a01..ddc984d7d91 100644 --- a/calendar/classes/local/event/strategies/raw_event_retrieval_strategy_interface.php +++ b/calendar/classes/local/event/strategies/raw_event_retrieval_strategy_interface.php @@ -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, diff --git a/calendar/lib.php b/calendar/lib.php index 8f49b89e8ac..d7691ada9d1 100644 --- a/calendar/lib.php +++ b/calendar/lib.php @@ -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 = [ diff --git a/calendar/renderer.php b/calendar/renderer.php index 7766e1b30de..6e974ddbec7 100644 --- a/calendar/renderer.php +++ b/calendar/renderer.php @@ -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()) { diff --git a/cohort/classes/privacy/provider.php b/cohort/classes/privacy/provider.php index 48b9fed9252..0c31af52d92 100644 --- a/cohort/classes/privacy/provider.php +++ b/cohort/classes/privacy/provider.php @@ -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]); diff --git a/comment/classes/privacy/provider.php b/comment/classes/privacy/provider.php index 1b2f73c2c60..7714d09b665 100644 --- a/comment/classes/privacy/provider.php +++ b/comment/classes/privacy/provider.php @@ -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 != '') { diff --git a/comment/lib.php b/comment/lib.php index 41c77e87147..a7f74cbd88a 100644 --- a/comment/lib.php +++ b/comment/lib.php @@ -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; diff --git a/communication/classes/api.php b/communication/classes/api.php index a98592880fe..f4afcf70042 100644 --- a/communication/classes/api.php +++ b/communication/classes/api.php @@ -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)) { diff --git a/communication/provider/matrix/tests/matrix_client_test_trait.php b/communication/provider/matrix/tests/matrix_client_test_trait.php index 02d33f337c2..e3609913daf 100644 --- a/communication/provider/matrix/tests/matrix_client_test_trait.php +++ b/communication/provider/matrix/tests/matrix_client_test_trait.php @@ -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()), diff --git a/competency/classes/api.php b/competency/classes/api.php index 69c0afeb8a7..5212f6580c6 100644 --- a/competency/classes/api.php +++ b/competency/classes/api.php @@ -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')) { diff --git a/competency/classes/competency.php b/competency/classes/competency.php index 5df830220b9..3ad434e3011 100644 --- a/competency/classes/competency.php +++ b/competency/classes/competency.php @@ -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(); diff --git a/competency/classes/user_competency.php b/competency/classes/user_competency.php index 5e6777696b9..bc14dacebbf 100644 --- a/competency/classes/user_competency.php +++ b/competency/classes/user_competency.php @@ -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(); diff --git a/competency/classes/user_competency_course.php b/competency/classes/user_competency_course.php index ad97f6cb011..882f074ebbb 100644 --- a/competency/classes/user_competency_course.php +++ b/competency/classes/user_competency_course.php @@ -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(); diff --git a/competency/classes/user_competency_plan.php b/competency/classes/user_competency_plan.php index 5b53589cd41..53e89b2c765 100644 --- a/competency/classes/user_competency_plan.php +++ b/competency/classes/user_competency_plan.php @@ -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(); diff --git a/completion/classes/form/form_trait.php b/completion/classes/form/form_trait.php index 2c4bccc5813..e4e60fd62fd 100644 --- a/completion/classes/form/form_trait.php +++ b/completion/classes/form/form_trait.php @@ -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, diff --git a/completion/classes/privacy/provider.php b/completion/classes/privacy/provider.php index 04dbcb9b0ac..a6f8d4ffebc 100644 --- a/completion/classes/privacy/provider.php +++ b/completion/classes/privacy/provider.php @@ -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(); diff --git a/completion/criteria/completion_criteria.php b/completion/criteria/completion_criteria.php index 5b634e89d3b..a328ac0217f 100644 --- a/completion/criteria/completion_criteria.php +++ b/completion/criteria/completion_criteria.php @@ -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]; diff --git a/completion/criteria/completion_criteria_activity.php b/completion/criteria/completion_criteria_activity.php index b4f78d841a3..f1f31c5dcc6 100644 --- a/completion/criteria/completion_criteria_activity.php +++ b/completion/criteria/completion_criteria_activity.php @@ -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); } } diff --git a/completion/criteria/completion_criteria_date.php b/completion/criteria/completion_criteria_date.php index 33bd9370cd4..04f8f0bb4ed 100644 --- a/completion/criteria/completion_criteria_date.php +++ b/completion/criteria/completion_criteria_date.php @@ -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); } diff --git a/completion/criteria/completion_criteria_grade.php b/completion/criteria/completion_criteria_grade.php index 40707e5dc64..ebe0128892a 100644 --- a/completion/criteria/completion_criteria_grade.php +++ b/completion/criteria/completion_criteria_grade.php @@ -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); } } diff --git a/completion/criteria/completion_criteria_self.php b/completion/criteria/completion_criteria_self.php index 9631f7f1ce1..6e11e6a9c1f 100644 --- a/completion/criteria/completion_criteria_self.php +++ b/completion/criteria/completion_criteria_self.php @@ -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); } } diff --git a/completion/criteria/completion_criteria_unenrol.php b/completion/criteria/completion_criteria_unenrol.php index b461cdf984a..2ae1b9c53a6 100644 --- a/completion/criteria/completion_criteria_unenrol.php +++ b/completion/criteria/completion_criteria_unenrol.php @@ -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); } } diff --git a/completion/tests/cm_completion_details_test.php b/completion/tests/cm_completion_details_test.php index faede9eafda..2b98c943068 100644 --- a/completion/tests/cm_completion_details_test.php +++ b/completion/tests/cm_completion_details_test.php @@ -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; } diff --git a/contentbank/classes/contentbank.php b/contentbank/classes/contentbank.php index 43976a6263c..f6e3c364321 100644 --- a/contentbank/classes/contentbank.php +++ b/contentbank/classes/contentbank.php @@ -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) { diff --git a/contentbank/classes/contenttype.php b/contentbank/classes/contenttype.php index dc7f22a6f5c..4acd969006f 100644 --- a/contentbank/classes/contenttype.php +++ b/contentbank/classes/contenttype.php @@ -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(); diff --git a/contentbank/classes/form/edit_content.php b/contentbank/classes/form/edit_content.php index e75b7316fa2..a008e2582bd 100644 --- a/contentbank/classes/form/edit_content.php +++ b/contentbank/classes/form/edit_content.php @@ -55,7 +55,7 @@ abstract class edit_content extends moodleform { * @param array $customdata Data to set during instance creation. * @param string $method Form method. */ - public function __construct(string $action = null, array $customdata = null, string $method = 'post') { + public function __construct(?string $action = null, ?array $customdata = null, string $method = 'post') { parent::__construct($action, $customdata, $method); $this->contextid = $customdata['contextid']; $this->plugin = $customdata['plugin']; diff --git a/contentbank/tests/contentbank_test.php b/contentbank/tests/contentbank_test.php index 2efb13eef28..1017e52b787 100644 --- a/contentbank/tests/contentbank_test.php +++ b/contentbank/tests/contentbank_test.php @@ -208,7 +208,7 @@ class contentbank_test extends advanced_testcase { * @param array $contexts List of contexts where to create content. */ public function test_search_contents(?string $search, string $where, int $expectedresult, array $contexts = [], - array $contenttypes = null): void { + ?array $contenttypes = null): void { global $DB, $CFG; $this->resetAfterTest(); diff --git a/course/classes/external/get_enrolled_courses_with_action_events_by_timeline_classification.php b/course/classes/external/get_enrolled_courses_with_action_events_by_timeline_classification.php index 7723f878c38..5c8196388b2 100644 --- a/course/classes/external/get_enrolled_courses_with_action_events_by_timeline_classification.php +++ b/course/classes/external/get_enrolled_courses_with_action_events_by_timeline_classification.php @@ -85,12 +85,12 @@ class get_enrolled_courses_with_action_events_by_timeline_classification extends string $classification, int $limit = 0, int $offset = 0, - string $sort = null, - string $customfieldname = null, - string $customfieldvalue = null, - string $searchvalue = null, - int $eventsfrom = null, - int $eventsto = null + ?string $sort = null, + ?string $customfieldname = null, + ?string $customfieldvalue = null, + ?string $searchvalue = null, + ?int $eventsfrom = null, + ?int $eventsto = null ): array { global $USER; diff --git a/course/classes/external/helper_for_get_mods_by_courses.php b/course/classes/external/helper_for_get_mods_by_courses.php index f874afad0c7..22b250d27fe 100644 --- a/course/classes/external/helper_for_get_mods_by_courses.php +++ b/course/classes/external/helper_for_get_mods_by_courses.php @@ -48,7 +48,7 @@ abstract class helper_for_get_mods_by_courses { * @return array with the containing all the values declared in {@see standard_coursemodule_elements_returns()}. */ public static function standard_coursemodule_element_values(\stdClass $modinstance, string $component, - string $capabilityforgroups = 'moodle/course:manageactivities', string $capabilityforintro = null): array { + string $capabilityforgroups = 'moodle/course:manageactivities', ?string $capabilityforintro = null): array { self::format_name_and_intro($modinstance, $component); $context = context_module::instance($modinstance->coursemodule); diff --git a/course/classes/management_renderer.php b/course/classes/management_renderer.php index 3d64a3a7eaf..c6e3370cee4 100644 --- a/course/classes/management_renderer.php +++ b/course/classes/management_renderer.php @@ -103,7 +103,7 @@ class core_course_management_renderer extends plugin_renderer_base { * @param core_course_category $category The currently selected category. Also the category to highlight in the listing. * @return string */ - public function category_listing(core_course_category $category = null) { + public function category_listing(?core_course_category $category = null) { if ($category === null) { $selectedparents = array(); @@ -309,7 +309,7 @@ class core_course_management_renderer extends plugin_renderer_base { * @param core_course_category $category * @return string */ - public function category_listing_actions(core_course_category $category = null) { + public function category_listing_actions(?core_course_category $category = null) { $actions = array(); $cancreatecategory = $category && $category->can_create_subcategory(); @@ -338,7 +338,7 @@ class core_course_management_renderer extends plugin_renderer_base { * @param array $actions * @return string */ - public function category_listitem_actions(core_course_category $category, array $actions = null) { + public function category_listitem_actions(core_course_category $category, ?array $actions = null) { if ($actions === null) { $actions = \core_course\management\helper::get_category_listitem_actions($category); } @@ -375,7 +375,7 @@ class core_course_management_renderer extends plugin_renderer_base { * @param core_course_category $category The currently selected category if there is one. * @return string */ - public function category_bulk_actions(core_course_category $category = null) { + public function category_bulk_actions(?core_course_category $category = null) { // Resort courses. // Change parent. if (!core_course_category::can_resort_any() && !core_course_category::can_change_parent_any()) { @@ -481,7 +481,7 @@ class core_course_management_renderer extends plugin_renderer_base { * @param string|null $viewmode The view mode the page is in, one out of 'default', 'combined', 'courses' or 'categories'. * @return string */ - public function course_listing(core_course_category $category = null, core_course_list_element $course = null, + public function course_listing(?core_course_category $category = null, ?core_course_list_element $course = null, $page = 0, $perpage = 20, $viewmode = 'default') { if ($category === null) { @@ -656,7 +656,7 @@ class core_course_management_renderer extends plugin_renderer_base { * @param int $perpage * @return string */ - public function course_listing_actions(core_course_category $category, core_course_list_element $course = null, $perpage = 20) { + public function course_listing_actions(core_course_category $category, ?core_course_list_element $course = null, $perpage = 20) { $actions = array(); if ($category->can_create_course()) { $url = new moodle_url('/course/edit.php', array('category' => $category->id, 'returnto' => 'catmanage')); @@ -984,8 +984,8 @@ class core_course_management_renderer extends plugin_renderer_base { * @param bool $linktext show title next to image in link * @return string HTML fragment */ - public function action_icon($url, pix_icon $pixicon, component_action $action = null, - array $attributes = null, $linktext = false) { + public function action_icon($url, pix_icon $pixicon, ?component_action $action = null, + ?array $attributes = null, $linktext = false) { if (!($url instanceof moodle_url)) { $url = new moodle_url($url); } @@ -1016,7 +1016,7 @@ class core_course_management_renderer extends plugin_renderer_base { * @param string $param The param name. * @return string */ - public function view_mode_selector(array $modes, $currentmode, moodle_url $url = null, $param = 'view') { + public function view_mode_selector(array $modes, $currentmode, ?moodle_url $url = null, $param = 'view') { if ($url === null) { $url = $this->page->url; } @@ -1064,7 +1064,7 @@ class core_course_management_renderer extends plugin_renderer_base { * @param string $search The string we are searching for. * @return string */ - public function search_listing(array $courses, $totalcourses, core_course_list_element $course = null, $page = 0, $perpage = 20, + public function search_listing(array $courses, $totalcourses, ?core_course_list_element $course = null, $page = 0, $perpage = 20, $search = '') { $page = max($page, 0); $perpage = max($perpage, 2); diff --git a/course/classes/search/course.php b/course/classes/search/course.php index 213904a020f..bf8891aea32 100644 --- a/course/classes/search/course.php +++ b/course/classes/search/course.php @@ -48,7 +48,7 @@ class course extends \core_search\base { * @param \context|null $context Restriction context * @return \moodle_recordset|null Recordset or null if no change possible */ - public function get_document_recordset($modifiedfrom = 0, \context $context = null) { + public function get_document_recordset($modifiedfrom = 0, ?\context $context = null) { global $DB; list ($contextjoin, $contextparams) = $this->get_course_level_context_restriction_sql( diff --git a/course/classes/search/customfield.php b/course/classes/search/customfield.php index dc74ae9790e..ad9a17e0dce 100644 --- a/course/classes/search/customfield.php +++ b/course/classes/search/customfield.php @@ -54,7 +54,7 @@ class customfield extends \core_search\base { * @param \context|null $context Restriction context * @return \moodle_recordset|null Recordset or null if no change possible */ - public function get_document_recordset($modifiedfrom = 0, \context $context = null) { + public function get_document_recordset($modifiedfrom = 0, ?\context $context = null) { global $DB; list ($contextjoin, $contextparams) = $this->get_course_level_context_restriction_sql($context, 'c', SQL_PARAMS_NAMED); diff --git a/course/classes/search/section.php b/course/classes/search/section.php index d5eaa4ff785..94c7b0f6590 100644 --- a/course/classes/search/section.php +++ b/course/classes/search/section.php @@ -51,7 +51,7 @@ class section extends \core_search\base { * @param \context|null $context Restriction context * @return \moodle_recordset|null Recordset or null if no change possible */ - public function get_document_recordset($modifiedfrom = 0, \context $context = null) { + public function get_document_recordset($modifiedfrom = 0, ?\context $context = null) { global $DB; list ($contextjoin, $contextparams) = $this->get_course_level_context_restriction_sql($context, 'c'); diff --git a/course/externallib.php b/course/externallib.php index 74f714cd789..d0e8512c59d 100644 --- a/course/externallib.php +++ b/course/externallib.php @@ -3926,10 +3926,10 @@ class core_course_external extends external_api { string $classification, int $limit = 0, int $offset = 0, - string $sort = null, - string $customfieldname = null, - string $customfieldvalue = null, - string $searchvalue = null, + ?string $sort = null, + ?string $customfieldname = null, + ?string $customfieldvalue = null, + ?string $searchvalue = null, array $requiredfields = [] ) { global $CFG, $PAGE, $USER; @@ -4231,7 +4231,7 @@ class core_course_external extends external_api { * @return array List of courses * @throws invalid_parameter_exception */ - public static function get_recent_courses(int $userid = 0, int $limit = 0, int $offset = 0, string $sort = null) { + public static function get_recent_courses(int $userid = 0, int $limit = 0, int $offset = 0, ?string $sort = null) { global $USER, $PAGE; if (empty($userid)) { diff --git a/course/format/classes/base.php b/course/format/classes/base.php index e6e90134966..52962b4f48e 100644 --- a/course/format/classes/base.php +++ b/course/format/classes/base.php @@ -1267,7 +1267,7 @@ abstract class base { * @param int|null $sectionid null if it is course format option * @return array array of options that have valid values */ - protected function validate_format_options(array $rawdata, int $sectionid = null): array { + protected function validate_format_options(array $rawdata, ?int $sectionid = null): array { if (!$sectionid) { $allformatoptions = $this->course_format_options(true); } else { diff --git a/course/lib.php b/course/lib.php index 8c9fd69c266..390cb019db9 100644 --- a/course/lib.php +++ b/course/lib.php @@ -1629,7 +1629,7 @@ function course_format_name ($course,$max=100) { * @param \stdClass $user the user to check, defaults to the global user if not provided. * @return bool whether the current user is allowed to add this type of module to this course. */ -function course_allowed_module($course, $modname, \stdClass $user = null) { +function course_allowed_module($course, $modname, ?\stdClass $user = null) { global $USER; $user = $user ?? $USER; if (is_numeric($modname)) { @@ -2222,7 +2222,7 @@ function update_course($data, $editoroptions = NULL) { * @param int $lastloginsince If specified, count only users who logged in after this timestamp. * @return float */ -function average_number_of_participants(bool $onlyactive = false, int $lastloginsince = null): float { +function average_number_of_participants(bool $onlyactive = false, ?int $lastloginsince = null): float { global $DB; $params = []; @@ -3091,7 +3091,7 @@ function mod_duplicate_activity($course, $cm, $sr = null) { * * @return cm_info|null cminfo object if we sucessfully duplicated the mod and found the new cm. */ -function duplicate_module($course, $cm, int $sectionid = null, bool $changename = true): ?cm_info { +function duplicate_module($course, $cm, ?int $sectionid = null, bool $changename = true): ?cm_info { global $CFG, $DB, $USER; require_once($CFG->dirroot . '/backup/util/includes/backup_includes.php'); require_once($CFG->dirroot . '/backup/util/includes/restore_includes.php'); @@ -4002,8 +4002,8 @@ function course_classify_courses_for_timeline(array $courses) { function course_get_enrolled_courses_for_logged_in_user( int $limit = 0, int $offset = 0, - string $sort = null, - string $fields = null, + ?string $sort = null, + ?string $fields = null, int $dbquerylimit = COURSE_DB_QUERY_LIMIT, array $includecourses = [], array $hiddencourses = [] @@ -4048,8 +4048,8 @@ function course_get_enrolled_courses_for_logged_in_user( function course_get_enrolled_courses_for_logged_in_user_from_search( int $limit = 0, int $offset = 0, - string $sort = null, - string $fields = null, + ?string $sort = null, + ?string $fields = null, int $dbquerylimit = COURSE_DB_QUERY_LIMIT, array $searchcriteria = [], array $options = [] @@ -4437,7 +4437,7 @@ function course_require_view_participants($context) { * @param stdClass $user the user object. If not provided, the current user will be checked. * @return bool true if the user is allowed to download in the context, false otherwise. */ -function can_download_from_backup_filearea($filearea, \context $context, stdClass $user = null) { +function can_download_from_backup_filearea($filearea, \context $context, ?stdClass $user = null) { $candownload = false; switch ($filearea) { case 'course': @@ -4493,7 +4493,7 @@ function get_hidden_courses_on_timeline($user = null) { * @param string|null $sort SQL string for sorting * @return array */ -function course_get_recent_courses(int $userid = null, int $limit = 0, int $offset = 0, string $sort = null) { +function course_get_recent_courses(?int $userid = null, int $limit = 0, int $offset = 0, ?string $sort = null) { global $CFG, $USER, $DB; diff --git a/course/renderer.php b/course/renderer.php index 8de46e710e2..c2408cbaf69 100644 --- a/course/renderer.php +++ b/course/renderer.php @@ -197,7 +197,7 @@ class core_course_renderer extends plugin_renderer_base { /** * @deprecated since 4.0 - please do not use this function any more. */ - public function course_section_cm_edit_actions($actions, cm_info $mod = null, $displayoptions = array()) { + public function course_section_cm_edit_actions($actions, ?cm_info $mod = null, $displayoptions = array()) { throw new coding_exception( 'course_section_cm_edit_actions can not be used any more. Please, use ' . diff --git a/customfield/classes/category_controller.php b/customfield/classes/category_controller.php index ee2e3fc6a62..9ead53a2699 100644 --- a/customfield/classes/category_controller.php +++ b/customfield/classes/category_controller.php @@ -59,7 +59,7 @@ class category_controller { * @param int $id * @param \stdClass|null $record */ - protected function __construct(int $id = 0, \stdClass $record = null) { + protected function __construct(int $id = 0, ?\stdClass $record = null) { $this->category = new category($id, $record); } @@ -77,7 +77,7 @@ class category_controller { * @throws \moodle_exception * @throws \coding_exception */ - public static function create(int $id, \stdClass $record = null, handler $handler = null): category_controller { + public static function create(int $id, ?\stdClass $record = null, ?handler $handler = null): category_controller { global $DB; if ($id && $record) { // This warning really should be in persistent as well. diff --git a/customfield/classes/data_controller.php b/customfield/classes/data_controller.php index 77f00594570..905aaec96d9 100644 --- a/customfield/classes/data_controller.php +++ b/customfield/classes/data_controller.php @@ -83,7 +83,7 @@ abstract class data_controller { * @throws \coding_exception * @throws \moodle_exception */ - public static function create(int $id, \stdClass $record = null, field_controller $field = null): data_controller { + public static function create(int $id, ?\stdClass $record = null, ?field_controller $field = null): data_controller { global $DB; if ($id && $record) { // This warning really should be in persistent as well. diff --git a/customfield/classes/field_controller.php b/customfield/classes/field_controller.php index 5dc580e8985..b790dc90397 100644 --- a/customfield/classes/field_controller.php +++ b/customfield/classes/field_controller.php @@ -61,7 +61,7 @@ abstract class field_controller { * @param int $id * @param \stdClass|null $record */ - public function __construct(int $id = 0, \stdClass $record = null) { + public function __construct(int $id = 0, ?\stdClass $record = null) { $this->field = new field($id, $record); } @@ -81,7 +81,7 @@ abstract class field_controller { * @throws \coding_exception * @throws \moodle_exception */ - public static function create(int $id, \stdClass $record = null, category_controller $category = null): field_controller { + public static function create(int $id, ?\stdClass $record = null, ?category_controller $category = null): field_controller { global $DB; if ($id && $record) { // This warning really should be in persistent as well. diff --git a/customfield/classes/handler.php b/customfield/classes/handler.php index 022f44ca7f4..9a829e8bcb4 100644 --- a/customfield/classes/handler.php +++ b/customfield/classes/handler.php @@ -199,7 +199,7 @@ abstract class handler { * @param string $name name of the category, null to generate automatically * @return int id of the new category */ - public function create_category(string $name = null): int { + public function create_category(?string $name = null): int { global $DB; $params = ['component' => $this->get_component(), 'area' => $this->get_area(), 'itemid' => $this->get_itemid()]; diff --git a/customfield/classes/privacy/provider.php b/customfield/classes/privacy/provider.php index 979912829c9..95187475c83 100644 --- a/customfield/classes/privacy/provider.php +++ b/customfield/classes/privacy/provider.php @@ -163,7 +163,7 @@ class provider implements */ public static function export_customfields_data(approved_contextlist $contextlist, string $component, string $area, string $itemidstest = 'IS NOT NULL', string $instanceidstest = 'IS NOT NULL', array $params = [], - array $subcontext = null) { + ?array $subcontext = null) { global $DB; // This query is very similar to api::get_instances_fields_data() but also works for multiple itemids diff --git a/customfield/field/textarea/classes/field_controller.php b/customfield/field/textarea/classes/field_controller.php index a3955bd2719..2171d9d246d 100644 --- a/customfield/field/textarea/classes/field_controller.php +++ b/customfield/field/textarea/classes/field_controller.php @@ -107,7 +107,7 @@ class field_controller extends \core_customfield\field_controller { * @param \context|null $context context if known, otherwise configuration context will be used * @return array */ - public function value_editor_options(\context $context = null) { + public function value_editor_options(?\context $context = null) { global $CFG; require_once($CFG->libdir.'/formslib.php'); diff --git a/enrol/cohort/lib.php b/enrol/cohort/lib.php index eba1675ea64..00bd0fc91ba 100644 --- a/enrol/cohort/lib.php +++ b/enrol/cohort/lib.php @@ -108,7 +108,7 @@ class enrol_cohort_plugin extends enrol_plugin { * @param array $fields instance fields * @return int id of new instance, null if can not be created */ - public function add_instance($course, array $fields = null) { + public function add_instance($course, ?array $fields = null) { global $CFG; // Allows multiple cohorts to be set on creation. diff --git a/enrol/fee/classes/plugin.php b/enrol/fee/classes/plugin.php index bd37fd55528..97e3ef6b840 100644 --- a/enrol/fee/classes/plugin.php +++ b/enrol/fee/classes/plugin.php @@ -136,7 +136,7 @@ class enrol_fee_plugin extends enrol_plugin { * @param array $fields instance fields * @return int id of new instance, null if can not be created */ - public function add_instance($course, array $fields = null) { + public function add_instance($course, ?array $fields = null) { if ($fields && !empty($fields['cost'])) { $fields['cost'] = unformat_float($fields['cost']); } diff --git a/enrol/guest/lib.php b/enrol/guest/lib.php index e06e6a6f3d1..d6e630d5acb 100644 --- a/enrol/guest/lib.php +++ b/enrol/guest/lib.php @@ -261,7 +261,7 @@ class enrol_guest_plugin extends enrol_plugin { * @param array instance fields * @return int id of new instance, null if can not be created */ - public function add_instance($course, array $fields = NULL) { + public function add_instance($course, ?array $fields = NULL) { $fields = (array)$fields; if (!isset($fields['password'])) { diff --git a/enrol/ldap/lib.php b/enrol/ldap/lib.php index 947af72c6e8..e39a64111cb 100644 --- a/enrol/ldap/lib.php +++ b/enrol/ldap/lib.php @@ -662,7 +662,7 @@ class enrol_ldap_plugin extends enrol_plugin { * @param progress_trace $trace * @return bool success */ - protected function ldap_connect(progress_trace $trace = null) { + protected function ldap_connect(?progress_trace $trace = null) { global $CFG; require_once($CFG->libdir.'/ldaplib.php'); diff --git a/enrol/locallib.php b/enrol/locallib.php index 5bcd05b30fe..d2b57e5bc06 100644 --- a/enrol/locallib.php +++ b/enrol/locallib.php @@ -1436,7 +1436,7 @@ class enrol_user_button extends single_button { * @param string $galleryversion Deprecated: The gallery version to use * @param bool $ondomready If true the call is postponed until the DOM is finished loading */ - public function require_yui_module($modules, $function, array $arguments = null, $galleryversion = null, $ondomready = false) { + public function require_yui_module($modules, $function, ?array $arguments = null, $galleryversion = null, $ondomready = false) { if ($galleryversion != null) { debugging('The galleryversion parameter to yui_module has been deprecated since Moodle 2.3.', DEBUG_DEVELOPER); } @@ -1457,7 +1457,7 @@ class enrol_user_button extends single_button { * @param bool $ondomready If true the call is postponed until the DOM is finished loading * @param array $module A module definition */ - public function require_js_init_call($function, array $extraarguments = null, $ondomready = false, array $module = null) { + public function require_js_init_call($function, ?array $extraarguments = null, $ondomready = false, ?array $module = null) { $js = new stdClass; $js->function = $function; $js->extraarguments = $extraarguments; @@ -1541,7 +1541,7 @@ class user_enrolment_action implements renderable { * @param moodle_url $url * @param array $attributes */ - public function __construct(pix_icon $icon, $title, $url, array $attributes = null) { + public function __construct(pix_icon $icon, $title, $url, ?array $attributes = null) { $this->icon = $icon; $this->title = $title; $this->url = new moodle_url($url); @@ -1623,7 +1623,7 @@ abstract class enrol_bulk_enrolment_operation { * @param course_enrolment_manager $manager * @param stdClass $plugin */ - public function __construct(course_enrolment_manager $manager, enrol_plugin $plugin = null) { + public function __construct(course_enrolment_manager $manager, ?enrol_plugin $plugin = null) { $this->manager = $manager; $this->plugin = $plugin; } diff --git a/enrol/lti/classes/local/ltiadvantage/entity/application_registration.php b/enrol/lti/classes/local/ltiadvantage/entity/application_registration.php index 735f0e245a1..f40a6cf2236 100644 --- a/enrol/lti/classes/local/ltiadvantage/entity/application_registration.php +++ b/enrol/lti/classes/local/ltiadvantage/entity/application_registration.php @@ -75,7 +75,7 @@ class application_registration { * @param int|null $id the id of the object instance, if being created from an existing store item. */ private function __construct(string $name, string $uniqueid, ?\moodle_url $platformid, ?string $clientid, - ?\moodle_url $authenticationrequesturl, ?\moodle_url $jwksurl, ?\moodle_url $accesstokenurl, int $id = null) { + ?\moodle_url $authenticationrequesturl, ?\moodle_url $jwksurl, ?\moodle_url $accesstokenurl, ?int $id = null) { if (empty($name)) { throw new \coding_exception("Invalid 'name' arg. Cannot be an empty string."); @@ -115,7 +115,7 @@ class application_registration { */ public static function create(string $name, string $uniqueid, \moodle_url $platformid, string $clientid, \moodle_url $authenticationrequesturl, \moodle_url $jwksurl, \moodle_url $accesstokenurl, - int $id = null): application_registration { + ?int $id = null): application_registration { if (empty($clientid)) { throw new \coding_exception("Invalid 'clientid' arg. Cannot be an empty string."); @@ -132,7 +132,7 @@ class application_registration { * @param int|null $id the id of the object instance, if being created from an existing store item. * @return application_registration the application_registration instance. */ - public static function create_draft(string $name, string $uniqueid, int $id = null): application_registration { + public static function create_draft(string $name, string $uniqueid, ?int $id = null): application_registration { return new self($name, $uniqueid, null, null, null, null, null, $id); } diff --git a/enrol/lti/classes/local/ltiadvantage/entity/context.php b/enrol/lti/classes/local/ltiadvantage/entity/context.php index 3d35fffcf75..a10f08459a7 100644 --- a/enrol/lti/classes/local/ltiadvantage/entity/context.php +++ b/enrol/lti/classes/local/ltiadvantage/entity/context.php @@ -93,7 +93,7 @@ class context { * @param int|null $id local id of this object instance, nullable for new objects. * @return context the context instance. */ - public static function create(int $deploymentid, string $contextid, array $types, int $id = null): context { + public static function create(int $deploymentid, string $contextid, array $types, ?int $id = null): context { return new self($deploymentid, $contextid, $types, $id); } diff --git a/enrol/lti/classes/local/ltiadvantage/entity/deployment.php b/enrol/lti/classes/local/ltiadvantage/entity/deployment.php index ea4ad199b6b..69e7ae9be3a 100644 --- a/enrol/lti/classes/local/ltiadvantage/entity/deployment.php +++ b/enrol/lti/classes/local/ltiadvantage/entity/deployment.php @@ -155,7 +155,7 @@ class deployment { * @throws \coding_exception if the resource_link can't be created. */ public function add_resource_link(string $resourcelinkid, int $resourceid, - int $contextid = null): resource_link { + ?int $contextid = null): resource_link { if (!$this->get_id()) { throw new \coding_exception('Can\'t add resource_link to a deployment that hasn\'t first been saved'); diff --git a/enrol/lti/classes/local/ltiadvantage/entity/resource_link.php b/enrol/lti/classes/local/ltiadvantage/entity/resource_link.php index 9acd18e4265..32edff72949 100644 --- a/enrol/lti/classes/local/ltiadvantage/entity/resource_link.php +++ b/enrol/lti/classes/local/ltiadvantage/entity/resource_link.php @@ -59,7 +59,7 @@ class resource_link { * @throws \coding_exception if the instance is unable to be created. */ private function __construct(string $resourcelinkid, int $deploymentid, int $resourceid, ?int $contextid = null, - int $id = null) { + ?int $id = null) { if (empty($resourcelinkid)) { throw new \coding_exception('Error: resourcelinkid cannot be an empty string'); @@ -84,7 +84,7 @@ class resource_link { * @return resource_link the newly created instance. */ public static function create(string $resourcelinkid, int $deploymentid, int $resourceid, ?int $contextid = null, - int $id = null): resource_link { + ?int $id = null): resource_link { return new self($resourcelinkid, $deploymentid, $resourceid, $contextid, $id); } diff --git a/enrol/lti/classes/local/ltiadvantage/entity/user.php b/enrol/lti/classes/local/ltiadvantage/entity/user.php index 8b6ca6330ec..417e91a69c0 100644 --- a/enrol/lti/classes/local/ltiadvantage/entity/user.php +++ b/enrol/lti/classes/local/ltiadvantage/entity/user.php @@ -169,7 +169,7 @@ class user { public static function create(int $resourceid, int $userid, int $deploymentid, string $sourceid, string $lang, string $timezone, string $city = '', string $country = '', string $institution = '', ?int $maildisplay = null, ?float $lastgrade = null, - ?int $lastaccess = null, ?int $resourcelinkid = null, int $id = null): user { + ?int $lastaccess = null, ?int $resourcelinkid = null, ?int $id = null): user { return new self($resourceid, $userid, $deploymentid, $sourceid, $lang, $city, $country, $institution, $timezone, $maildisplay, $lastgrade, $lastaccess, $resourcelinkid, $id); diff --git a/enrol/lti/classes/task/sync_members.php b/enrol/lti/classes/task/sync_members.php index 0a27175bfc5..5aa77ed72b6 100644 --- a/enrol/lti/classes/task/sync_members.php +++ b/enrol/lti/classes/task/sync_members.php @@ -363,7 +363,7 @@ class sync_members extends scheduled_task { * @param string $membershipsurltemplate The memberships endpoint URL template. * @return bool|User[] Array of User objects upon successful membership service request. False, otherwise. */ - protected function do_context_membership_request(Context $context, ResourceLink $resourcelink = null, + protected function do_context_membership_request(Context $context, ?ResourceLink $resourcelink = null, $membershipsurltemplate = '') { $dataconnector = $this->dataconnector; diff --git a/enrol/lti/lib.php b/enrol/lti/lib.php index f01522cb9e1..6bcacb3016f 100644 --- a/enrol/lti/lib.php +++ b/enrol/lti/lib.php @@ -96,7 +96,7 @@ class enrol_lti_plugin extends enrol_plugin { * @param array $fields instance fields * @return int id of new instance, null if can not be created */ - public function add_instance($course, array $fields = null) { + public function add_instance($course, ?array $fields = null) { global $DB; $instanceid = parent::add_instance($course, $fields); diff --git a/enrol/lti/tests/local/ltiadvantage/repository/application_registration_repository_test.php b/enrol/lti/tests/local/ltiadvantage/repository/application_registration_repository_test.php index c04fc2aaa21..1db47aa23aa 100644 --- a/enrol/lti/tests/local/ltiadvantage/repository/application_registration_repository_test.php +++ b/enrol/lti/tests/local/ltiadvantage/repository/application_registration_repository_test.php @@ -35,8 +35,8 @@ class application_registration_repository_test extends \advanced_testcase { * @param string|null $clientid the clientid of the platform's tool registration, or null to use a default. * @return application_registration the application_registration instance. */ - protected function generate_application_registration(string $issuer = null, string $uniqueid = null, - string $clientid = null): application_registration { + protected function generate_application_registration(?string $issuer = null, ?string $uniqueid = null, + ?string $clientid = null): application_registration { $issuer = $issuer ?? 'https://lms.example.org'; $uniqueid = $uniqueid ?? 'a2c94a2c94'; diff --git a/enrol/lti/tests/local/ltiadvantage/repository/deployment_repository_test.php b/enrol/lti/tests/local/ltiadvantage/repository/deployment_repository_test.php index ee19b9f8f4a..9954d6c8f1d 100644 --- a/enrol/lti/tests/local/ltiadvantage/repository/deployment_repository_test.php +++ b/enrol/lti/tests/local/ltiadvantage/repository/deployment_repository_test.php @@ -35,7 +35,7 @@ class deployment_repository_test extends \advanced_testcase { * @return deployment the deployment. */ protected function create_test_deployment(string $deploymentid = 'DeployID123', - int $appregistrationid = null): deployment { + ?int $appregistrationid = null): deployment { if (is_null($appregistrationid)) { $registration = application_registration::create( diff --git a/enrol/lti/tests/sync_members_test.php b/enrol/lti/tests/sync_members_test.php index 446989d6bbc..45814ed6289 100644 --- a/enrol/lti/tests/sync_members_test.php +++ b/enrol/lti/tests/sync_members_test.php @@ -306,7 +306,7 @@ class dummy_sync_members_task extends sync_members { * @param string $membershipsurltemplate The memberships endpoint URL template. * @return bool|User[] Array of User objects upon successful membership service request. False, otherwise. */ - public function do_context_membership_request(Context $context, ResourceLink $resourcelink = null, + public function do_context_membership_request(Context $context, ?ResourceLink $resourcelink = null, $membershipsurltemplate = '') { $members = parent::do_context_membership_request($context, $resourcelink, $membershipsurltemplate); return $members; diff --git a/enrol/manual/lib.php b/enrol/manual/lib.php index 0ef478a228b..a85f4ce8c42 100644 --- a/enrol/manual/lib.php +++ b/enrol/manual/lib.php @@ -155,7 +155,7 @@ class enrol_manual_plugin extends enrol_plugin { * @param array instance fields * @return int id of new instance, null if can not be created */ - public function add_instance($course, array $fields = NULL) { + public function add_instance($course, ?array $fields = NULL) { global $DB; if ($DB->record_exists('enrol', array('courseid'=>$course->id, 'enrol'=>'manual'))) { diff --git a/enrol/meta/lib.php b/enrol/meta/lib.php index 6c57bcc7c70..1bc08ca49df 100644 --- a/enrol/meta/lib.php +++ b/enrol/meta/lib.php @@ -114,7 +114,7 @@ class enrol_meta_plugin extends enrol_plugin { * @param array $fields instance fields * @return int id of last instance, null if can not be created */ - public function add_instance($course, array $fields = null) { + public function add_instance($course, ?array $fields = null) { global $CFG; require_once("$CFG->dirroot/enrol/meta/locallib.php"); diff --git a/enrol/paypal/lib.php b/enrol/paypal/lib.php index 64e2cb946d6..254b0836e73 100644 --- a/enrol/paypal/lib.php +++ b/enrol/paypal/lib.php @@ -127,7 +127,7 @@ class enrol_paypal_plugin extends enrol_plugin { * @param array $fields instance fields * @return int id of new instance, null if can not be created */ - public function add_instance($course, array $fields = null) { + public function add_instance($course, ?array $fields = null) { if ($fields && !empty($fields['cost'])) { $fields['cost'] = unformat_float($fields['cost']); } diff --git a/enrol/self/lib.php b/enrol/self/lib.php index 3c987aec9a2..60e2b8f13b1 100644 --- a/enrol/self/lib.php +++ b/enrol/self/lib.php @@ -1123,7 +1123,7 @@ class enrol_self_plugin extends enrol_plugin { * @param array $fields instance fields * @return int id of new instance, null if can not be created */ - public function add_instance($course, array $fields = null) { + public function add_instance($course, ?array $fields = null) { // In the form we are representing 2 db columns with one field. if (!empty($fields) && !empty($fields['expirynotify'])) { if ($fields['expirynotify'] == 2) { diff --git a/favourites/classes/local/service/component_favourite_service.php b/favourites/classes/local/service/component_favourite_service.php index 5105b34b240..ad5169a03f7 100644 --- a/favourites/classes/local/service/component_favourite_service.php +++ b/favourites/classes/local/service/component_favourite_service.php @@ -69,7 +69,7 @@ class component_favourite_service { * @param int $itemid the id of the item to which the favourites relate * @param \context $context the context of the items which were favourited. */ - public function delete_favourites_by_type_and_item(string $itemtype, int $itemid, \context $context = null) { + public function delete_favourites_by_type_and_item(string $itemtype, int $itemid, ?\context $context = null) { $criteria = ['component' => $this->component, 'itemtype' => $itemtype, 'itemid' => $itemid] + ($context ? ['contextid' => $context->id] : []); $this->repo->delete_by($criteria); diff --git a/favourites/classes/local/service/user_favourite_service.php b/favourites/classes/local/service/user_favourite_service.php index ee8a51fbd58..95db26b85b6 100644 --- a/favourites/classes/local/service/user_favourite_service.php +++ b/favourites/classes/local/service/user_favourite_service.php @@ -69,7 +69,7 @@ class user_favourite_service { * @throws \moodle_exception if the component name is invalid, or if the repository encounters any errors. */ public function create_favourite(string $component, string $itemtype, int $itemid, \context $context, - int $ordering = null): favourite { + ?int $ordering = null): favourite { // Access: Any component can ask to favourite something, we can't verify access to that 'something' here though. // Validate the component name. @@ -265,7 +265,7 @@ class user_favourite_service { * @param \context|null $context the context of the item which was favourited. * @return int */ - public function count_favourites_by_type(string $component, string $itemtype, \context $context = null) { + public function count_favourites_by_type(string $component, string $itemtype, ?\context $context = null) { $criteria = [ 'userid' => $this->userid, 'component' => $component, diff --git a/favourites/classes/privacy/provider.php b/favourites/classes/privacy/provider.php index c3724c5fb6d..3bd6e82286c 100644 --- a/favourites/classes/privacy/provider.php +++ b/favourites/classes/privacy/provider.php @@ -85,7 +85,7 @@ class provider implements * @param string $itemtype the type of the favourited items. */ public static function add_contexts_for_userid(\core_privacy\local\request\contextlist $contextlist, int $userid, - string $component, string $itemtype = null) { + string $component, ?string $itemtype = null) { $sql = "SELECT contextid FROM {favourite} f WHERE userid = :userid @@ -109,7 +109,7 @@ class provider implements * @return void */ public static function add_userids_for_context(\core_privacy\local\request\userlist $userlist, - string $itemtype = null) { + ?string $itemtype = null) { if (empty($userlist)) { return; } diff --git a/files/renderer.php b/files/renderer.php index 48c6bbef315..f4b1f06f9a0 100644 --- a/files/renderer.php +++ b/files/renderer.php @@ -39,7 +39,7 @@ defined('MOODLE_INTERNAL') || die(); */ class core_files_renderer extends plugin_renderer_base { - public function files_tree_viewer(file_info $file_info, array $options = null) { + public function files_tree_viewer(file_info $file_info, ?array $options = null) { $tree = new files_tree_viewer($file_info, $options); return $this->render($tree); } @@ -576,7 +576,7 @@ class files_tree_viewer implements renderable { * @param file_info $file_info * @param array $options */ - public function __construct(file_info $file_info, array $options = null) { + public function __construct(file_info $file_info, ?array $options = null) { global $CFG; //note: this MUST NOT use get_file_storage() !!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/grade/classes/component_gradeitem.php b/grade/classes/component_gradeitem.php index 8aea26bf02a..4e67600bb42 100644 --- a/grade/classes/component_gradeitem.php +++ b/grade/classes/component_gradeitem.php @@ -527,7 +527,7 @@ abstract class component_gradeitem { * @param int $instanceid The instanceid of the advanced grading form * @return gradingform_instance */ - public function get_advanced_grading_instance(stdClass $grader, stdClass $grade, int $instanceid = null): ?gradingform_instance { + public function get_advanced_grading_instance(stdClass $grader, stdClass $grade, ?int $instanceid = null): ?gradingform_instance { $controller = $this->get_advanced_grading_controller($this->itemname); if (empty($controller)) { diff --git a/grade/classes/privacy/grade_grade_with_history.php b/grade/classes/privacy/grade_grade_with_history.php index 3cdb33579eb..2c1f4e6f45a 100644 --- a/grade/classes/privacy/grade_grade_with_history.php +++ b/grade/classes/privacy/grade_grade_with_history.php @@ -30,7 +30,7 @@ use grade_grade; class grade_grade_with_history extends grade_grade { public int $historyid; - public function __construct(\stdClass $params = null, $fetch = true) { + public function __construct(?\stdClass $params = null, $fetch = true) { // The grade history is not a real grade_grade so we remove the ID. $this->historyid = $params->id; unset($params->id); diff --git a/grade/classes/privacy/provider.php b/grade/classes/privacy/provider.php index 1060d24163d..856186f2177 100644 --- a/grade/classes/privacy/provider.php +++ b/grade/classes/privacy/provider.php @@ -1281,7 +1281,7 @@ class provider implements * @throws \coding_exception * @throws \dml_exception */ - protected static function delete_files(array $itemids, bool $ishistory, array $userids = null) { + protected static function delete_files(array $itemids, bool $ishistory, ?array $userids = null) { global $DB; list($iteminnsql, $params) = $DB->get_in_or_equal($itemids, SQL_PARAMS_NAMED); diff --git a/grade/grading/classes/privacy/provider.php b/grade/grading/classes/privacy/provider.php index d3194cf0d15..b4409e2f78d 100644 --- a/grade/grading/classes/privacy/provider.php +++ b/grade/grading/classes/privacy/provider.php @@ -200,7 +200,7 @@ class provider implements * @param \context $context The context to delete on. * @param int|null $itemid An optional item ID to refine the deletion. */ - public static function delete_instance_data(\context $context, int $itemid = null) { + public static function delete_instance_data(\context $context, ?int $itemid = null) { if (is_null($itemid)) { self::delete_data_for_instances($context); } else { diff --git a/grade/grading/form/guide/lib.php b/grade/grading/form/guide/lib.php index b0a005231c4..4acaf09ba92 100644 --- a/grade/grading/form/guide/lib.php +++ b/grade/grading/form/guide/lib.php @@ -73,7 +73,7 @@ class gradingform_guide_controller extends gradingform_controller { * @param settings_navigation $settingsnav {@link settings_navigation} * @param navigation_node $node {@link navigation_node} */ - public function extend_settings_navigation(settings_navigation $settingsnav, navigation_node $node=null) { + public function extend_settings_navigation(settings_navigation $settingsnav, ?navigation_node $node=null) { $node->add(get_string('definemarkingguide', 'gradingform_guide'), $this->get_editor_url(), settings_navigation::TYPE_CUSTOM, null, null, new pix_icon('icon', '', 'gradingform_guide')); @@ -89,7 +89,7 @@ class gradingform_guide_controller extends gradingform_controller { * @param navigation_node $node {@link navigation_node} * @return void */ - public function extend_navigation(global_navigation $navigation, navigation_node $node=null) { + public function extend_navigation(global_navigation $navigation, ?navigation_node $node=null) { if (has_capability('moodle/grade:managegradingforms', $this->get_context())) { // No need for preview if user can manage forms, he will have link to manage.php in settings instead. return; diff --git a/grade/grading/form/lib.php b/grade/grading/form/lib.php index 190fc9062c1..7978801d5d4 100644 --- a/grade/grading/form/lib.php +++ b/grade/grading/form/lib.php @@ -205,7 +205,7 @@ abstract class gradingform_controller { * @param moodle_url $returnurl optional URL of a page where the user should be sent once they are finished with editing * @return moodle_url */ - public function get_editor_url(moodle_url $returnurl = null) { + public function get_editor_url(?moodle_url $returnurl = null) { $params = array('areaid' => $this->areaid); @@ -226,7 +226,7 @@ abstract class gradingform_controller { * @param settings_navigation $settingsnav {@link settings_navigation} * @param navigation_node $node {@link navigation_node} */ - public function extend_settings_navigation(settings_navigation $settingsnav, navigation_node $node=null) { + public function extend_settings_navigation(settings_navigation $settingsnav, ?navigation_node $node=null) { // do not extend by default } @@ -239,7 +239,7 @@ abstract class gradingform_controller { * @param global_navigation $navigation {@link global_navigation} * @param navigation_node $node {@link navigation_node} */ - public function extend_navigation(global_navigation $navigation, navigation_node $node=null) { + public function extend_navigation(global_navigation $navigation, ?navigation_node $node=null) { // do not extend by default } diff --git a/grade/grading/form/rubric/lib.php b/grade/grading/form/rubric/lib.php index 58336994180..b34fac44675 100644 --- a/grade/grading/form/rubric/lib.php +++ b/grade/grading/form/rubric/lib.php @@ -71,7 +71,7 @@ class gradingform_rubric_controller extends gradingform_controller { * @param settings_navigation $settingsnav {@link settings_navigation} * @param navigation_node $node {@link navigation_node} */ - public function extend_settings_navigation(settings_navigation $settingsnav, navigation_node $node=null) { + public function extend_settings_navigation(settings_navigation $settingsnav, ?navigation_node $node=null) { $node->add(get_string('definerubric', 'gradingform_rubric'), $this->get_editor_url(), settings_navigation::TYPE_CUSTOM, null, null, new pix_icon('icon', '', 'gradingform_rubric')); @@ -86,7 +86,7 @@ class gradingform_rubric_controller extends gradingform_controller { * @param global_navigation $navigation {@link global_navigation} * @param navigation_node $node {@link navigation_node} */ - public function extend_navigation(global_navigation $navigation, navigation_node $node=null) { + public function extend_navigation(global_navigation $navigation, ?navigation_node $node=null) { if (has_capability('moodle/grade:managegradingforms', $this->get_context())) { // no need for preview if user can manage forms, he will have link to manage.php in settings instead return; diff --git a/grade/grading/lib.php b/grade/grading/lib.php index beeade0fcf6..743020d6094 100644 --- a/grade/grading/lib.php +++ b/grade/grading/lib.php @@ -443,7 +443,7 @@ class grading_manager { * @param settings_navigation $settingsnav {@link settings_navigation} * @param navigation_node $modulenode {@link navigation_node} */ - public function extend_settings_navigation(settings_navigation $settingsnav, navigation_node $modulenode=null) { + public function extend_settings_navigation(settings_navigation $settingsnav, ?navigation_node $modulenode=null) { $this->ensure_isset(array('context', 'component')); @@ -472,7 +472,7 @@ class grading_manager { * @param global_navigation $navigation * @param navigation_node $modulenode */ - public function extend_navigation(global_navigation $navigation, navigation_node $modulenode=null) { + public function extend_navigation(global_navigation $navigation, ?navigation_node $modulenode=null) { $this->ensure_isset(array('context', 'component')); $areas = $this->get_available_areas(); @@ -551,7 +551,7 @@ class grading_manager { * @param moodle_url $returnurl optional URL of the page where the user should be sent back to * @return moodle_url */ - public function get_management_url(moodle_url $returnurl = null) { + public function get_management_url(?moodle_url $returnurl = null) { $this->ensure_isset(array('context', 'component')); diff --git a/grade/report/history/classes/helper.php b/grade/report/history/classes/helper.php index c4d8b1ba8e6..0e736869fa7 100644 --- a/grade/report/history/classes/helper.php +++ b/grade/report/history/classes/helper.php @@ -44,7 +44,7 @@ class helper { * * @return output\user_button the user select button. */ - public static function init_js($courseid, array $currentusers = null) { + public static function init_js($courseid, ?array $currentusers = null) { global $PAGE; // Load the strings for js. diff --git a/grade/report/singleview/classes/local/screen/screen.php b/grade/report/singleview/classes/local/screen/screen.php index 2958d9660e7..c7895c23d47 100644 --- a/grade/report/singleview/classes/local/screen/screen.php +++ b/grade/report/singleview/classes/local/screen/screen.php @@ -163,7 +163,7 @@ abstract class screen { * @param bool|null $display Should we wrap this in an anchor ? * @return string The link */ - public function format_link(string $screen, int $itemid, bool $display = null): string { + public function format_link(string $screen, int $itemid, ?bool $display = null): string { $url = new moodle_url('/grade/report/singleview/index.php', [ 'id' => $this->courseid, 'item' => $screen, diff --git a/grade/report/user/classes/report/user.php b/grade/report/user/classes/report/user.php index 3b45568efe8..b3185ba41f3 100644 --- a/grade/report/user/classes/report/user.php +++ b/grade/report/user/classes/report/user.php @@ -224,7 +224,7 @@ class user extends grade_report { * @param int $userid The id of the user * @param bool $viewasuser Set this to true when the current user is a mentor/parent of the targetted user. */ - public function __construct(int $courseid, ?object $gpr, object $context, int $userid, bool $viewasuser = null) { + public function __construct(int $courseid, ?object $gpr, object $context, int $userid, ?bool $viewasuser = null) { global $DB, $CFG; parent::__construct($courseid, $gpr, $context); diff --git a/grade/tests/component_gradeitem_test.php b/grade/tests/component_gradeitem_test.php index 9eb34f84279..13e57c89b82 100644 --- a/grade/tests/component_gradeitem_test.php +++ b/grade/tests/component_gradeitem_test.php @@ -218,7 +218,7 @@ class component_gradeitem_test extends advanced_testcase { * @param int|null $displaytype The display type of the grade. * @return \stdClass|null */ - protected function initialise_test_and_get_grade_item(int $gradeforum, int $gradegiven, int $displaytype = null): \stdClass { + protected function initialise_test_and_get_grade_item(int $gradeforum, int $gradegiven, ?int $displaytype = null): \stdClass { $this->resetAfterTest(); $forum = $this->get_forum_instance([ diff --git a/h5p/classes/framework.php b/h5p/classes/framework.php index 10e7c32d77d..c41e9a2d5c2 100644 --- a/h5p/classes/framework.php +++ b/h5p/classes/framework.php @@ -1757,7 +1757,7 @@ class framework implements H5PFrameworkInterface { * @param string $newmessage The message * @param string $code The message code */ - private function set_message(string $type, string $newmessage = null, string $code = null) { + private function set_message(string $type, ?string $newmessage = null, ?string $code = null) { global $SESSION; // We expect to get out an array of strings when getting info diff --git a/h5p/classes/helper.php b/h5p/classes/helper.php index 0dca112db73..56fc62280f4 100644 --- a/h5p/classes/helper.php +++ b/h5p/classes/helper.php @@ -163,7 +163,7 @@ class helper { * * @return int The representation of display options as int */ - public static function decode_display_options(core $core, int $displayint = null): \stdClass { + public static function decode_display_options(core $core, ?int $displayint = null): \stdClass { $config = new \stdClass(); if ($displayint === null) { $displayint = self::get_display_options($core, $config); @@ -232,7 +232,7 @@ class helper { * @return \stored_file The file created */ public static function create_fake_stored_file_from_path(string $filepath, int $userid = 0, - \context $context = null): \stored_file { + ?\context $context = null): \stored_file { if (is_null($context)) { $context = context_system::instance(); } @@ -476,7 +476,7 @@ class helper { * @param factory $factory The \core_h5p\factory object * @return array|null The information export file otherwise null. */ - public static function get_export_info(string $exportfilename, \moodle_url $url = null, ?factory $factory = null): ?array { + public static function get_export_info(string $exportfilename, ?\moodle_url $url = null, ?factory $factory = null): ?array { if (!$factory) { $factory = new factory(); diff --git a/h5p/tests/generator/lib.php b/h5p/tests/generator/lib.php index 79edfec2e12..9096f72583e 100644 --- a/h5p/tests/generator/lib.php +++ b/h5p/tests/generator/lib.php @@ -247,8 +247,8 @@ class core_h5p_generator extends \component_generator_base { * @return stdClass An object representing the added library record */ public function create_library_record(string $machinename, string $title, int $majorversion = 1, - int $minorversion = 0, int $patchversion = 1, string $semantics = '', string $addto = null, - string $tutorial = null, string $example = null, bool $enabled = true, int $runnable = 1): stdClass { + int $minorversion = 0, int $patchversion = 1, string $semantics = '', ?string $addto = null, + ?string $tutorial = null, ?string $example = null, bool $enabled = true, int $runnable = 1): stdClass { global $DB; $content = [ @@ -283,7 +283,7 @@ class core_h5p_generator extends \component_generator_base { * @param array|null $filerecord The file associated to the H5P entry. * @return int The ID of the added record */ - public function create_h5p_record(int $mainlibid, string $jsoncontent = null, string $filtered = null, + public function create_h5p_record(int $mainlibid, ?string $jsoncontent = null, ?string $filtered = null, ?array $filerecord = null): int { global $DB; diff --git a/lib/accesslib.php b/lib/accesslib.php index ccddb2905fc..09298458a49 100644 --- a/lib/accesslib.php +++ b/lib/accesslib.php @@ -2966,7 +2966,7 @@ function user_can_assign(context $context, $targetroleid) { * @param context $context optional context for course role name aliases * @return array of role records with optional coursealias property */ -function get_all_roles(context $context = null) { +function get_all_roles(?context $context = null) { global $DB; if (!$context or !$coursecontext = $context->get_course_context(false)) { @@ -4641,7 +4641,7 @@ function role_get_description(stdClass $role) { * @param bool $returnmenu true means id=>localname, false means id=>rolerecord * @return array Array of context-specific role names, or role objects with a ->localname field added. */ -function role_get_names(context $context = null, $rolenamedisplay = ROLENAME_ALIAS, $returnmenu = null) { +function role_get_names(?context $context = null, $rolenamedisplay = ROLENAME_ALIAS, $returnmenu = null) { return role_fix_names(get_all_roles($context), $context, $rolenamedisplay, $returnmenu); } @@ -4654,7 +4654,7 @@ function role_get_names(context $context = null, $rolenamedisplay = ROLENAME_ALI * @param bool $returnmenu null means keep the same format as $roleoptions, true means id=>localname, false means id=>rolerecord * @return array Array of context-specific role names, or role objects with a ->localname field added. */ -function role_fix_names($roleoptions, context $context = null, $rolenamedisplay = ROLENAME_ALIAS, $returnmenu = null) { +function role_fix_names($roleoptions, ?context $context = null, $rolenamedisplay = ROLENAME_ALIAS, $returnmenu = null) { global $DB; if (empty($roleoptions)) { diff --git a/lib/adminlib.php b/lib/adminlib.php index d51c3a3eab6..a6900caff2a 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -8718,7 +8718,7 @@ class admin_setting_managecontentbankcontenttypes extends admin_setting { * pagelayout - This option can be used to set a specific pagelyaout, admin is default. * nosearch - Do not display search bar */ -function admin_externalpage_setup($section, $extrabutton = '', array $extraurlparams = null, $actualurl = '', array $options = array()) { +function admin_externalpage_setup($section, $extrabutton = '', ?array $extraurlparams = null, $actualurl = '', array $options = array()) { global $CFG, $PAGE, $USER, $SITE, $OUTPUT; $PAGE->set_context(null); // hack - set context to something, by default to system context @@ -10451,7 +10451,7 @@ class admin_setting_configcolourpicker extends admin_setting { * @param string $defaultsetting * @param array $previewconfig Array('selector'=>'.some .css .selector','style'=>'backgroundColor'); */ - public function __construct($name, $visiblename, $description, $defaultsetting, array $previewconfig = null, + public function __construct($name, $visiblename, $description, $defaultsetting, ?array $previewconfig = null, $usedefaultwhenempty = true) { $this->previewconfig = $previewconfig; $this->usedefaultwhenempty = $usedefaultwhenempty; @@ -10618,7 +10618,7 @@ class admin_setting_configstoredfile extends admin_setting { * @param int $itemid itemid for file storage * @param array $options file area options */ - public function __construct($name, $visiblename, $description, $filearea, $itemid = 0, array $options = null) { + public function __construct($name, $visiblename, $description, $filearea, $itemid = 0, ?array $options = null) { parent::__construct($name, $visiblename, $description, ''); $this->filearea = $filearea; $this->itemid = $itemid; diff --git a/lib/behat/extension/Moodle/BehatExtension/Output/Formatter/MoodleProgressFormatterFactory.php b/lib/behat/extension/Moodle/BehatExtension/Output/Formatter/MoodleProgressFormatterFactory.php index 132bdc1a8a5..27decc7e3a3 100644 --- a/lib/behat/extension/Moodle/BehatExtension/Output/Formatter/MoodleProgressFormatterFactory.php +++ b/lib/behat/extension/Moodle/BehatExtension/Output/Formatter/MoodleProgressFormatterFactory.php @@ -52,7 +52,7 @@ class MoodleProgressFormatterFactory implements FormatterFactory { * * @param null|ServiceProcessor $processor */ - public function __construct(ServiceProcessor $processor = null) { + public function __construct(?ServiceProcessor $processor = null) { $this->processor = $processor ? : new ServiceProcessor(); } diff --git a/lib/behat/extension/Moodle/BehatExtension/ServiceContainer/BehatExtension.php b/lib/behat/extension/Moodle/BehatExtension/ServiceContainer/BehatExtension.php index c7cae1d81fe..29ec92ddb9b 100644 --- a/lib/behat/extension/Moodle/BehatExtension/ServiceContainer/BehatExtension.php +++ b/lib/behat/extension/Moodle/BehatExtension/ServiceContainer/BehatExtension.php @@ -58,7 +58,7 @@ class BehatExtension implements ExtensionInterface { * * @param null|ServiceProcessor $processor */ - public function __construct(ServiceProcessor $processor = null) { + public function __construct(?ServiceProcessor $processor = null) { $this->processor = $processor ? : new ServiceProcessor(); } diff --git a/lib/classes/check/external/get_result_admintree.php b/lib/classes/check/external/get_result_admintree.php index 01c6b1ad934..7da3e766b49 100644 --- a/lib/classes/check/external/get_result_admintree.php +++ b/lib/classes/check/external/get_result_admintree.php @@ -56,7 +56,7 @@ class get_result_admintree extends external_api { * @return array returned data */ public static function execute(string $admintreeid, string $settingname, bool $includedetails, - admin_root $admintree = null): array { + ?admin_root $admintree = null): array { global $OUTPUT, $CFG; // Validate parameters. @@ -105,7 +105,7 @@ class get_result_admintree extends external_api { * @param string $settingname Name of the admin_setting * @param admin_root|null $tree Admin tree to use (for unit testing). Null will default to the admin_get_root() */ - private static function get_check_from_setting(string $settingid, string $settingname, admin_root $tree = null) { + private static function get_check_from_setting(string $settingid, string $settingname, ?admin_root $tree = null) { // Since settings do not know exactly who their parents are in the tree, we must search for the setting. if (empty($tree)) { $tree = \admin_get_root(); diff --git a/lib/classes/content/export/zipwriter.php b/lib/classes/content/export/zipwriter.php index de3813fcaea..f5951f40dba 100644 --- a/lib/classes/content/export/zipwriter.php +++ b/lib/classes/content/export/zipwriter.php @@ -73,7 +73,7 @@ class zipwriter { * @param \ZipStream\ZipStream $archive * @param stdClass|null $options */ - public function __construct(\ZipStream\ZipStream $archive, stdClass $options = null) { + public function __construct(\ZipStream\ZipStream $archive, ?stdClass $options = null) { $this->archive = $archive; if ($options) { $this->parse_options($options); @@ -140,7 +140,7 @@ class zipwriter { * @param stdClass|null $exportoptions * @return static */ - public static function get_stream_writer(string $filename, stdClass $exportoptions = null) { + public static function get_stream_writer(string $filename, ?stdClass $exportoptions = null) { $archive = new \ZipStream\ZipStream( outputName: $filename, ); @@ -158,7 +158,7 @@ class zipwriter { * @param stdClass|null $exportoptions * @return static */ - public static function get_file_writer(string $filename, stdClass $exportoptions = null) { + public static function get_file_writer(string $filename, ?stdClass $exportoptions = null) { $dir = make_request_directory(); $filepath = $dir . "/$filename"; $fh = fopen($filepath, 'w'); diff --git a/lib/classes/dataformat.php b/lib/classes/dataformat.php index 99b92e70428..a86e39d5122 100644 --- a/lib/classes/dataformat.php +++ b/lib/classes/dataformat.php @@ -66,7 +66,7 @@ class dataformat { * @throws coding_exception */ public static function download_data(string $filename, string $dataformat, array $columns, Iterable $iterator, - callable $callback = null): void { + ?callable $callback = null): void { if (ob_get_length()) { throw new coding_exception('Output can not be buffered before calling download_data()'); @@ -115,7 +115,7 @@ class dataformat { * @return string Complete path to the file on disk */ public static function write_data(string $filename, string $dataformat, array $columns, Iterable $iterator, - callable $callback = null): string { + ?callable $callback = null): string { $format = self::get_format_instance($dataformat); @@ -159,7 +159,7 @@ class dataformat { * @return stored_file */ public static function write_data_to_filearea(array $filerecord, string $dataformat, array $columns, Iterable $iterator, - callable $callback = null): stored_file { + ?callable $callback = null): stored_file { $filepath = self::write_data($filerecord['filename'], $dataformat, $columns, $iterator, $callback); diff --git a/lib/classes/event/base.php b/lib/classes/event/base.php index 5304ee3f9bd..e212054214b 100644 --- a/lib/classes/event/base.php +++ b/lib/classes/event/base.php @@ -170,7 +170,7 @@ abstract class base implements \IteratorAggregate { * * @throws \coding_exception */ - final public static function create(array $data = null) { + final public static function create(?array $data = null) { global $USER, $CFG; $data = (array)$data; diff --git a/lib/classes/lock/timing_wrapper_lock_factory.php b/lib/classes/lock/timing_wrapper_lock_factory.php index 46f4cb18c7d..6315f59faae 100644 --- a/lib/classes/lock/timing_wrapper_lock_factory.php +++ b/lib/classes/lock/timing_wrapper_lock_factory.php @@ -43,7 +43,7 @@ class timing_wrapper_lock_factory implements lock_factory { * @param string $type Type (should be same as passed to real lock factory) * @param lock_factory $factory Real lock factory */ - public function __construct($type, lock_factory $factory = null) { + public function __construct($type, ?lock_factory $factory = null) { $this->type = $type; if (!$factory) { // This parameter has to be optional because of the interface, but it is actually diff --git a/lib/classes/message/inbound/processing_failed_exception.php b/lib/classes/message/inbound/processing_failed_exception.php index 1e9fbba8220..94db83824e9 100644 --- a/lib/classes/message/inbound/processing_failed_exception.php +++ b/lib/classes/message/inbound/processing_failed_exception.php @@ -40,7 +40,7 @@ class processing_failed_exception extends \moodle_exception { * @param string $component The string component * @param \stdClass $data The data to pass to get_string */ - public function __construct($identifier, $component, \stdClass $data = null) { + public function __construct($identifier, $component, ?\stdClass $data = null) { return parent::__construct($identifier, $component, '', $data); } } diff --git a/lib/classes/output/action_menu/subpanel.php b/lib/classes/output/action_menu/subpanel.php index 94257d2a097..85fe0cc050d 100644 --- a/lib/classes/output/action_menu/subpanel.php +++ b/lib/classes/output/action_menu/subpanel.php @@ -51,8 +51,8 @@ class subpanel extends action_link implements renderable { public function __construct( $text, renderable $subpanel, - array $attributes = null, - pix_icon $icon = null + ?array $attributes = null, + ?pix_icon $icon = null ) { $this->text = $text; $this->subpanel = $subpanel; diff --git a/lib/classes/output/chooser_item.php b/lib/classes/output/chooser_item.php index c90d6f115b8..1dcde0e364b 100644 --- a/lib/classes/output/chooser_item.php +++ b/lib/classes/output/chooser_item.php @@ -52,7 +52,7 @@ class chooser_item implements renderable, templatable { /** * Constructor. */ - public function __construct($id, $label, $value, pix_icon $icon, $description = null, context $context = null) { + public function __construct($id, $label, $value, pix_icon $icon, $description = null, ?context $context = null) { $this->id = $id; $this->label = $label; $this->value = $value; diff --git a/lib/classes/output/external.php b/lib/classes/output/external.php index 181faf9d6ca..b7329353577 100644 --- a/lib/classes/output/external.php +++ b/lib/classes/output/external.php @@ -118,7 +118,7 @@ class external extends external_api { string $template, string $themename, bool $includecomments = false, - string $lang = null + ?string $lang = null ) { global $DB, $CFG, $PAGE; diff --git a/lib/classes/output/mustache_template_source_loader.php b/lib/classes/output/mustache_template_source_loader.php index d5cb7e5a621..039a9ed5851 100644 --- a/lib/classes/output/mustache_template_source_loader.php +++ b/lib/classes/output/mustache_template_source_loader.php @@ -37,7 +37,7 @@ class mustache_template_source_loader { * * @param callable|null $gettemplatesource Callback to load template source by template name */ - public function __construct(callable $gettemplatesource = null) { + public function __construct(?callable $gettemplatesource = null) { if ($gettemplatesource) { // The calling code has specified a function for retrieving the template source // code by name and theme. @@ -140,7 +140,7 @@ class mustache_template_source_loader { bool $includecomments = false, array $seentemplates = [], array $seenstrings = [], - string $lang = null + ?string $lang = null ): array { // Initialise the return values. $templates = []; diff --git a/lib/classes/output/select_menu.php b/lib/classes/output/select_menu.php index e642c70b6c6..710db9207f1 100644 --- a/lib/classes/output/select_menu.php +++ b/lib/classes/output/select_menu.php @@ -50,7 +50,7 @@ class select_menu implements renderable, templatable { * Supports grouped options as well. * @param string|null $selected The value of the preselected option. */ - public function __construct(string $name, array $options, string $selected = null) { + public function __construct(string $name, array $options, ?string $selected = null) { $this->name = $name; $this->options = $options; $this->selected = $selected; diff --git a/lib/classes/persistent.php b/lib/classes/persistent.php index 38ec253430c..8308cd7988a 100644 --- a/lib/classes/persistent.php +++ b/lib/classes/persistent.php @@ -49,7 +49,7 @@ abstract class 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 > 0) { @@ -975,7 +975,7 @@ abstract class persistent { * @param array $params * @return bool */ - public static function record_exists_select($select, array $params = null) { + public static function record_exists_select($select, ?array $params = null) { global $DB; return $DB->record_exists_select(static::TABLE, $select, $params); } diff --git a/lib/classes/shutdown_manager.php b/lib/classes/shutdown_manager.php index 64b8c601f0f..56d9e484a8d 100644 --- a/lib/classes/shutdown_manager.php +++ b/lib/classes/shutdown_manager.php @@ -121,7 +121,7 @@ class core_shutdown_manager { * @param array $params * @return void */ - public static function register_signal_handler($callback, array $params = null): void { + public static function register_signal_handler($callback, ?array $params = null): void { if (!is_callable($callback)) { error_log('Invalid custom signal function detected ' . var_export($callback, true)); // phpcs:ignore } @@ -135,7 +135,7 @@ class core_shutdown_manager { * @param array $params * @return void */ - public static function register_function($callback, array $params = null): void { + public static function register_function($callback, ?array $params = null): void { if (!is_callable($callback)) { error_log('Invalid custom shutdown function detected '.var_export($callback, true)); // phpcs:ignore } diff --git a/lib/classes/user.php b/lib/classes/user.php index 1f1a0be23ee..6554e21f317 100644 --- a/lib/classes/user.php +++ b/lib/classes/user.php @@ -215,7 +215,7 @@ class core_user { * @param int $querylimit Max number of database queries, default 5 (zero = no limit) * @return array Array of user objects with limited fields */ - public static function search($query, \context_course $coursecontext = null, + public static function search($query, ?\context_course $coursecontext = null, $max = 30, $querylimit = 5) { global $CFG, $DB; require_once($CFG->dirroot . '/user/lib.php'); @@ -1229,7 +1229,7 @@ class core_user { * @param stdClass $user User object, defaults to the current user. * @return bool */ - public static function awaiting_action(stdClass $user = null): bool { + public static function awaiting_action(?stdClass $user = null): bool { global $USER; if ($user === null) { @@ -1300,7 +1300,7 @@ class core_user { * @param array $options can include: override - if true, will not use forced firstname/lastname settings * @return string Full name of the user */ - public static function get_fullname(stdClass $user, context $context = null, array $options = []): string { + public static function get_fullname(stdClass $user, ?context $context = null, array $options = []): string { global $CFG, $SESSION; // Clone the user so that it does not mess up the original object. @@ -1414,7 +1414,7 @@ class core_user { * @param context|null $context The context will be used to determine the visibility of the user's profile url. * @return moodle_url Profile url of the user */ - public static function get_profile_url(stdClass $user, context $context = null): moodle_url { + public static function get_profile_url(stdClass $user, ?context $context = null): moodle_url { if (empty($user->id)) { throw new coding_exception('User id is required when displaying profile url.'); } @@ -1453,7 +1453,7 @@ class core_user { * - includetoken = false (whether to use a token for authentication. True for current user, int value for other user id) * @return user_picture User picture object */ - public static function get_profile_picture(stdClass $user, context $context = null, array $options = []): user_picture { + public static function get_profile_picture(stdClass $user, ?context $context = null, array $options = []): user_picture { // Create a new user picture object. $userpicture = new user_picture($user); diff --git a/lib/clilib.php b/lib/clilib.php index e6664cd1a00..82d0c4c41bd 100644 --- a/lib/clilib.php +++ b/lib/clilib.php @@ -54,7 +54,7 @@ function cli_writeln($text, $stream=STDOUT) { * @param bool $casesensitive true if options are case sensitive * @return string entered text */ -function cli_input($prompt, $default='', array $options=null, $casesensitiveoptions=false) { +function cli_input($prompt, $default='', ?array $options=null, $casesensitiveoptions=false) { cli_writeln($prompt); cli_write(': '); $input = fread(STDIN, 2048); @@ -80,7 +80,7 @@ function cli_input($prompt, $default='', array $options=null, $casesensitiveopti * @param array $shortmapping array describing mapping of short to long style options ex:('h'=>'help', 'v'=>'verbose') * @return array array of arrays, options, unrecognised as optionlongname=>value */ -function cli_get_params(array $longoptions, array $shortmapping=null) { +function cli_get_params(array $longoptions, ?array $shortmapping=null) { $shortmapping = (array)$shortmapping; $options = array(); $unrecognized = array(); diff --git a/lib/completionlib.php b/lib/completionlib.php index b18d4768b58..ad928d533c7 100644 --- a/lib/completionlib.php +++ b/lib/completionlib.php @@ -1395,7 +1395,7 @@ class completion_info { * @return array Array of user objects with user fields (including all identity fields) */ public function get_tracked_users($where = '', $whereparams = array(), $groupid = 0, - $sort = '', $limitfrom = '', $limitnum = '', context $extracontext = null) { + $sort = '', $limitfrom = '', $limitnum = '', ?context $extracontext = null) { global $DB; @@ -1447,7 +1447,7 @@ class completion_info { * containing an additional ->progress array of coursemoduleid => completionstate */ public function get_progress_all($where = '', $where_params = array(), $groupid = 0, - $sort = '', $pagesize = '', $start = '', context $extracontext = null) { + $sort = '', $pagesize = '', $start = '', ?context $extracontext = null) { global $CFG, $DB; // Get list of applicable users diff --git a/lib/datalib.php b/lib/datalib.php index 43c0fd439f4..82edd764c7c 100644 --- a/lib/datalib.php +++ b/lib/datalib.php @@ -147,7 +147,7 @@ function get_admins() { * @param array $exceptions A list of IDs to ignore, eg 2,4,5,8,9,10 * @return array */ -function search_users($courseid, $groupid, $searchtext, $sort='', array $exceptions=null) { +function search_users($courseid, $groupid, $searchtext, $sort='', ?array $exceptions=null) { global $DB; $fullname = $DB->sql_fullname('u.firstname', 'u.lastname'); @@ -234,7 +234,7 @@ function search_users($courseid, $groupid, $searchtext, $sort='', array $excepti * parameters (using named placeholders). */ function users_search_sql(string $search, string $u = 'u', int $searchtype = USER_SEARCH_STARTS_WITH, array $extrafields = [], - array $exclude = null, array $includeonly = null): array { + ?array $exclude = null, ?array $includeonly = null): array { global $DB, $CFG; $params = array(); $tests = array(); @@ -360,7 +360,7 @@ function users_search_sql(string $search, string $u = 'u', int $searchtype = USE * string SQL fragment to use in the ORDER BY clause. For example, "firstname, lastname". * array of parameters used in the SQL fragment. If $search is not given, this is guaranteed to be an empty array. */ -function users_order_by_sql(string $usertablealias = '', string $search = null, context $context = null, +function users_order_by_sql(string $usertablealias = '', ?string $search = null, ?context $context = null, array $customfieldmappings = []) { global $DB, $PAGE; @@ -429,8 +429,8 @@ function users_order_by_sql(string $usertablealias = '', string $search = null, * @return array|int|bool {@link $USER} records unless get is false in which case the integer count of the records found is returned. * False is returned if an error is encountered. */ -function get_users($get=true, $search='', $confirmed=false, array $exceptions=null, $sort='firstname ASC', - $firstinitial='', $lastinitial='', $page='', $recordsperpage='', $fields='*', $extraselect='', array $extraparams=null) { +function get_users($get=true, $search='', $confirmed=false, ?array $exceptions=null, $sort='firstname ASC', + $firstinitial='', $lastinitial='', $page='', $recordsperpage='', $fields='*', $extraselect='', ?array $extraparams=null) { global $DB, $CFG; if ($get && !$recordsperpage) { @@ -503,7 +503,7 @@ function get_users($get=true, $search='', $confirmed=false, array $exceptions=nu */ function get_users_listing($sort='lastaccess', $dir='ASC', $page=0, $recordsperpage=0, $search='', $firstinitial='', $lastinitial='', $extraselect='', - array $extraparams=null, $extracontext = null) { + ?array $extraparams=null, $extracontext = null) { global $DB, $CFG; $fullname = $DB->sql_fullname(); @@ -1181,7 +1181,7 @@ function get_scales_menu($courseid=0) { * @param string $select use empty string when updating all records * @param array $params optional select parameters */ -function increment_revision_number($table, $field, $select, array $params = null) { +function increment_revision_number($table, $field, $select, ?array $params = null) { global $DB; $now = time(); diff --git a/lib/ddl/database_manager.php b/lib/ddl/database_manager.php index 7fdd3be58b8..810c3830fb4 100644 --- a/lib/ddl/database_manager.php +++ b/lib/ddl/database_manager.php @@ -955,7 +955,7 @@ class database_manager { * @param array $options * @return array keyed by table name with array of difference messages as values */ - public function check_database_schema(xmldb_structure $schema, array $options = null) { + public function check_database_schema(xmldb_structure $schema, ?array $options = null) { $alloptions = array( 'extratables' => true, 'missingtables' => true, diff --git a/lib/dml/moodle_database.php b/lib/dml/moodle_database.php index 648cdd22039..73653196e85 100644 --- a/lib/dml/moodle_database.php +++ b/lib/dml/moodle_database.php @@ -304,7 +304,7 @@ abstract class moodle_database { * @return bool true * @throws dml_connection_exception if error */ - abstract public function connect($dbhost, $dbuser, $dbpass, $dbname, $prefix, array $dboptions=null); + abstract public function connect($dbhost, $dbuser, $dbpass, $dbname, $prefix, ?array $dboptions=null); /** * Store various database settings @@ -316,7 +316,7 @@ abstract class moodle_database { * @param array $dboptions driver specific options * @return void */ - protected function store_settings($dbhost, $dbuser, $dbpass, $dbname, $prefix, array $dboptions=null) { + protected function store_settings($dbhost, $dbuser, $dbpass, $dbname, $prefix, ?array $dboptions=null) { $this->dbhost = $dbhost; $this->dbuser = $dbuser; $this->dbpass = $dbpass; @@ -376,7 +376,7 @@ abstract class moodle_database { * * @return bool success True for successful connection. False otherwise. */ - public function create_database($dbhost, $dbuser, $dbpass, $dbname, array $dboptions=null) { + public function create_database($dbhost, $dbuser, $dbpass, $dbname, ?array $dboptions=null) { return false; } @@ -600,7 +600,7 @@ abstract class moodle_database { * @param mixed $obj The library specific object. (optional) * @return void */ - protected function print_debug($sql, array $params=null, $obj=null) { + protected function print_debug($sql, ?array $params=null, $obj=null) { if (!$this->get_debug()) { return; } @@ -661,7 +661,7 @@ abstract class moodle_database { * @return array An array list containing sql 'where' part and 'params'. * @throws dml_exception */ - protected function where_clause($table, array $conditions=null) { + protected function where_clause($table, ?array $conditions=null) { // We accept nulls in conditions $conditions = is_null($conditions) ? array() : $conditions; @@ -894,7 +894,7 @@ abstract class moodle_database { * @param array $params The query parameters. * @return array (sql, params, type of params) */ - public function fix_sql_params($sql, array $params=null) { + public function fix_sql_params($sql, ?array $params=null) { global $CFG; require_once($CFG->libdir . '/ddllib.php'); @@ -1317,7 +1317,7 @@ abstract class moodle_database { * @return bool true * @throws dml_exception A DML specific exception is thrown for any errors. */ - abstract public function execute($sql, array $params=null); + abstract public function execute($sql, ?array $params=null); /** * Get a number of records as a moodle_recordset where all the given conditions met. @@ -1353,7 +1353,7 @@ abstract class moodle_database { * @return moodle_recordset A moodle_recordset instance * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function get_recordset($table, array $conditions=null, $sort='', $fields='*', $limitfrom=0, $limitnum=0) { + public function get_recordset($table, ?array $conditions=null, $sort='', $fields='*', $limitfrom=0, $limitnum=0) { list($select, $params) = $this->where_clause($table, $conditions); return $this->get_recordset_select($table, $select, $params, $sort, $fields, $limitfrom, $limitnum); } @@ -1399,7 +1399,7 @@ abstract class moodle_database { * @return moodle_recordset A moodle_recordset instance. * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function get_recordset_select($table, $select, array $params=null, $sort='', $fields='*', $limitfrom=0, $limitnum=0) { + public function get_recordset_select($table, $select, ?array $params=null, $sort='', $fields='*', $limitfrom=0, $limitnum=0) { $sql = "SELECT $fields FROM {".$table."}"; if ($select) { $sql .= " WHERE $select"; @@ -1426,7 +1426,7 @@ abstract class moodle_database { * @return moodle_recordset A moodle_recordset instance. * @throws dml_exception A DML specific exception is thrown for any errors. */ - abstract public function get_recordset_sql($sql, array $params=null, $limitfrom=0, $limitnum=0); + abstract public function get_recordset_sql($sql, ?array $params=null, $limitfrom=0, $limitnum=0); /** * Get all records from a table. @@ -1462,7 +1462,7 @@ abstract class moodle_database { * @return array An array of Objects indexed by first column. * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function get_records($table, array $conditions=null, $sort='', $fields='*', $limitfrom=0, $limitnum=0) { + public function get_records($table, ?array $conditions=null, $sort='', $fields='*', $limitfrom=0, $limitnum=0) { list($select, $params) = $this->where_clause($table, $conditions); return $this->get_records_select($table, $select, $params, $sort, $fields, $limitfrom, $limitnum); } @@ -1506,7 +1506,7 @@ abstract class moodle_database { * @return array of objects indexed by first column * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function get_records_select($table, $select, array $params=null, $sort='', $fields='*', $limitfrom=0, $limitnum=0) { + public function get_records_select($table, $select, ?array $params=null, $sort='', $fields='*', $limitfrom=0, $limitnum=0) { if ($select) { $select = "WHERE $select"; } @@ -1530,7 +1530,7 @@ abstract class moodle_database { * @return array of objects indexed by first column * @throws dml_exception A DML specific exception is thrown for any errors. */ - abstract public function get_records_sql($sql, array $params=null, $limitfrom=0, $limitnum=0); + abstract public function get_records_sql($sql, ?array $params=null, $limitfrom=0, $limitnum=0); /** * Get the first two columns from a number of records as an associative array where all the given conditions met. @@ -1551,7 +1551,7 @@ abstract class moodle_database { * @return array an associative array * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function get_records_menu($table, array $conditions=null, $sort='', $fields='*', $limitfrom=0, $limitnum=0) { + public function get_records_menu($table, ?array $conditions=null, $sort='', $fields='*', $limitfrom=0, $limitnum=0) { $menu = array(); if ($records = $this->get_records($table, $conditions, $sort, $fields, $limitfrom, $limitnum)) { foreach ($records as $record) { @@ -1580,7 +1580,7 @@ abstract class moodle_database { * @return array an associative array * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function get_records_select_menu($table, $select, array $params=null, $sort='', $fields='*', $limitfrom=0, $limitnum=0) { + public function get_records_select_menu($table, $select, ?array $params=null, $sort='', $fields='*', $limitfrom=0, $limitnum=0) { $menu = array(); if ($records = $this->get_records_select($table, $select, $params, $sort, $fields, $limitfrom, $limitnum)) { foreach ($records as $record) { @@ -1606,7 +1606,7 @@ abstract class moodle_database { * @return array an associative array * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function get_records_sql_menu($sql, array $params=null, $limitfrom=0, $limitnum=0) { + public function get_records_sql_menu($sql, ?array $params=null, $limitfrom=0, $limitnum=0) { $menu = array(); if ($records = $this->get_records_sql($sql, $params, $limitfrom, $limitnum)) { foreach ($records as $record) { @@ -1651,7 +1651,7 @@ abstract class moodle_database { * @return stdClass|false a fieldset object containing the first matching record, false or exception if error not found depending on mode * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function get_record_select($table, $select, array $params=null, $fields='*', $strictness=IGNORE_MISSING) { + public function get_record_select($table, $select, ?array $params=null, $fields='*', $strictness=IGNORE_MISSING) { if ($select) { $select = "WHERE $select"; } @@ -1677,7 +1677,7 @@ abstract class moodle_database { * @return mixed a fieldset object containing the first matching record, false or exception if error not found depending on mode * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function get_record_sql($sql, array $params=null, $strictness=IGNORE_MISSING) { + public function get_record_sql($sql, ?array $params=null, $strictness=IGNORE_MISSING) { $strictness = (int)$strictness; // we support true/false for BC reasons too if ($strictness == IGNORE_MULTIPLE) { $count = 1; @@ -1733,7 +1733,7 @@ abstract class moodle_database { * @return mixed the specified value false if not found * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function get_field_select($table, $return, $select, array $params=null, $strictness=IGNORE_MISSING) { + public function get_field_select($table, $return, $select, ?array $params=null, $strictness=IGNORE_MISSING) { if ($select) { $select = "WHERE $select"; } @@ -1756,7 +1756,7 @@ abstract class moodle_database { * @return mixed the specified value false if not found * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function get_field_sql($sql, array $params=null, $strictness=IGNORE_MISSING) { + public function get_field_sql($sql, ?array $params=null, $strictness=IGNORE_MISSING) { if (!$record = $this->get_record_sql($sql, $params, $strictness)) { return false; } @@ -1789,7 +1789,7 @@ abstract class moodle_database { * @return array of values * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function get_fieldset_select($table, $return, $select, array $params=null) { + public function get_fieldset_select($table, $return, $select, ?array $params=null) { if ($select) { $select = "WHERE $select"; } @@ -1804,7 +1804,7 @@ abstract class moodle_database { * @return array of values * @throws dml_exception A DML specific exception is thrown for any errors. */ - abstract public function get_fieldset_sql($sql, array $params=null); + abstract public function get_fieldset_sql($sql, ?array $params=null); /** * Insert new record into database, as fast as possible, no safety checks, lobs not supported. @@ -1919,7 +1919,7 @@ abstract class moodle_database { * @return bool true * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function set_field($table, $newfield, $newvalue, array $conditions=null) { + public function set_field($table, $newfield, $newvalue, ?array $conditions=null) { list($select, $params) = $this->where_clause($table, $conditions); return $this->set_field_select($table, $newfield, $newvalue, $select, $params); } @@ -1935,7 +1935,7 @@ abstract class moodle_database { * @return bool true * @throws dml_exception A DML specific exception is thrown for any errors. */ - abstract public function set_field_select($table, $newfield, $newvalue, $select, array $params=null); + abstract public function set_field_select($table, $newfield, $newvalue, $select, ?array $params=null); /** @@ -1946,7 +1946,7 @@ abstract class moodle_database { * @return int The count of records returned from the specified criteria. * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function count_records($table, array $conditions=null) { + public function count_records($table, ?array $conditions=null) { list($select, $params) = $this->where_clause($table, $conditions); return $this->count_records_select($table, $select, $params); } @@ -1961,7 +1961,7 @@ abstract class moodle_database { * @return int The count of records returned from the specified criteria. * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function count_records_select($table, $select, array $params=null, $countitem="COUNT('x')") { + public function count_records_select($table, $select, ?array $params=null, $countitem="COUNT('x')") { if ($select) { $select = "WHERE $select"; } @@ -1981,7 +1981,7 @@ abstract class moodle_database { * @return int the count * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function count_records_sql($sql, array $params=null) { + public function count_records_sql($sql, ?array $params=null) { $count = $this->get_field_sql($sql, $params); if ($count === false or !is_number($count) or $count < 0) { throw new coding_exception("count_records_sql() expects the first field to contain non-negative number from COUNT(), '$count' found instead."); @@ -2011,7 +2011,7 @@ abstract class moodle_database { * @return bool true if a matching record exists, else false. * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function record_exists_select($table, $select, array $params=null) { + public function record_exists_select($table, $select, ?array $params=null) { if ($select) { $select = "WHERE $select"; } @@ -2029,7 +2029,7 @@ abstract class moodle_database { * @return bool true if the SQL executes without errors and returns at least one record. * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function record_exists_sql($sql, array $params=null) { + public function record_exists_sql($sql, ?array $params=null) { $mrs = $this->get_recordset_sql($sql, $params, 0, 1); $return = $mrs->valid(); $mrs->close(); @@ -2045,7 +2045,7 @@ abstract class moodle_database { * @return bool true. * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function delete_records($table, array $conditions=null) { + public function delete_records($table, ?array $conditions=null) { // truncate is drop/create (DDL), not transactional safe, // so we don't use the shortcut within them. MDL-29198 if (is_null($conditions) && empty($this->transactions)) { @@ -2101,7 +2101,7 @@ abstract class moodle_database { * @return bool true. * @throws dml_exception A DML specific exception is thrown for any errors. */ - abstract public function delete_records_select($table, $select, array $params=null); + abstract public function delete_records_select($table, $select, ?array $params=null); /** * Returns the FROM clause required by some DBs in all SELECT statements. diff --git a/lib/dml/moodle_read_slave_trait.php b/lib/dml/moodle_read_slave_trait.php index da2cca32066..53d1d546f5a 100644 --- a/lib/dml/moodle_read_slave_trait.php +++ b/lib/dml/moodle_read_slave_trait.php @@ -130,7 +130,7 @@ trait moodle_read_slave_trait { * @return bool true * @throws dml_connection_exception if error */ - abstract protected function raw_connect(string $dbhost, string $dbuser, string $dbpass, string $dbname, $prefix, array $dboptions = null): bool; + abstract protected function raw_connect(string $dbhost, string $dbuser, string $dbpass, string $dbname, $prefix, ?array $dboptions = null): bool; /** * Connect to db @@ -145,7 +145,7 @@ trait moodle_read_slave_trait { * @return bool true * @throws dml_connection_exception if error */ - public function connect($dbhost, $dbuser, $dbpass, $dbname, $prefix, array $dboptions = null) { + public function connect($dbhost, $dbuser, $dbpass, $dbname, $prefix, ?array $dboptions = null) { $this->pdbhost = $dbhost; $this->pdbuser = $dbuser; $this->pdbpass = $dbpass; diff --git a/lib/dml/mysqli_native_moodle_database.php b/lib/dml/mysqli_native_moodle_database.php index 9f0aad559ea..0e38f0b3a37 100644 --- a/lib/dml/mysqli_native_moodle_database.php +++ b/lib/dml/mysqli_native_moodle_database.php @@ -65,7 +65,7 @@ class mysqli_native_moodle_database extends moodle_database { * @return bool success * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function create_database($dbhost, $dbuser, $dbpass, $dbname, array $dboptions=null) { + public function create_database($dbhost, $dbuser, $dbpass, $dbname, ?array $dboptions=null) { $driverstatus = $this->driver_installed(); if ($driverstatus !== true) { @@ -512,7 +512,7 @@ class mysqli_native_moodle_database extends moodle_database { * @throws moodle_exception * @throws dml_connection_exception if error */ - public function raw_connect(string $dbhost, string $dbuser, string $dbpass, string $dbname, $prefix, array $dboptions=null): bool { + public function raw_connect(string $dbhost, string $dbuser, string $dbpass, string $dbname, $prefix, ?array $dboptions=null): bool { $driverstatus = $this->driver_installed(); if ($driverstatus !== true) { @@ -1211,7 +1211,7 @@ class mysqli_native_moodle_database extends moodle_database { * Very ugly hack which emulates bound parameters in queries * because prepared statements do not use query cache. */ - protected function emulate_bound_params($sql, array $params=null) { + protected function emulate_bound_params($sql, ?array $params=null) { if (empty($params)) { return $sql; } @@ -1244,7 +1244,7 @@ class mysqli_native_moodle_database extends moodle_database { * @return bool true * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function execute($sql, array $params=null) { + public function execute($sql, ?array $params=null) { list($sql, $params, $type) = $this->fix_sql_params($sql, $params); if (strpos($sql, ';') !== false) { @@ -1283,7 +1283,7 @@ class mysqli_native_moodle_database extends moodle_database { * @return moodle_recordset instance * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function get_recordset_sql($sql, array $params=null, $limitfrom=0, $limitnum=0) { + public function get_recordset_sql($sql, ?array $params=null, $limitfrom=0, $limitnum=0) { list($limitfrom, $limitnum) = $this->normalise_limit_from_num($limitfrom, $limitnum); @@ -1345,7 +1345,7 @@ class mysqli_native_moodle_database extends moodle_database { * @return array of objects, or empty array if no records were found * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function get_records_sql($sql, array $params=null, $limitfrom=0, $limitnum=0) { + public function get_records_sql($sql, ?array $params=null, $limitfrom=0, $limitnum=0) { list($limitfrom, $limitnum) = $this->normalise_limit_from_num($limitfrom, $limitnum); @@ -1387,7 +1387,7 @@ class mysqli_native_moodle_database extends moodle_database { * @return array of values * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function get_fieldset_sql($sql, array $params=null) { + public function get_fieldset_sql($sql, ?array $params=null) { list($sql, $params, $type) = $this->fix_sql_params($sql, $params); $rawsql = $this->emulate_bound_params($sql, $params); @@ -1730,7 +1730,7 @@ class mysqli_native_moodle_database extends moodle_database { * @return bool true * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function set_field_select($table, $newfield, $newvalue, $select, array $params=null) { + public function set_field_select($table, $newfield, $newvalue, $select, ?array $params=null) { if ($select) { $select = "WHERE $select"; } @@ -1771,7 +1771,7 @@ class mysqli_native_moodle_database extends moodle_database { * @return bool true * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function delete_records_select($table, $select, array $params=null) { + public function delete_records_select($table, $select, ?array $params=null) { if ($select) { $select = "WHERE $select"; } diff --git a/lib/dml/oci_native_moodle_database.php b/lib/dml/oci_native_moodle_database.php index 65046bcea09..94625934994 100644 --- a/lib/dml/oci_native_moodle_database.php +++ b/lib/dml/oci_native_moodle_database.php @@ -131,7 +131,7 @@ class oci_native_moodle_database extends moodle_database { * @return bool true * @throws dml_connection_exception if error */ - public function connect($dbhost, $dbuser, $dbpass, $dbname, $prefix, array $dboptions=null) { + public function connect($dbhost, $dbuser, $dbpass, $dbname, $prefix, ?array $dboptions=null) { if ($prefix == '' and !$this->external) { //Enforce prefixes for everybody but mysql throw new dml_exception('prefixcannotbeempty', $this->get_dbfamily()); @@ -875,7 +875,7 @@ class oci_native_moodle_database extends moodle_database { return true; } - protected function bind_params($stmt, array &$params=null, $tablename=null, array &$descriptors = null) { + protected function bind_params($stmt, ?array &$params=null, $tablename=null, ?array &$descriptors = null) { if ($params) { $columns = array(); if ($tablename) { @@ -1006,7 +1006,7 @@ class oci_native_moodle_database extends moodle_database { * @return bool true * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function execute($sql, array $params=null) { + public function execute($sql, ?array $params=null) { list($sql, $params, $type) = $this->fix_sql_params($sql, $params); if (strpos($sql, ';') !== false) { @@ -1040,7 +1040,7 @@ class oci_native_moodle_database extends moodle_database { * @return mixed a fieldset object containing the first matching record, false or exception if error not found depending on mode * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function get_record_sql($sql, array $params=null, $strictness=IGNORE_MISSING) { + public function get_record_sql($sql, ?array $params=null, $strictness=IGNORE_MISSING) { $strictness = (int)$strictness; if ($strictness == IGNORE_MULTIPLE) { // do not limit here - ORA does not like that @@ -1073,7 +1073,7 @@ class oci_native_moodle_database extends moodle_database { * @return moodle_recordset instance * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function get_recordset_sql($sql, array $params=null, $limitfrom=0, $limitnum=0) { + public function get_recordset_sql($sql, ?array $params=null, $limitfrom=0, $limitnum=0) { list($limitfrom, $limitnum) = $this->normalise_limit_from_num($limitfrom, $limitnum); @@ -1117,7 +1117,7 @@ class oci_native_moodle_database extends moodle_database { * @return array of objects, or empty array if no records were found * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function get_records_sql($sql, array $params=null, $limitfrom=0, $limitnum=0) { + public function get_records_sql($sql, ?array $params=null, $limitfrom=0, $limitnum=0) { list($limitfrom, $limitnum) = $this->normalise_limit_from_num($limitfrom, $limitnum); @@ -1168,7 +1168,7 @@ class oci_native_moodle_database extends moodle_database { * @return array of values * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function get_fieldset_sql($sql, array $params=null) { + public function get_fieldset_sql($sql, ?array $params=null) { list($sql, $params, $type) = $this->fix_sql_params($sql, $params); list($sql, $params) = $this->tweak_param_names($sql, $params); @@ -1412,7 +1412,7 @@ class oci_native_moodle_database extends moodle_database { * @return bool true * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function set_field_select($table, $newfield, $newvalue, $select, array $params=null) { + public function set_field_select($table, $newfield, $newvalue, $select, ?array $params=null) { if ($select) { $select = "WHERE $select"; @@ -1469,7 +1469,7 @@ class oci_native_moodle_database extends moodle_database { * @return bool true * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function delete_records_select($table, $select, array $params=null) { + public function delete_records_select($table, $select, ?array $params=null) { if ($select) { $select = "WHERE $select"; diff --git a/lib/dml/pdo_moodle_database.php b/lib/dml/pdo_moodle_database.php index 8dd9a75abd2..3a2a8471524 100644 --- a/lib/dml/pdo_moodle_database.php +++ b/lib/dml/pdo_moodle_database.php @@ -59,7 +59,7 @@ abstract class pdo_moodle_database extends moodle_database { * @param array $dboptions driver specific options * @return bool success */ - public function connect($dbhost, $dbuser, $dbpass, $dbname, $prefix, array $dboptions=null) { + public function connect($dbhost, $dbuser, $dbpass, $dbname, $prefix, ?array $dboptions=null) { $driverstatus = $this->driver_installed(); if ($driverstatus !== true) { @@ -205,7 +205,7 @@ abstract class pdo_moodle_database extends moodle_database { return true; } - public function delete_records_select($table, $select, array $params=null) { + public function delete_records_select($table, $select, ?array $params=null) { $sql = "DELETE FROM {{$table}}"; if ($select) { $sql .= " WHERE $select"; @@ -231,7 +231,7 @@ abstract class pdo_moodle_database extends moodle_database { * @param array $params query parameters * @return bool success */ - public function execute($sql, array $params=null) { + public function execute($sql, ?array $params=null) { list($sql, $params, $type) = $this->fix_sql_params($sql, $params); $result = true; @@ -264,7 +264,7 @@ abstract class pdo_moodle_database extends moodle_database { * @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set). * @return moodle_recordset instance */ - public function get_recordset_sql($sql, array $params=null, $limitfrom=0, $limitnum=0) { + public function get_recordset_sql($sql, ?array $params=null, $limitfrom=0, $limitnum=0) { $result = true; @@ -292,7 +292,7 @@ abstract class pdo_moodle_database extends moodle_database { * @param array $params array of sql parameters * @return array of values */ - public function get_fieldset_sql($sql, array $params=null) { + public function get_fieldset_sql($sql, ?array $params=null) { $rs = $this->get_recordset_sql($sql, $params); if (!$rs->valid()) { $rs->close(); // Not going to iterate (but exit), close rs @@ -320,7 +320,7 @@ abstract class pdo_moodle_database extends moodle_database { * @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set). * @return array of objects, or empty array if no records were found, or false if an error occurred. */ - public function get_records_sql($sql, array $params=null, $limitfrom=0, $limitnum=0) { + public function get_records_sql($sql, ?array $params=null, $limitfrom=0, $limitnum=0) { global $CFG; $rs = $this->get_recordset_sql($sql, $params, $limitfrom, $limitnum); @@ -499,7 +499,7 @@ abstract class pdo_moodle_database extends moodle_database { * @param array $params array of sql parameters * @return bool success */ - public function set_field_select($table, $newfield, $newvalue, $select, array $params=null) { + public function set_field_select($table, $newfield, $newvalue, $select, ?array $params=null) { if ($select) { $select = "WHERE $select"; } diff --git a/lib/dml/pgsql_native_moodle_database.php b/lib/dml/pgsql_native_moodle_database.php index 974c7108b3d..f7d70c040df 100644 --- a/lib/dml/pgsql_native_moodle_database.php +++ b/lib/dml/pgsql_native_moodle_database.php @@ -141,7 +141,7 @@ class pgsql_native_moodle_database extends moodle_database { * @throws moodle_exception * @throws dml_connection_exception if error */ - public function raw_connect(string $dbhost, string $dbuser, string $dbpass, string $dbname, $prefix, array $dboptions=null): bool { + public function raw_connect(string $dbhost, string $dbuser, string $dbpass, string $dbname, $prefix, ?array $dboptions=null): bool { if ($prefix == '' and !$this->external) { //Enforce prefixes for everybody but mysql throw new dml_exception('prefixcannotbeempty', $this->get_dbfamily()); @@ -851,7 +851,7 @@ class pgsql_native_moodle_database extends moodle_database { * @return bool true * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function execute($sql, array $params=null) { + public function execute($sql, ?array $params=null) { list($sql, $params, $type) = $this->fix_sql_params($sql, $params); if (strpos($sql, ';') !== false) { @@ -883,7 +883,7 @@ class pgsql_native_moodle_database extends moodle_database { * @return moodle_recordset instance * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function get_recordset_sql($sql, array $params=null, $limitfrom=0, $limitnum=0) { + public function get_recordset_sql($sql, ?array $params=null, $limitfrom=0, $limitnum=0) { list($limitfrom, $limitnum) = $this->normalise_limit_from_num($limitfrom, $limitnum); @@ -1028,7 +1028,7 @@ class pgsql_native_moodle_database extends moodle_database { * @return array of objects, or empty array if no records were found * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function get_records_sql($sql, array $params = null, $limitfrom = 0, $limitnum = 0) { + public function get_records_sql($sql, ?array $params = null, $limitfrom = 0, $limitnum = 0) { list($limitfrom, $limitnum) = $this->normalise_limit_from_num($limitfrom, $limitnum); if ($limitnum) { @@ -1079,7 +1079,7 @@ class pgsql_native_moodle_database extends moodle_database { * @return array of values * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function get_fieldset_sql($sql, array $params=null) { + public function get_fieldset_sql($sql, ?array $params=null) { list($sql, $params, $type) = $this->fix_sql_params($sql, $params); $this->query_start($sql, $params, SQL_QUERY_SELECT); @@ -1405,7 +1405,7 @@ class pgsql_native_moodle_database extends moodle_database { * @return bool true * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function set_field_select($table, $newfield, $newvalue, $select, array $params=null) { + public function set_field_select($table, $newfield, $newvalue, $select, ?array $params=null) { if ($select) { $select = "WHERE $select"; @@ -1444,7 +1444,7 @@ class pgsql_native_moodle_database extends moodle_database { * @return bool true * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function delete_records_select($table, $select, array $params=null) { + public function delete_records_select($table, $select, ?array $params=null) { if ($select) { $select = "WHERE $select"; } diff --git a/lib/dml/pgsql_native_moodle_recordset.php b/lib/dml/pgsql_native_moodle_recordset.php index d6ef4113fd1..6642af3e446 100644 --- a/lib/dml/pgsql_native_moodle_recordset.php +++ b/lib/dml/pgsql_native_moodle_recordset.php @@ -59,7 +59,7 @@ class pgsql_native_moodle_recordset extends moodle_recordset { * @param pgsql_native_moodle_database $db Database object (only required when using cursors) * @param string $cursorname Name of cursor or '' if none */ - public function __construct($result, pgsql_native_moodle_database $db = null, $cursorname = '') { + public function __construct($result, ?pgsql_native_moodle_database $db = null, $cursorname = '') { if ($cursorname && !$db) { throw new coding_exception('When specifying a cursor, $db is required'); } diff --git a/lib/dml/sqlite3_pdo_moodle_database.php b/lib/dml/sqlite3_pdo_moodle_database.php index c6976995611..394e257bf2c 100644 --- a/lib/dml/sqlite3_pdo_moodle_database.php +++ b/lib/dml/sqlite3_pdo_moodle_database.php @@ -86,7 +86,7 @@ class sqlite3_pdo_moodle_database extends pdo_moodle_database { * * @return bool success */ - public function create_database($dbhost, $dbuser, $dbpass, $dbname, array $dboptions=null) { + public function create_database($dbhost, $dbuser, $dbpass, $dbname, ?array $dboptions=null) { global $CFG; $this->dbhost = $dbhost; @@ -329,7 +329,7 @@ class sqlite3_pdo_moodle_database extends pdo_moodle_database { * @param array $conditions optional array $fieldname=>requestedvalue with AND in between * @return returns success. */ - public function delete_records($table, array $conditions=null) { + public function delete_records($table, ?array $conditions=null) { if (is_null($conditions)) { return $this->execute("DELETE FROM {{$table}}"); } diff --git a/lib/dml/sqlsrv_native_moodle_database.php b/lib/dml/sqlsrv_native_moodle_database.php index bf189e2a10c..94443287b09 100644 --- a/lib/dml/sqlsrv_native_moodle_database.php +++ b/lib/dml/sqlsrv_native_moodle_database.php @@ -187,7 +187,7 @@ class sqlsrv_native_moodle_database extends moodle_database { * @return bool true * @throws dml_connection_exception if error */ - public function connect($dbhost, $dbuser, $dbpass, $dbname, $prefix, array $dboptions=null) { + public function connect($dbhost, $dbuser, $dbpass, $dbname, $prefix, ?array $dboptions=null) { if ($prefix == '' and !$this->external) { // Enforce prefixes for everybody but mysql. throw new dml_exception('prefixcannotbeempty', $this->get_dbfamily()); @@ -772,7 +772,7 @@ class sqlsrv_native_moodle_database extends moodle_database { /** * Prepare the array of params for native binding */ - protected function build_native_bound_params(array $params = null) { + protected function build_native_bound_params(?array $params = null) { return null; } @@ -781,7 +781,7 @@ class sqlsrv_native_moodle_database extends moodle_database { * Workaround for SQL*Server Native driver similar to MSSQL driver for * consistent behavior. */ - protected function emulate_bound_params($sql, array $params = null) { + protected function emulate_bound_params($sql, ?array $params = null) { if (empty($params)) { return $sql; @@ -822,7 +822,7 @@ class sqlsrv_native_moodle_database extends moodle_database { * @return bool true * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function execute($sql, array $params = null) { + public function execute($sql, ?array $params = null) { if (strpos($sql, ';') !== false) { throw new coding_exception('moodle_database::execute() Multiple sql statements found or bound parameters not used properly in query!'); } @@ -871,7 +871,7 @@ class sqlsrv_native_moodle_database extends moodle_database { * @return moodle_recordset instance * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function get_recordset_sql($sql, array $params = null, $limitfrom = 0, $limitnum = 0) { + public function get_recordset_sql($sql, ?array $params = null, $limitfrom = 0, $limitnum = 0) { list($limitfrom, $limitnum) = $this->normalise_limit_from_num($limitfrom, $limitnum); $needscrollable = (bool)$limitfrom; // To determine if we'll need to perform scroll to $limitfrom. @@ -980,7 +980,7 @@ class sqlsrv_native_moodle_database extends moodle_database { * @return array of objects, or empty array if no records were found * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function get_records_sql($sql, array $params = null, $limitfrom = 0, $limitnum = 0) { + public function get_records_sql($sql, ?array $params = null, $limitfrom = 0, $limitnum = 0) { $rs = $this->get_recordset_sql($sql, $params, $limitfrom, $limitnum); @@ -1009,7 +1009,7 @@ class sqlsrv_native_moodle_database extends moodle_database { * @return array of values * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function get_fieldset_sql($sql, array $params = null) { + public function get_fieldset_sql($sql, ?array $params = null) { $rs = $this->get_recordset_sql($sql, $params); @@ -1267,7 +1267,7 @@ class sqlsrv_native_moodle_database extends moodle_database { * @return bool true * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function set_field_select($table, $newfield, $newvalue, $select, array $params = null) { + public function set_field_select($table, $newfield, $newvalue, $select, ?array $params = null) { if ($select) { $select = "WHERE $select"; } @@ -1307,7 +1307,7 @@ class sqlsrv_native_moodle_database extends moodle_database { * @return bool true * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function delete_records_select($table, $select, array $params = null) { + public function delete_records_select($table, $select, ?array $params = null) { if ($select) { $select = "WHERE $select"; } diff --git a/lib/dml/tests/dml_test.php b/lib/dml/tests/dml_test.php index 31a753f9aa6..d4390771354 100644 --- a/lib/dml/tests/dml_test.php +++ b/lib/dml/tests/dml_test.php @@ -6508,7 +6508,7 @@ class moodle_database_for_testing extends moodle_database { protected function get_dblibrary() {} public function get_name() {} public function get_configuration_help() {} - public function connect($dbhost, $dbuser, $dbpass, $dbname, $prefix, array $dboptions=null) {} + public function connect($dbhost, $dbuser, $dbpass, $dbname, $prefix, ?array $dboptions=null) {} public function get_server_info() {} protected function allowed_param_types() {} public function get_last_error() {} @@ -6521,17 +6521,17 @@ class moodle_database_for_testing extends moodle_database { public function set_debug($state) {} public function get_debug() {} public function change_database_structure($sql, $tablenames = null) {} - public function execute($sql, array $params=null) {} - public function get_recordset_sql($sql, array $params=null, $limitfrom=0, $limitnum=0) {} - public function get_records_sql($sql, array $params=null, $limitfrom=0, $limitnum=0) {} - public function get_fieldset_sql($sql, array $params=null) {} + public function execute($sql, ?array $params=null) {} + public function get_recordset_sql($sql, ?array $params=null, $limitfrom=0, $limitnum=0) {} + public function get_records_sql($sql, ?array $params=null, $limitfrom=0, $limitnum=0) {} + public function get_fieldset_sql($sql, ?array $params=null) {} public function insert_record_raw($table, $params, $returnid=true, $bulk=false, $customsequence=false) {} public function insert_record($table, $dataobject, $returnid=true, $bulk=false) {} public function import_record($table, $dataobject) {} public function update_record_raw($table, $params, $bulk=false) {} public function update_record($table, $dataobject, $bulk=false) {} - public function set_field_select($table, $newfield, $newvalue, $select, array $params=null) {} - public function delete_records_select($table, $select, array $params=null) {} + public function set_field_select($table, $newfield, $newvalue, $select, ?array $params=null) {} + public function delete_records_select($table, $select, ?array $params=null) {} public function sql_concat(...$arr) {} public function sql_concat_join($separator="' '", $elements=array()) {} public function sql_group_concat(string $field, string $separator = ', ', string $sort = ''): string { diff --git a/lib/dml/tests/fixtures/read_slave_moodle_database.php b/lib/dml/tests/fixtures/read_slave_moodle_database.php index a69133fcbf9..3a6f1d04b8b 100644 --- a/lib/dml/tests/fixtures/read_slave_moodle_database.php +++ b/lib/dml/tests/fixtures/read_slave_moodle_database.php @@ -54,7 +54,7 @@ class read_slave_moodle_database extends test_moodle_database { * @param array $dboptions * @return bool true */ - public function raw_connect(string $dbhost, string $dbuser, string $dbpass, string $dbname, $prefix, array $dboptions = null): bool { + public function raw_connect(string $dbhost, string $dbuser, string $dbpass, string $dbname, $prefix, ?array $dboptions = null): bool { $dbport = isset($dboptions['dbport']) ? $dboptions['dbport'] : ""; $this->handle = implode(':', [$dbhost, $dbport, $dbuser, $dbpass]); $this->prefix = $prefix; @@ -113,7 +113,7 @@ class read_slave_moodle_database extends test_moodle_database { * @return bool true * @throws \Exception */ - public function execute($sql, array $params = null) { + public function execute($sql, ?array $params = null) { list($sql, $params, $type) = $this->fix_sql_params($sql, $params); return $this->with_query_start_end($sql, $params, SQL_QUERY_UPDATE); } @@ -126,7 +126,7 @@ class read_slave_moodle_database extends test_moodle_database { * @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set). * @return string $handle handle property */ - public function get_records_sql($sql, array $params = null, $limitfrom = 0, $limitnum = 0) { + public function get_records_sql($sql, ?array $params = null, $limitfrom = 0, $limitnum = 0) { list($sql, $params, $type) = $this->fix_sql_params($sql, $params); return $this->with_query_start_end($sql, $params, SQL_QUERY_SELECT); } @@ -139,7 +139,7 @@ class read_slave_moodle_database extends test_moodle_database { * @param int $limitnum * @return bool true */ - public function get_recordset_sql($sql, array $params = null, $limitfrom = 0, $limitnum = 0) { + public function get_recordset_sql($sql, ?array $params = null, $limitfrom = 0, $limitnum = 0) { list($sql, $params, $type) = $this->fix_sql_params($sql, $params); return $this->with_query_start_end($sql, $params, SQL_QUERY_SELECT); } diff --git a/lib/dml/tests/fixtures/read_slave_moodle_database_special.php b/lib/dml/tests/fixtures/read_slave_moodle_database_special.php index a04c669abb5..ad7a4988462 100644 --- a/lib/dml/tests/fixtures/read_slave_moodle_database_special.php +++ b/lib/dml/tests/fixtures/read_slave_moodle_database_special.php @@ -46,7 +46,7 @@ class read_slave_moodle_database_special extends read_slave_moodle_database { * @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set). * @return string $handle handle property */ - public function get_records_sql($sql, array $params = null, $limitfrom = 0, $limitnum = 0) { + public function get_records_sql($sql, ?array $params = null, $limitfrom = 0, $limitnum = 0) { $dbhandle = parent::get_records_sql($sql, $params); return []; } @@ -60,7 +60,7 @@ class read_slave_moodle_database_special extends read_slave_moodle_database { * @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set). * @return string $handle handle property */ - public function get_records_sql_p($sql, array $params = null, $limitfrom = 0, $limitnum = 0) { + public function get_records_sql_p($sql, ?array $params = null, $limitfrom = 0, $limitnum = 0) { return parent::get_records_sql($sql, $params); } @@ -72,7 +72,7 @@ class read_slave_moodle_database_special extends read_slave_moodle_database { * @param int $limitnum * @return bool true */ - public function get_recordset_sql($sql, array $params = null, $limitfrom = 0, $limitnum = 0) { + public function get_recordset_sql($sql, ?array $params = null, $limitfrom = 0, $limitnum = 0) { $dbhandle = parent::get_recordset_sql($sql, $params); return new read_slave_moodle_recordset_special(); } @@ -84,7 +84,7 @@ class read_slave_moodle_database_special extends read_slave_moodle_database { * @param array $conditions optional array $fieldname=>requestedvalue with AND in between * @return int The count of records returned from the specified criteria. */ - public function count_records($table, array $conditions = null) { + public function count_records($table, ?array $conditions = null) { return 1; } } diff --git a/lib/dml/tests/fixtures/test_moodle_database.php b/lib/dml/tests/fixtures/test_moodle_database.php index 387defdf74b..7d5a6ac2936 100644 --- a/lib/dml/tests/fixtures/test_moodle_database.php +++ b/lib/dml/tests/fixtures/test_moodle_database.php @@ -195,7 +195,7 @@ abstract class test_moodle_database extends \moodle_database { * @return bool true * @throws Exception */ - public function execute($sql, array $params = null) { + public function execute($sql, ?array $params = null) { throw new Exception("execute() not implemented"); } @@ -208,7 +208,7 @@ abstract class test_moodle_database extends \moodle_database { * @return bool true * @throws Exception */ - public function get_recordset_sql($sql, array $params = null, $limitfrom = 0, $limitnum = 0) { + public function get_recordset_sql($sql, ?array $params = null, $limitfrom = 0, $limitnum = 0) { throw new Exception("get_recordset_sql() not implemented"); } @@ -221,7 +221,7 @@ abstract class test_moodle_database extends \moodle_database { * @return bool true * @throws Exception */ - public function get_records_sql($sql, array $params = null, $limitfrom = 0, $limitnum = 0) { + public function get_records_sql($sql, ?array $params = null, $limitfrom = 0, $limitnum = 0) { throw new Exception("get_records_sql() not implemented"); } @@ -232,7 +232,7 @@ abstract class test_moodle_database extends \moodle_database { * @return bool true * @throws Exception */ - public function get_fieldset_sql($sql, array $params = null) { + public function get_fieldset_sql($sql, ?array $params = null) { throw new Exception("get_fieldset_sql() not implemented"); } @@ -308,7 +308,7 @@ abstract class test_moodle_database extends \moodle_database { * @return bool true * @throws Exception */ - public function set_field_select($table, $newfield, $newvalue, $select, array $params = null) { + public function set_field_select($table, $newfield, $newvalue, $select, ?array $params = null) { throw new Exception("set_field_select() not implemented"); } @@ -320,7 +320,7 @@ abstract class test_moodle_database extends \moodle_database { * @return bool true * @throws Exception */ - public function delete_records_select($table, $select, array $params = null) { + public function delete_records_select($table, $select, ?array $params = null) { throw new Exception("delete_records_select() not implemented"); } diff --git a/lib/dmllib.php b/lib/dmllib.php index 497a00f8d2e..87244221acb 100644 --- a/lib/dmllib.php +++ b/lib/dmllib.php @@ -132,7 +132,7 @@ class dml_read_exception extends dml_exception { * @param string $sql The SQL that ran just before this read error. * @param array $params The SQL's related parameters.(optional) */ - function __construct($error, $sql=null, array $params=null) { + function __construct($error, $sql=null, ?array $params=null) { $this->error = $error; $this->sql = $sql; $this->params = $params; @@ -161,7 +161,7 @@ class dml_multiple_records_exception extends dml_exception { * @param string $sql The SQL that ran just before this read error. * @param array $params The SQL's related parameters.(optional) */ - function __construct($sql='', array $params=null) { + function __construct($sql='', ?array $params=null) { $errorinfo = $sql."\n[".var_export($params, true).']'; parent::__construct('multiplerecordsfound', null, $errorinfo); } @@ -190,7 +190,7 @@ class dml_missing_record_exception extends dml_exception { * @param string $sql Optional SQL query. * @param array $params Optional SQL query's parameters. */ - function __construct($tablename, $sql='', array $params=null) { + function __construct($tablename, $sql='', ?array $params=null) { if (empty($tablename)) { $tablename = null; } @@ -243,7 +243,7 @@ class dml_write_exception extends dml_exception { * @param string $sql The SQL that ran just before this write error. * @param array $params The SQL's related parameters.(optional) */ - function __construct($error, $sql=null, array $params=null) { + function __construct($error, $sql=null, ?array $params=null) { $this->error = $error; $this->sql = $sql; $this->params = $params; diff --git a/lib/dtl/database_mover.php b/lib/dtl/database_mover.php index 419080e089e..e4106c174ba 100644 --- a/lib/dtl/database_mover.php +++ b/lib/dtl/database_mover.php @@ -43,7 +43,7 @@ class database_mover extends database_exporter { * @see export_database). */ public function __construct(moodle_database $mdb_source, moodle_database $mdb_target, - $check_schema = true, progress_trace $feedback = null) { + $check_schema = true, ?progress_trace $feedback = null) { if (empty($feedback)) { $this->feedback = new null_progress_trace(); } else { diff --git a/lib/editor/atto/lib.php b/lib/editor/atto/lib.php index ab29f7319c1..182cf37dab2 100644 --- a/lib/editor/atto/lib.php +++ b/lib/editor/atto/lib.php @@ -83,7 +83,7 @@ class atto_texteditor extends texteditor { * @param array $options * @param null $fpoptions */ - public function use_editor($elementid, array $options=null, $fpoptions=null) { + public function use_editor($elementid, ?array $options=null, $fpoptions=null) { global $PAGE; if (array_key_exists('atto:toolbar', $options)) { @@ -167,7 +167,7 @@ class atto_texteditor extends texteditor { * @param array $options * @param array $fpoptions */ - protected function get_init_params($elementid, array $options = null, array $fpoptions = null, $plugins = null) { + protected function get_init_params($elementid, ?array $options = null, ?array $fpoptions = null, $plugins = null) { global $PAGE; $directionality = get_string('thisdirection', 'langconfig'); diff --git a/lib/editor/textarea/lib.php b/lib/editor/textarea/lib.php index 9c8bc31215c..6ef5b1f920a 100644 --- a/lib/editor/textarea/lib.php +++ b/lib/editor/textarea/lib.php @@ -47,7 +47,7 @@ class textarea_texteditor extends texteditor { return true; } - public function use_editor($elementid, array $options=null, $fpoptions=null) { + public function use_editor($elementid, ?array $options=null, $fpoptions=null) { return; } } diff --git a/lib/editor/tiny/classes/editor.php b/lib/editor/tiny/classes/editor.php index 0863858820a..3ac122bf06b 100644 --- a/lib/editor/tiny/classes/editor.php +++ b/lib/editor/tiny/classes/editor.php @@ -142,7 +142,7 @@ class editor extends \texteditor { * @param array $options * @param null $fpoptions */ - public function use_editor($elementid, array $options = null, $fpoptions = null) { + public function use_editor($elementid, ?array $options = null, $fpoptions = null) { global $PAGE; // Ensure that the default configuration is set. diff --git a/lib/editorlib.php b/lib/editorlib.php index 9e2423dab66..a7ddebfd637 100644 --- a/lib/editorlib.php +++ b/lib/editorlib.php @@ -234,7 +234,7 @@ abstract class texteditor { * @param obejct $fpoptions file picker options * @return void */ - abstract public function use_editor($elementid, array $options=null, $fpoptions = null); + abstract public function use_editor($elementid, ?array $options=null, $fpoptions = null); /** * Setup all JS and CSS needed for editor. diff --git a/lib/enrollib.php b/lib/enrollib.php index fa97842e660..72ebb4bf799 100644 --- a/lib/enrollib.php +++ b/lib/enrollib.php @@ -849,7 +849,7 @@ function enrol_get_my_courses($fields = null, $sort = null, $limit = 0, $coursei * @param array $instances enrol instances of this course, improves performance * @return array of pix_icon */ -function enrol_get_course_info_icons($course, array $instances = NULL) { +function enrol_get_course_info_icons($course, ?array $instances = NULL) { $icons = array(); if (is_null($instances)) { $instances = enrol_get_instances($course->id, true); @@ -2594,7 +2594,7 @@ abstract class enrol_plugin { * @param array instance fields * @return int id of new instance, null if can not be created */ - public function add_instance($course, array $fields = NULL) { + public function add_instance($course, ?array $fields = NULL) { global $DB; if ($course->id == SITEID) { diff --git a/lib/filelib.php b/lib/filelib.php index 3a4eb1577f2..31b8ab80acd 100644 --- a/lib/filelib.php +++ b/lib/filelib.php @@ -405,7 +405,7 @@ function file_get_unused_draft_itemid() { * @param string $text some html content that needs to have embedded links rewritten to point to the draft area. * @return string|null returns string if $text was passed in, the rewritten $text is returned. Otherwise NULL. */ -function file_prepare_draft_area(&$draftitemid, $contextid, $component, $filearea, $itemid, array $options=null, $text=null) { +function file_prepare_draft_area(&$draftitemid, $contextid, $component, $filearea, $itemid, ?array $options=null, $text=null) { global $CFG, $USER; $options = (array)$options; @@ -489,7 +489,7 @@ function file_prepare_draft_area(&$draftitemid, $contextid, $component, $fileare * mixed $options.includetoken Use a token for authentication. True for current user, int value for other user id. * string The processed text. */ -function file_rewrite_pluginfile_urls($text, $file, $contextid, $component, $filearea, $itemid, array $options=null) { +function file_rewrite_pluginfile_urls($text, $file, $contextid, $component, $filearea, $itemid, ?array $options=null) { global $CFG, $USER; $options = (array)$options; @@ -1104,7 +1104,7 @@ function file_copy_file_to_file_area($file, $filename, $itemid) { * @param bool $forcehttps force https urls. * @return string|null if $text was passed in, the rewritten $text is returned. Otherwise NULL. */ -function file_save_draft_area_files($draftitemid, $contextid, $component, $filearea, $itemid, array $options=null, $text=null, $forcehttps=false) { +function file_save_draft_area_files($draftitemid, $contextid, $component, $filearea, $itemid, ?array $options=null, $text=null, $forcehttps=false) { global $USER; // Do not merge files, leave it as it was. @@ -2971,7 +2971,7 @@ function file_overwrite_existing_draftfile(stored_file $newfile, stored_file $ex * @since Moodle 3.2 */ function file_merge_files_from_draft_area_into_filearea($draftitemid, $contextid, $component, $filearea, $itemid, - array $options = null) { + ?array $options = null) { // We use 0 here so file_prepare_draft_area creates a new one, finaldraftid will be updated with the new draft id. $finaldraftid = 0; file_prepare_draft_area($finaldraftid, $contextid, $component, $filearea, $itemid, $options); diff --git a/lib/filestorage/file_packer.php b/lib/filestorage/file_packer.php index 0fe1d779560..a1c59a7c2ac 100644 --- a/lib/filestorage/file_packer.php +++ b/lib/filestorage/file_packer.php @@ -61,7 +61,7 @@ abstract class file_packer { */ abstract public function archive_to_storage(array $files, $contextid, $component, $filearea, $itemid, $filepath, $filename, - $userid = NULL, $ignoreinvalidfiles=true, file_progress $progress = null); + $userid = NULL, $ignoreinvalidfiles=true, ?file_progress $progress = null); /** * Archive files and store the result in os file. @@ -85,7 +85,7 @@ abstract class file_packer { * @return bool true if file created, false if not */ abstract public function archive_to_pathname(array $files, $archivefile, - $ignoreinvalidfiles=true, file_progress $progress = null); + $ignoreinvalidfiles=true, ?file_progress $progress = null); /** * Extract file to given file path (real OS filesystem), existing files are overwritten. @@ -99,7 +99,7 @@ abstract class file_packer { * @return array|bool list of processed files; false if error */ abstract public function extract_to_pathname($archivefile, $pathname, - array $onlyfiles = NULL, file_progress $progress = null, $returnbool = false); + ?array $onlyfiles = NULL, ?file_progress $progress = null, $returnbool = false); /** * Extract file to given file path (real OS filesystem), existing files are overwritten. @@ -116,7 +116,7 @@ abstract class file_packer { */ abstract public function extract_to_storage($archivefile, $contextid, $component, $filearea, $itemid, $pathbase, $userid = NULL, - file_progress $progress = null); + ?file_progress $progress = null); /** * Returns array of info about all files in archive. diff --git a/lib/filestorage/file_storage.php b/lib/filestorage/file_storage.php index 25796e2fdaa..5a3ec192890 100644 --- a/lib/filestorage/file_storage.php +++ b/lib/filestorage/file_storage.php @@ -915,7 +915,7 @@ class file_storage { * @param array $params any query params used by $itemidstest. */ public function delete_area_files_select($contextid, $component, - $filearea, $itemidstest, array $params = null) { + $filearea, $itemidstest, ?array $params = null) { global $DB; $where = "contextid = :contextid @@ -1221,7 +1221,7 @@ class file_storage { * @param bool $usetempfile use temporary file for download, may prevent out of memory problems * @return stored_file */ - public function create_file_from_url($filerecord, $url, array $options = null, $usetempfile = false) { + public function create_file_from_url($filerecord, $url, ?array $options = null, $usetempfile = false) { $filerecord = (array)$filerecord; // Do not modify the submitted record, this cast unlinks objects. $filerecord = (object)$filerecord; // We support arrays too. diff --git a/lib/filestorage/file_system.php b/lib/filestorage/file_system.php index 53f37d93abb..b9e8cee61a9 100644 --- a/lib/filestorage/file_system.php +++ b/lib/filestorage/file_system.php @@ -284,7 +284,7 @@ abstract class file_system { * @param file_progress $progress progress indicator callback or null if not required * @return array|bool List of processed files; false if error */ - public function extract_to_pathname(stored_file $file, file_packer $packer, $pathname, file_progress $progress = null) { + public function extract_to_pathname(stored_file $file, file_packer $packer, $pathname, ?file_progress $progress = null) { $archivefile = $this->get_local_path_from_storedfile($file, true); return $packer->extract_to_pathname($archivefile, $pathname, null, $progress); } @@ -304,7 +304,7 @@ abstract class file_system { * @return array|bool list of processed files; false if error */ public function extract_to_storage(stored_file $file, file_packer $packer, $contextid, - $component, $filearea, $itemid, $pathbase, $userid = null, file_progress $progress = null) { + $component, $filearea, $itemid, $pathbase, $userid = null, ?file_progress $progress = null) { // Since we do not know which extractor we have, and whether it supports remote paths, use a local path here. $archivefile = $this->get_local_path_from_storedfile($file, true); diff --git a/lib/filestorage/mbz_packer.php b/lib/filestorage/mbz_packer.php index 3fde394c0f0..7814a3c308e 100644 --- a/lib/filestorage/mbz_packer.php +++ b/lib/filestorage/mbz_packer.php @@ -66,7 +66,7 @@ class mbz_packer extends file_packer { */ public function archive_to_storage(array $files, $contextid, $component, $filearea, $itemid, $filepath, $filename, - $userid = null, $ignoreinvalidfiles = true, file_progress $progress = null) { + $userid = null, $ignoreinvalidfiles = true, ?file_progress $progress = null) { return $this->get_packer_for_archive_operation()->archive_to_storage($files, $contextid, $component, $filearea, $itemid, $filepath, $filename, $userid, $ignoreinvalidfiles, $progress); @@ -83,7 +83,7 @@ class mbz_packer extends file_packer { * @throws coding_exception If any archive paths do not meet the restrictions */ public function archive_to_pathname(array $files, $archivefile, - $ignoreinvalidfiles=true, file_progress $progress = null) { + $ignoreinvalidfiles=true, ?file_progress $progress = null) { return $this->get_packer_for_archive_operation()->archive_to_pathname($files, $archivefile, $ignoreinvalidfiles, $progress); } @@ -101,7 +101,7 @@ class mbz_packer extends file_packer { * @throws moodle_exception If error */ public function extract_to_pathname($archivefile, $pathname, - array $onlyfiles = null, file_progress $progress = null, $returnbool = false) { + ?array $onlyfiles = null, ?file_progress $progress = null, $returnbool = false) { return $this->get_packer_for_read_operation($archivefile)->extract_to_pathname( $archivefile, $pathname, $onlyfiles, $progress, $returnbool); } @@ -122,7 +122,7 @@ class mbz_packer extends file_packer { */ public function extract_to_storage($archivefile, $contextid, $component, $filearea, $itemid, $pathbase, $userid = null, - file_progress $progress = null) { + ?file_progress $progress = null) { return $this->get_packer_for_read_operation($archivefile)->extract_to_storage( $archivefile, $contextid, $component, $filearea, $itemid, $pathbase, $userid, $progress); diff --git a/lib/filestorage/stored_file.php b/lib/filestorage/stored_file.php index 4cd5b3ecc78..b51eedb4cb5 100644 --- a/lib/filestorage/stored_file.php +++ b/lib/filestorage/stored_file.php @@ -540,7 +540,7 @@ class stored_file { * @return array|bool list of processed files; false if error */ public function extract_to_pathname(file_packer $packer, $pathname, - file_progress $progress = null) { + ?file_progress $progress = null) { return $this->filesystem->extract_to_pathname($this, $packer, $pathname, $progress); } @@ -558,7 +558,7 @@ class stored_file { * @return array|bool list of processed files; false if error */ public function extract_to_storage(file_packer $packer, $contextid, - $component, $filearea, $itemid, $pathbase, $userid = null, file_progress $progress = null) { + $component, $filearea, $itemid, $pathbase, $userid = null, ?file_progress $progress = null) { return $this->filesystem->extract_to_storage($this, $packer, $contextid, $component, $filearea, $itemid, $pathbase, $userid, $progress); diff --git a/lib/filestorage/tgz_extractor.php b/lib/filestorage/tgz_extractor.php index 4d1bc370fb2..c0ca1382f0a 100644 --- a/lib/filestorage/tgz_extractor.php +++ b/lib/filestorage/tgz_extractor.php @@ -137,7 +137,7 @@ class tgz_extractor { * @return array Array from archive path => true of processed files * @throws moodle_exception If there is any error processing the archive */ - public function extract(tgz_extractor_handler $handler, file_progress $progress = null) { + public function extract(tgz_extractor_handler $handler, ?file_progress $progress = null) { $this->mode = self::MODE_EXTRACT; $this->extract_or_list($handler, $progress); $results = $this->results; @@ -152,7 +152,7 @@ class tgz_extractor { * @param file_progress $progress Optional progress reporting * @throws moodle_exception If there is any error processing the archive */ - protected function extract_or_list(tgz_extractor_handler $handler = null, file_progress $progress = null) { + protected function extract_or_list(?tgz_extractor_handler $handler = null, ?file_progress $progress = null) { // Open archive. if ($this->storedfile) { $gz = $this->storedfile->get_content_file_handle(stored_file::FILE_HANDLE_GZOPEN); @@ -345,7 +345,7 @@ class tgz_extractor { * @param string $block Data block * @param tgz_extractor_handler $handler Will be called for extracted files */ - protected function process_file_block($block, tgz_extractor_handler $handler = null) { + protected function process_file_block($block, ?tgz_extractor_handler $handler = null) { // Write block into buffer. $blocksize = tgz_packer::TAR_BLOCK_SIZE; if ($this->currentfileprocessed + tgz_packer::TAR_BLOCK_SIZE > $this->currentfilesize) { @@ -389,7 +389,7 @@ class tgz_extractor { * @throws moodle_exception */ protected function start_current_file($archivepath, $filesize, $mtime, - tgz_extractor_handler $handler = null) { + ?tgz_extractor_handler $handler = null) { global $CFG; $this->currentarchivepath = $archivepath; diff --git a/lib/filestorage/tgz_packer.php b/lib/filestorage/tgz_packer.php index 2d67ade7b10..833212ede2f 100644 --- a/lib/filestorage/tgz_packer.php +++ b/lib/filestorage/tgz_packer.php @@ -100,7 +100,7 @@ class tgz_packer extends file_packer { */ public function archive_to_storage(array $files, $contextid, $component, $filearea, $itemid, $filepath, $filename, - $userid = null, $ignoreinvalidfiles = true, file_progress $progress = null) { + $userid = null, $ignoreinvalidfiles = true, ?file_progress $progress = null) { global $CFG; // Set up a temporary location for the file. @@ -167,7 +167,7 @@ class tgz_packer extends file_packer { * @throws coding_exception If any archive paths do not meet the restrictions */ public function archive_to_pathname(array $files, $archivefile, - $ignoreinvalidfiles=true, file_progress $progress = null) { + $ignoreinvalidfiles=true, ?file_progress $progress = null) { // Open .gz file. if (!($gz = gzopen($archivefile, 'wb'))) { return false; @@ -327,7 +327,7 @@ class tgz_packer extends file_packer { * @throws coding_exception If names aren't valid */ protected function write_tar_entry($gz, $archivepath, $file, $size, $mtime, $content = null, - file_progress $progress = null, $done = 0) { + ?file_progress $progress = null, $done = 0) { // Header based on documentation of POSIX ustar format from: // http://www.freebsd.org/cgi/man.cgi?query=tar&sektion=5&manpath=FreeBSD+8-current . @@ -641,7 +641,7 @@ class tgz_packer extends file_packer { * @throws moodle_exception If error */ public function extract_to_pathname($archivefile, $pathname, - array $onlyfiles = null, file_progress $progress = null, $returnbool = false) { + ?array $onlyfiles = null, ?file_progress $progress = null, $returnbool = false) { $extractor = new tgz_extractor($archivefile); try { $result = $extractor->extract( @@ -684,7 +684,7 @@ class tgz_packer extends file_packer { */ public function extract_to_storage($archivefile, $contextid, $component, $filearea, $itemid, $pathbase, $userid = null, - file_progress $progress = null) { + ?file_progress $progress = null) { $extractor = new tgz_extractor($archivefile); return $extractor->extract( new tgz_packer_extract_to_storage($contextid, $component, @@ -752,7 +752,7 @@ class tgz_packer_extract_to_pathname implements tgz_extractor_handler { * @param string $pathname target directory * @param array $onlyfiles only extract files present in the array */ - public function __construct($pathname, array $onlyfiles = null) { + public function __construct($pathname, ?array $onlyfiles = null) { $this->pathname = $pathname; $this->onlyfiles = $onlyfiles; } diff --git a/lib/filestorage/zip_packer.php b/lib/filestorage/zip_packer.php index 39cedfda4ae..4a29bff04af 100644 --- a/lib/filestorage/zip_packer.php +++ b/lib/filestorage/zip_packer.php @@ -55,7 +55,7 @@ class zip_packer extends file_packer { */ public function archive_to_storage(array $files, $contextid, $component, $filearea, $itemid, $filepath, $filename, - $userid = NULL, $ignoreinvalidfiles=true, file_progress $progress = null) { + $userid = NULL, $ignoreinvalidfiles=true, ?file_progress $progress = null) { global $CFG; $fs = get_file_storage(); @@ -96,7 +96,7 @@ class zip_packer extends file_packer { * @return bool true if file created, false if not */ public function archive_to_pathname(array $files, $archivefile, - $ignoreinvalidfiles=true, file_progress $progress = null) { + $ignoreinvalidfiles=true, ?file_progress $progress = null) { $ziparch = new zip_archive(); if (!$ziparch->open($archivefile, file_archive::OVERWRITE)) { return false; @@ -173,7 +173,7 @@ class zip_packer extends file_packer { * @param file_progress $progress Progress indicator callback or null if not required * @return bool success */ - private function archive_stored($ziparch, $archivepath, $file, file_progress $progress = null) { + private function archive_stored($ziparch, $archivepath, $file, ?file_progress $progress = null) { $result = $file->archive_file($ziparch, $archivepath); if (!$result) { return false; @@ -216,7 +216,7 @@ class zip_packer extends file_packer { * @return bool success */ private function archive_pathname($ziparch, $archivepath, $file, - file_progress $progress = null) { + ?file_progress $progress = null) { // Record progress each time this function is called. if ($progress) { $progress->progress(); @@ -263,7 +263,7 @@ class zip_packer extends file_packer { * @return bool|array list of processed files; false if error */ public function extract_to_pathname($archivefile, $pathname, - array $onlyfiles = null, file_progress $progress = null, $returnbool = false) { + ?array $onlyfiles = null, ?file_progress $progress = null, $returnbool = false) { global $CFG; if (!is_string($archivefile)) { @@ -424,7 +424,7 @@ class zip_packer extends file_packer { */ public function extract_to_storage($archivefile, $contextid, $component, $filearea, $itemid, $pathbase, $userid = NULL, - file_progress $progress = null) { + ?file_progress $progress = null) { global $CFG; if (!is_string($archivefile)) { diff --git a/lib/form/choicedropdown.php b/lib/form/choicedropdown.php index e01a752ac65..b93871b1f67 100644 --- a/lib/form/choicedropdown.php +++ b/lib/form/choicedropdown.php @@ -72,7 +72,7 @@ class MoodleQuickForm_choicedropdown extends HTML_QuickForm_select implements te public function __construct( $elementname = null, $elementlabel = null, - choicelist $options = null, + ?choicelist $options = null, $attributes = null ) { parent::__construct($elementname, $elementlabel, $options, $attributes); diff --git a/lib/formslib.php b/lib/formslib.php index 30f291d659a..7cde8fab751 100644 --- a/lib/formslib.php +++ b/lib/formslib.php @@ -1428,7 +1428,7 @@ abstract class moodleform { * @param array $strings strings for javascript * @deprecated since Moodle 3.3 MDL-57471 */ - function init_javascript_enhancement($element, $enhancement, array $options=array(), array $strings=null) { + function init_javascript_enhancement($element, $enhancement, array $options=array(), ?array $strings=null) { debugging('$mform->init_javascript_enhancement() is deprecated and no longer does anything. '. 'smartselect uses should be converted to the searchableselector form element.', DEBUG_DEVELOPER); } diff --git a/lib/grade/grade_grade.php b/lib/grade/grade_grade.php index d4ba86d0941..46adfbfc972 100644 --- a/lib/grade/grade_grade.php +++ b/lib/grade/grade_grade.php @@ -1081,7 +1081,7 @@ class grade_grade extends grade_object { * * @param int|null $historyid */ - protected function add_feedback_files(int $historyid = null) { + protected function add_feedback_files(?int $historyid = null) { global $CFG; // We only support feedback files for modules atm. @@ -1102,7 +1102,7 @@ class grade_grade extends grade_object { * * @param int|null $historyid */ - protected function update_feedback_files(int $historyid = null) { + protected function update_feedback_files(?int $historyid = null) { global $CFG; // We only support feedback files for modules atm. diff --git a/lib/grade/grade_item.php b/lib/grade/grade_item.php index a1fd071b373..60660858426 100644 --- a/lib/grade/grade_item.php +++ b/lib/grade/grade_item.php @@ -778,7 +778,7 @@ class grade_item extends grade_object { * @param string $groupwheresql Where conditions for $groupsql * @return int The number of hidden grades */ - public function has_hidden_grades($groupsql="", array $params=null, $groupwheresql="") { + public function has_hidden_grades($groupsql="", ?array $params=null, $groupwheresql="") { global $DB; $params = (array)$params; $params['itemid'] = $this->id; diff --git a/lib/grade/grade_object.php b/lib/grade/grade_object.php index 2378a738f9c..a3ba70df7e4 100644 --- a/lib/grade/grade_object.php +++ b/lib/grade/grade_object.php @@ -429,7 +429,7 @@ abstract class grade_object { * * @param int|null $historyid */ - protected function add_feedback_files(int $historyid = null) { + protected function add_feedback_files(?int $historyid = null) { } /** @@ -437,7 +437,7 @@ abstract class grade_object { * * @param int|null $historyid */ - protected function update_feedback_files(int $historyid = null) { + protected function update_feedback_files(?int $historyid = null) { } /** diff --git a/lib/gradelib.php b/lib/gradelib.php index a0e444744d1..eeb2212344a 100644 --- a/lib/gradelib.php +++ b/lib/gradelib.php @@ -382,7 +382,7 @@ function grade_needs_regrade_progress_bar($courseid) { * @param callable $callback A function to call if regrading took place * @return moodle_url|false The URL to redirect to if redirecting */ -function grade_regrade_final_grades_if_required($course, callable $callback = null) { +function grade_regrade_final_grades_if_required($course, ?callable $callback = null) { global $PAGE, $OUTPUT; if (!grade_needs_regrade_final_grades($course->id)) { diff --git a/lib/grouplib.php b/lib/grouplib.php index 40c4bcc102f..730887178d3 100644 --- a/lib/grouplib.php +++ b/lib/grouplib.php @@ -1194,7 +1194,7 @@ function groups_group_visible($groupid, $course, $cm = null, $userid = null) { * @return array($sql, $params) * @throws coding_exception if empty or invalid context submitted when $groupid = USERSWITHOUTGROUP */ -function groups_get_members_ids_sql($groupids, context $context = null, $groupsjointype = GROUPS_JOIN_ANY) { +function groups_get_members_ids_sql($groupids, ?context $context = null, $groupsjointype = GROUPS_JOIN_ANY) { if (!is_array($groupids)) { $groupids = [$groupids]; } @@ -1254,7 +1254,7 @@ function groups_get_names_concat_sql(int $courseid, string $separator = ', '): a * @return \core\dml\sql_join Contains joins, wheres, params * @throws coding_exception if empty or invalid context submitted when $groupid = USERSWITHOUTGROUP */ -function groups_get_members_join($groupids, $useridcolumn, context $context = null, int $jointype = GROUPS_JOIN_ANY) { +function groups_get_members_join($groupids, $useridcolumn, ?context $context = null, int $jointype = GROUPS_JOIN_ANY) { global $DB; // Use unique prefix just in case somebody makes some SQL magic with the result. @@ -1474,7 +1474,7 @@ function _group_verify_activegroup($courseid, $groupmode, $groupingid, array $al * @param cache $cache The cache if it has already been initialised. If not a new one will be created. * @return stdClass A data object containing groups, groupings, and mappings. */ -function groups_cache_groupdata($courseid, cache $cache = null) { +function groups_cache_groupdata($courseid, ?cache $cache = null) { global $DB; if ($cache === null) { @@ -1531,7 +1531,7 @@ function groups_cache_groupdata($courseid, cache $cache = null) { * @param cache $cache The cache if it has already been initialised. If not a new one will be created. * @return stdClass */ -function groups_get_course_data($courseid, cache $cache = null) { +function groups_get_course_data($courseid, ?cache $cache = null) { if ($cache === null) { // Initialise a cache if we wern't given one. $cache = cache::make('core', 'groupdata'); diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 9bd47351651..b16374b38f9 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -4733,7 +4733,7 @@ function delete_course($courseorid, $showfeedback = true) { * method returns false, some of the removals will probably have succeeded, and others * failed, but you have no way of knowing which. */ -function remove_course_contents($courseid, $showfeedback = true, array $options = null) { +function remove_course_contents($courseid, $showfeedback = true, ?array $options = null) { global $CFG, $DB, $OUTPUT; require_once($CFG->libdir.'/badgeslib.php'); diff --git a/lib/navigationlib.php b/lib/navigationlib.php index 24a175bb321..39854f4b092 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -338,7 +338,7 @@ class navigation_node implements renderable { * @return navigation_node */ public static function create($text, $action=null, $type=self::TYPE_CUSTOM, - $shorttext=null, $key=null, pix_icon $icon=null) { + $shorttext=null, $key=null, ?pix_icon $icon=null) { if ($action && !($action instanceof moodle_url || $action instanceof action_link)) { debugging( "It is required that the action provided be either an action_url|moodle_url." . @@ -378,7 +378,7 @@ class navigation_node implements renderable { * @param pix_icon $icon * @return navigation_node */ - public function add($text, $action=null, $type=self::TYPE_CUSTOM, $shorttext=null, $key=null, pix_icon $icon=null) { + public function add($text, $action=null, $type=self::TYPE_CUSTOM, $shorttext=null, $key=null, ?pix_icon $icon=null) { if ($action && is_string($action)) { $action = new moodle_url($action); } @@ -884,7 +884,7 @@ class navigation_node implements renderable { * If an array is given then nodes will only be hidden if their type mtatches an element in the array. * e.g. array(navigation_node::TYPE_COURSE) would hide only course nodes. */ - public function hide(array $typestohide = null) { + public function hide(?array $typestohide = null) { if ($typestohide === null || in_array($this->type, $typestohide)) { $this->display = false; if ($this->has_children()) { @@ -3900,7 +3900,7 @@ class navbar extends navigation_node { * @param pix_icon $icon An optional icon to use for this node. * @return navigation_node */ - public function add($text, $action=null, $type=self::TYPE_CUSTOM, $shorttext=null, $key=null, pix_icon $icon=null) { + public function add($text, $action=null, $type=self::TYPE_CUSTOM, $shorttext=null, $key=null, ?pix_icon $icon=null) { if ($this->content !== null) { debugging('Nav bar items must be printed before $OUTPUT->header() has been called', DEBUG_DEVELOPER); } @@ -3946,7 +3946,7 @@ class navbar extends navigation_node { * @param pix_icon $icon An optional icon to use for this node. * @return navigation_node */ - public function prepend($text, $action=null, $type=self::TYPE_CUSTOM, $shorttext=null, $key=null, pix_icon $icon=null) { + public function prepend($text, $action=null, $type=self::TYPE_CUSTOM, $shorttext=null, $key=null, ?pix_icon $icon=null) { if ($this->content !== null) { debugging('Nav bar items must be printed before $OUTPUT->header() has been called', DEBUG_DEVELOPER); } @@ -4478,7 +4478,7 @@ class settings_navigation extends navigation_node { * @param pix_icon $icon An icon that appears next to the node. * @return navigation_node with the new node added to it. */ - public function add($text, $url=null, $type=null, $shorttext=null, $key=null, pix_icon $icon=null) { + public function add($text, $url=null, $type=null, $shorttext=null, $key=null, ?pix_icon $icon=null) { $node = parent::add($text, $url, $type, $shorttext, $key, $icon); $node->add_class('root_node'); return $node; @@ -4496,7 +4496,7 @@ class settings_navigation extends navigation_node { * @param pix_icon $icon An icon that appears next to the node. * @return navigation_node $node with the new node added to it. */ - public function prepend($text, $url=null, $type=null, $shorttext=null, $key=null, pix_icon $icon=null) { + public function prepend($text, $url=null, $type=null, $shorttext=null, $key=null, ?pix_icon $icon=null) { $children = $this->children; $childrenclass = get_class($children); $this->children = new $childrenclass; @@ -4541,7 +4541,7 @@ class settings_navigation extends navigation_node { * tree and start at the beginning * @return mixed A key to access the admin tree by */ - protected function load_administration_settings(navigation_node $referencebranch=null, part_of_admin_tree $adminbranch=null) { + protected function load_administration_settings(?navigation_node $referencebranch=null, ?part_of_admin_tree $adminbranch=null) { global $CFG; // Check if we are just starting to generate this navigation. diff --git a/lib/pagelib.php b/lib/pagelib.php index 1c4d0019509..384b3dcc6b9 100644 --- a/lib/pagelib.php +++ b/lib/pagelib.php @@ -1491,7 +1491,7 @@ class moodle_page { * @param array $params parameters to add to the URL * @throws coding_exception */ - public function set_url($url, array $params = null) { + public function set_url($url, ?array $params = null) { global $CFG; if (is_string($url) && strpos($url, 'http') !== 0) { diff --git a/lib/portfolio/formats.php b/lib/portfolio/formats.php index 7d64d67a557..afba3f3d173 100644 --- a/lib/portfolio/formats.php +++ b/lib/portfolio/formats.php @@ -493,7 +493,7 @@ class portfolio_format_leap2a extends portfolio_format_rich { * @param stdclass $user user information object * @return portfolio_format_leap2a_writer */ - public static function leap2a_writer(stdclass $user=null) { + public static function leap2a_writer(?stdclass $user=null) { global $CFG; if (empty($user)) { global $USER; diff --git a/lib/questionlib.php b/lib/questionlib.php index 89c274e95cf..e59d5e37383 100644 --- a/lib/questionlib.php +++ b/lib/questionlib.php @@ -939,7 +939,7 @@ function question_load_questions($questionids, $extrafields = '', $join = '') { * @param \core_tag_tag[]|null $tagobjects The tags for the given $question. * @param stdClass[]|null $filtercourses The courses to filter the course tags by. */ -function _tidy_question($question, $category, array $tagobjects = null, array $filtercourses = null): void { +function _tidy_question($question, $category, ?array $tagobjects = null, ?array $filtercourses = null): void { // Convert numeric fields to float. This prevents these being displayed as 1.0000000. $question->defaultmark += 0; $question->penalty += 0; @@ -1692,7 +1692,7 @@ function question_get_all_capabilities(): array { * @return string */ function question_rewrite_question_urls($text, $file, $contextid, $component, $filearea, - array $ids, $itemid, array $options=null): string { + array $ids, $itemid, ?array $options=null): string { $idsstr = ''; if (!empty($ids)) { diff --git a/lib/testing/classes/util.php b/lib/testing/classes/util.php index 5315c77c94b..85360550ca0 100644 --- a/lib/testing/classes/util.php +++ b/lib/testing/classes/util.php @@ -448,7 +448,7 @@ abstract class testing_util { * @param array $empties tables that are known to be unmodified and empty * @return void */ - public static function reset_all_database_sequences(array $empties = null) { + public static function reset_all_database_sequences(?array $empties = null) { global $DB; if (!$data = self::get_tabledata()) { diff --git a/lib/testing/generator/data_generator.php b/lib/testing/generator/data_generator.php index f2faf210967..54293d0a508 100644 --- a/lib/testing/generator/data_generator.php +++ b/lib/testing/generator/data_generator.php @@ -143,7 +143,7 @@ EOD; * @param array $options * @return stdClass user record */ - public function create_user($record=null, array $options=null) { + public function create_user($record=null, ?array $options=null) { global $DB, $CFG; require_once($CFG->dirroot.'/user/lib.php'); @@ -277,7 +277,7 @@ EOD; * @param array $options * @return core_course_category course category record */ - public function create_category($record=null, array $options=null) { + public function create_category($record=null, ?array $options=null) { $this->categorycount++; $i = $this->categorycount; @@ -304,7 +304,7 @@ EOD; * @param array $options * @return stdClass cohort record */ - public function create_cohort($record=null, array $options=null) { + public function create_cohort($record=null, ?array $options=null) { global $DB, $CFG; require_once("$CFG->dirroot/cohort/lib.php"); @@ -354,7 +354,7 @@ EOD; * 'createsections' => bool precreate all sections * @return stdClass course record */ - public function create_course($record=null, array $options=null) { + public function create_course($record=null, ?array $options=null) { global $DB, $CFG; require_once("$CFG->dirroot/course/lib.php"); @@ -461,7 +461,7 @@ EOD; * @return section_info * @throws coding_exception */ - public function create_course_section($record = null, array $options = null) { + public function create_course_section($record = null, ?array $options = null) { global $DB; $record = (array)$record; @@ -519,7 +519,7 @@ EOD; * @return stdClass activity record new new record that was just inserted in the table * like 'forum' or 'quiz', with a ->cmid field added. */ - public function create_module($modulename, $record=null, array $options=null) { + public function create_module($modulename, $record=null, ?array $options=null) { $generator = $this->get_plugin_generator('mod_'.$modulename); return $generator->create_instance($record, $options); } @@ -694,7 +694,7 @@ EOD; * @return stdClass repository instance record * @since Moodle 2.5.1 */ - public function create_repository($type, $record=null, array $options = null) { + public function create_repository($type, $record=null, ?array $options = null) { $generator = $this->get_plugin_generator('repository_'.$type); return $generator->create_instance($record, $options); } @@ -708,7 +708,7 @@ EOD; * @return repository_type object * @since Moodle 2.5.1 */ - public function create_repository_type($type, $record=null, array $options = null) { + public function create_repository_type($type, $record=null, ?array $options = null) { $generator = $this->get_plugin_generator('repository_'.$type); return $generator->create_type($record, $options); } @@ -720,7 +720,7 @@ EOD; * @param array $options * @return stdClass block instance record */ - public function create_scale($record=null, array $options=null) { + public function create_scale($record=null, ?array $options=null) { global $DB; $this->scalecount++; @@ -896,7 +896,7 @@ EOD; * @param array $rolecapabilities The list of capability =>permission to set for this role * @param null|context $context The context to apply this capability to */ - public function create_role_capability(int $roleid, array $rolecapabilities, context $context = null): void { + public function create_role_capability(int $roleid, array $rolecapabilities, ?context $context = null): void { // Map the capabilities into human-readable names. $allpermissions = [ 'inherit' => CAP_INHERIT, diff --git a/lib/testing/generator/module_generator.php b/lib/testing/generator/module_generator.php index a4913e7f180..12fcc425f51 100644 --- a/lib/testing/generator/module_generator.php +++ b/lib/testing/generator/module_generator.php @@ -223,7 +223,7 @@ abstract class testing_module_generator extends component_generator_base { * @return stdClass record from module-defined table with additional field * cmid (corresponding id in course_modules table) */ - public function create_instance($record = null, array $options = null) { + public function create_instance($record = null, ?array $options = null) { global $CFG, $DB, $PAGE; require_once($CFG->dirroot.'/course/modlib.php'); diff --git a/lib/testing/generator/repository_generator.php b/lib/testing/generator/repository_generator.php index 21a40663a23..505c07df26f 100644 --- a/lib/testing/generator/repository_generator.php +++ b/lib/testing/generator/repository_generator.php @@ -110,7 +110,7 @@ class testing_repository_generator extends component_generator_base { * @param array $options * @return stdClass repository instance record */ - public function create_instance($record = null, array $options = null) { + public function create_instance($record = null, ?array $options = null) { global $CFG, $DB, $PAGE; require_once($CFG->dirroot . '/repository/lib.php'); @@ -173,7 +173,7 @@ class testing_repository_generator extends component_generator_base { * * @return stdClass repository type record */ - public function create_type($record = null, array $options = null) { + public function create_type($record = null, ?array $options = null) { global $CFG, $DB; require_once($CFG->dirroot . '/repository/lib.php'); diff --git a/lib/tests/behat/behat_navigation.php b/lib/tests/behat/behat_navigation.php index 4050304a66d..12f7360b67f 100644 --- a/lib/tests/behat/behat_navigation.php +++ b/lib/tests/behat/behat_navigation.php @@ -1535,8 +1535,8 @@ class behat_navigation extends behat_base { string $item, bool $not, string $dropdown, - string $container = null, - string $containertype = null, + ?string $container = null, + ?string $containertype = null, ): void { $containernode = null; if ($container && $containertype) { diff --git a/lib/tests/navigationlib_test.php b/lib/tests/navigationlib_test.php index 76c45426d3e..e7f63bca581 100644 --- a/lib/tests/navigationlib_test.php +++ b/lib/tests/navigationlib_test.php @@ -721,7 +721,7 @@ class navigationlib_test extends \advanced_testcase { */ class exposed_global_navigation extends global_navigation { protected $exposedkey = 'exposed_'; - public function __construct(\moodle_page $page=null) { + public function __construct(?\moodle_page $page=null) { global $PAGE; if ($page === null) { $page = $PAGE; diff --git a/lib/userkey/classes/privacy/provider.php b/lib/userkey/classes/privacy/provider.php index f8ab5ddfcb9..5da4e64badc 100644 --- a/lib/userkey/classes/privacy/provider.php +++ b/lib/userkey/classes/privacy/provider.php @@ -74,7 +74,7 @@ class provider implements * @param int $instance The instance ID. */ public static function get_user_contexts_with_script(userlist $userlist, \context $context, string $script, - int $instance = null) { + ?int $instance = null) { if (!$context instanceof \context_user) { return; } diff --git a/lib/xapi/classes/iri.php b/lib/xapi/classes/iri.php index c635d0717fe..b14c09d9611 100644 --- a/lib/xapi/classes/iri.php +++ b/lib/xapi/classes/iri.php @@ -48,7 +48,7 @@ class iri { * @param string|null $type if none passed $type will be 'element' * @return string a valid IRI value */ - public static function generate(string $value, string $type = null): string { + public static function generate(string $value, ?string $type = null): string { if (self::check($value)) { return $value; } @@ -69,7 +69,7 @@ class iri { * @param string|null $type if $value is a fake IRI, the $type must be provided. * @return string the original value used in iri::generate. */ - public static function extract(string $value, string $type = null): string { + public static function extract(string $value, ?string $type = null): string { if (empty($type)) { $type = 'element'; } diff --git a/lib/xapi/classes/local/statement/item_activity.php b/lib/xapi/classes/local/statement/item_activity.php index 2ee8c1a8e4e..360f2dc1e75 100644 --- a/lib/xapi/classes/local/statement/item_activity.php +++ b/lib/xapi/classes/local/statement/item_activity.php @@ -52,7 +52,7 @@ class item_activity extends item_object { * @param stdClass $data from the specific xAPI element * @param item_definition $definition option definition item */ - protected function __construct(stdClass $data, item_definition $definition = null) { + protected function __construct(stdClass $data, ?item_definition $definition = null) { parent::__construct($data); $this->id = iri::extract($data->id, 'activity'); $this->definition = $definition; @@ -93,7 +93,7 @@ class item_activity extends item_object { * @param item_definition|null $definition optional item_definition * @return item_activity */ - public static function create_from_id(string $id, item_definition $definition = null): item_activity { + public static function create_from_id(string $id, ?item_definition $definition = null): item_activity { $data = (object) [ 'objectType' => 'Activity', 'id' => iri::generate($id, 'activity'), diff --git a/lib/xapi/classes/local/statement/item_result.php b/lib/xapi/classes/local/statement/item_result.php index 31361039c8f..aa4e42e8bc2 100644 --- a/lib/xapi/classes/local/statement/item_result.php +++ b/lib/xapi/classes/local/statement/item_result.php @@ -50,7 +50,7 @@ class item_result extends item { * @param int $duration duration in seconds * @param item_score $score the provided score */ - protected function __construct(stdClass $data, int $duration = null, item_score $score = null) { + protected function __construct(stdClass $data, ?int $duration = null, ?item_score $score = null) { parent::__construct($data); $this->duration = $duration; $this->score = $score; diff --git a/lib/xapi/tests/iri_test.php b/lib/xapi/tests/iri_test.php index bb90d070872..c274e3aa6ed 100644 --- a/lib/xapi/tests/iri_test.php +++ b/lib/xapi/tests/iri_test.php @@ -53,7 +53,7 @@ class iri_test extends advanced_testcase { * @param string $expected Expected result * @param string $type = null If some special type is provided */ - public function test_generate(string $value, string $expected, string $type = null): void { + public function test_generate(string $value, string $expected, ?string $type = null): void { $iri = iri::generate($value, $type); $this->assertEquals($iri, $expected); } @@ -66,7 +66,7 @@ class iri_test extends advanced_testcase { * @param string $value Value to generate IRI * @param string $type = null If some special type is provided */ - public function test_extract(string $expected, string $value, string $type = null): void { + public function test_extract(string $expected, string $value, ?string $type = null): void { $extract = iri::extract($value, $type); $this->assertEquals($extract, $expected); } diff --git a/lib/xmldb/xmldb_field.php b/lib/xmldb/xmldb_field.php index a86163bc3fc..b051eb4ca9d 100644 --- a/lib/xmldb/xmldb_field.php +++ b/lib/xmldb/xmldb_field.php @@ -760,7 +760,7 @@ class xmldb_field extends xmldb_object { * @param xmldb_table $xmldb_table optional when object is table * @return string null if ok, error message if problem found */ - public function validateDefinition(xmldb_table $xmldb_table=null) { + public function validateDefinition(?xmldb_table $xmldb_table=null) { if (!$xmldb_table) { return 'Invalid xmldb_field->validateDefinition() call, $xmldb_table is required.'; } diff --git a/lib/xmldb/xmldb_index.php b/lib/xmldb/xmldb_index.php index 071aa5df17c..431b38c7d60 100644 --- a/lib/xmldb/xmldb_index.php +++ b/lib/xmldb/xmldb_index.php @@ -336,7 +336,7 @@ class xmldb_index extends xmldb_object { * @param xmldb_table $xmldb_table optional when object is table * @return string null if ok, error message if problem found */ - public function validateDefinition(xmldb_table $xmldb_table=null) { + public function validateDefinition(?xmldb_table $xmldb_table=null) { if (!$xmldb_table) { return 'Invalid xmldb_index->validateDefinition() call, $xmldb_table is required.'; } diff --git a/lib/xmldb/xmldb_object.php b/lib/xmldb/xmldb_object.php index 09a311af080..bfc3316df84 100644 --- a/lib/xmldb/xmldb_object.php +++ b/lib/xmldb/xmldb_object.php @@ -416,7 +416,7 @@ class xmldb_object { * @param xmldb_table $xmldb_table optional when object is table * @return string null if ok, error message if problem found */ - public function validateDefinition(xmldb_table $xmldb_table=null) { + public function validateDefinition(?xmldb_table $xmldb_table=null) { return null; } } diff --git a/lib/xmldb/xmldb_table.php b/lib/xmldb/xmldb_table.php index 5c78f14034b..5cac466e775 100644 --- a/lib/xmldb/xmldb_table.php +++ b/lib/xmldb/xmldb_table.php @@ -713,7 +713,7 @@ class xmldb_table extends xmldb_object { * @param xmldb_table $xmldb_table optional when object is table * @return string null if ok, error message if problem found */ - public function validateDefinition(xmldb_table $xmldb_table=null) { + public function validateDefinition(?xmldb_table $xmldb_table=null) { // table parameter is ignored $name = $this->getName(); if (strlen($name) > self::NAME_MAX_LENGTH) { diff --git a/message/classes/api.php b/message/classes/api.php index 5ba3e7a1ee1..8ee6246638e 100644 --- a/message/classes/api.php +++ b/message/classes/api.php @@ -469,8 +469,8 @@ class api { * @return array the array of conversations * @throws \moodle_exception */ - public static function get_conversations($userid, $limitfrom = 0, $limitnum = 20, int $type = null, - bool $favourites = null, bool $mergeself = false) { + public static function get_conversations($userid, $limitfrom = 0, $limitnum = 20, ?int $type = null, + ?bool $favourites = null, bool $mergeself = false) { global $DB; if (!is_null($type) && !in_array($type, [self::MESSAGE_CONVERSATION_TYPE_INDIVIDUAL, @@ -1168,7 +1168,7 @@ class api { * @param int $conversationid The id of the conversation * @return bool Returns true if a user can delete the conversation, false otherwise. */ - public static function can_delete_conversation(int $userid, int $conversationid = null): bool { + public static function can_delete_conversation(int $userid, ?int $conversationid = null): bool { global $USER; if (is_null($conversationid)) { @@ -2089,9 +2089,9 @@ class api { * @param int|null $contextid The id of the context * @return \stdClass */ - public static function create_conversation(int $type, array $userids, string $name = null, - int $enabled = self::MESSAGE_CONVERSATION_ENABLED, string $component = null, - string $itemtype = null, int $itemid = null, int $contextid = null) { + public static function create_conversation(int $type, array $userids, ?string $name = null, + int $enabled = self::MESSAGE_CONVERSATION_ENABLED, ?string $component = null, + ?string $itemtype = null, ?int $itemid = null, ?int $contextid = null) { global $DB; diff --git a/message/classes/helper.php b/message/classes/helper.php index e3e1043eee2..4db082da2aa 100644 --- a/message/classes/helper.php +++ b/message/classes/helper.php @@ -552,9 +552,9 @@ class helper { */ public static function render_messaging_widget( bool $isdrawer, - int $sendtouser = null, - int $conversationid = null, - string $view = null + ?int $sendtouser = null, + ?int $conversationid = null, + ?string $view = null ) { global $USER, $CFG, $PAGE; diff --git a/message/classes/search/message_received.php b/message/classes/search/message_received.php index 052d6bde907..4cd25069f9a 100644 --- a/message/classes/search/message_received.php +++ b/message/classes/search/message_received.php @@ -42,7 +42,7 @@ class message_received extends base_message { * @param \context|null $context Optional context to restrict scope of returned results * @return moodle_recordset|null Recordset (or null if no results) */ - public function get_document_recordset($modifiedfrom = 0, \context $context = null) { + public function get_document_recordset($modifiedfrom = 0, ?\context $context = null) { return $this->get_document_recordset_helper($modifiedfrom, $context, 'useridto'); } diff --git a/message/classes/search/message_sent.php b/message/classes/search/message_sent.php index 79dc0bdb4f1..7635bc96c8b 100644 --- a/message/classes/search/message_sent.php +++ b/message/classes/search/message_sent.php @@ -41,7 +41,7 @@ class message_sent extends base_message { * @param \context|null $context Optional context to restrict scope of returned results * @return moodle_recordset|null Recordset (or null if no results) */ - public function get_document_recordset($modifiedfrom = 0, \context $context = null) { + public function get_document_recordset($modifiedfrom = 0, ?\context $context = null) { return $this->get_document_recordset_helper($modifiedfrom, $context, 'useridfrom'); } diff --git a/message/classes/tests/helper.php b/message/classes/tests/helper.php index c89634b56a5..e449e9f155f 100644 --- a/message/classes/tests/helper.php +++ b/message/classes/tests/helper.php @@ -118,7 +118,7 @@ class helper { * @throws \dml_exception if the conversation doesn't exist. */ public static function send_fake_message_to_conversation(\stdClass $userfrom, int $convid, string $message = 'Hello world!', - int $time = null): int { + ?int $time = null): int { global $DB; $conversationrec = $DB->get_record('message_conversations', ['id' => $convid], 'id', MUST_EXIST); $conversationid = $conversationrec->id; diff --git a/message/externallib.php b/message/externallib.php index 693a9df86b7..a9fe992719e 100644 --- a/message/externallib.php +++ b/message/externallib.php @@ -1333,7 +1333,7 @@ class core_message_external extends external_api { * @throws \moodle_exception if the messaging feature is disabled on the site. * @since 3.2 */ - public static function get_conversations($userid, $limitfrom = 0, $limitnum = 0, int $type = null, bool $favourites = null, + public static function get_conversations($userid, $limitfrom = 0, $limitnum = 0, ?int $type = null, ?bool $favourites = null, bool $mergeself = false) { global $CFG, $USER; diff --git a/message/output/airnotifier/classes/manager.php b/message/output/airnotifier/classes/manager.php index ed9adf5692c..1d6e4132d1c 100644 --- a/message/output/airnotifier/classes/manager.php +++ b/message/output/airnotifier/classes/manager.php @@ -402,7 +402,7 @@ class message_airnotifier_manager { * @param int $userid the user to check the devices for (empty for current user) * @return bool true when the user has enabled devices, false otherwise */ - public function has_enabled_devices(string $appname, int $userid = null): bool { + public function has_enabled_devices(string $appname, ?int $userid = null): bool { $enableddevices = false; $devices = $this->get_user_devices($appname, $userid); diff --git a/message/tests/privacy/provider_test.php b/message/tests/privacy/provider_test.php index 8f8cb4a6a7d..00f63d2f165 100644 --- a/message/tests/privacy/provider_test.php +++ b/message/tests/privacy/provider_test.php @@ -2833,7 +2833,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { * @return int The id of the message * @throws dml_exception */ - private function create_message(int $useridfrom, int $useridto, int $timecreated = null, bool $read = false) { + private function create_message(int $useridfrom, int $useridto, ?int $timecreated = null, bool $read = false) { global $DB; static $i = 1; @@ -2884,7 +2884,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { * @return int The id of the notification * @throws dml_exception */ - private function create_notification(int $useridfrom, int $useridto, int $timecreated = null, int $timeread = null) { + private function create_notification(int $useridfrom, int $useridto, ?int $timecreated = null, ?int $timeread = null) { global $DB; static $i = 1; diff --git a/mod/assign/classes/external/external_api.php b/mod/assign/classes/external/external_api.php index 1be7efd0f26..ff5555555aa 100644 --- a/mod/assign/classes/external/external_api.php +++ b/mod/assign/classes/external/external_api.php @@ -102,7 +102,7 @@ class external_api extends \core_external\external_api { * @param int $attemptnumber Attempt number. Use -1 for last attempt. * @return bool|\stdClass */ - protected static function get_user_or_group_submission(\assign $assignment, int $userid = null, + protected static function get_user_or_group_submission(\assign $assignment, ?int $userid = null, int $groupid = 0, bool $create = false, int $attemptnumber = -1) { if ($assignment->get_instance($userid)->teamsubmission) { $submission = $assignment->get_group_submission($userid, $groupid, $create, $attemptnumber); diff --git a/mod/assign/classes/output/assign_header.php b/mod/assign/classes/output/assign_header.php index 9fe74922f40..4d90f1344e3 100644 --- a/mod/assign/classes/output/assign_header.php +++ b/mod/assign/classes/output/assign_header.php @@ -71,7 +71,7 @@ class assign_header implements \renderable { $subpage = '', $preface = '', $postfix = '', - \moodle_url $subpageurl = null, + ?\moodle_url $subpageurl = null, bool $activity = false ) { $this->assign = $assign; diff --git a/mod/assign/classes/output/grading_actionmenu.php b/mod/assign/classes/output/grading_actionmenu.php index c574eeb6fbc..69d943484ce 100644 --- a/mod/assign/classes/output/grading_actionmenu.php +++ b/mod/assign/classes/output/grading_actionmenu.php @@ -60,7 +60,7 @@ class grading_actionmenu implements templatable, renderable { int $cmid, ?bool $submissionpluginenabled = null, ?int $submissioncount = null, - assign $assign = null + ?assign $assign = null ) { $this->cmid = $cmid; if (!$assign) { diff --git a/mod/assign/classes/output/user_submission_actionmenu.php b/mod/assign/classes/output/user_submission_actionmenu.php index 6cbfddc8617..d8a52a0e6b8 100644 --- a/mod/assign/classes/output/user_submission_actionmenu.php +++ b/mod/assign/classes/output/user_submission_actionmenu.php @@ -63,8 +63,8 @@ class user_submission_actionmenu implements templatable, renderable { * @param stdClass|null $teamsubmission A team submission for this activity. * @param int $timelimit The time limit for completing this activity. */ - public function __construct(int $cmid, bool $showsubmit, bool $showedit, stdClass $submission = null, - stdClass $teamsubmission = null, int $timelimit = 0) { + public function __construct(int $cmid, bool $showsubmit, bool $showedit, ?stdClass $submission = null, + ?stdClass $teamsubmission = null, int $timelimit = 0) { $this->cmid = $cmid; $this->showsubmit = $showsubmit; diff --git a/mod/assign/classes/privacy/assign_plugin_request_data.php b/mod/assign/classes/privacy/assign_plugin_request_data.php index f241e9db090..29a560e18d0 100644 --- a/mod/assign/classes/privacy/assign_plugin_request_data.php +++ b/mod/assign/classes/privacy/assign_plugin_request_data.php @@ -69,8 +69,8 @@ class assign_plugin_request_data { * @param \stdClass $user The user object. * @param \assign $assign The assign object. */ - public function __construct(\context $context, \assign $assign, \stdClass $pluginobject = null, array $subcontext = [], - \stdClass $user = null) { + public function __construct(\context $context, \assign $assign, ?\stdClass $pluginobject = null, array $subcontext = [], + ?\stdClass $user = null) { $this->context = $context; $this->pluginobject = $pluginobject; $this->subcontext = $subcontext; diff --git a/mod/assign/feedback/editpdf/classes/annotation.php b/mod/assign/feedback/editpdf/classes/annotation.php index 0bf90282a6d..0bfb899cd96 100644 --- a/mod/assign/feedback/editpdf/classes/annotation.php +++ b/mod/assign/feedback/editpdf/classes/annotation.php @@ -70,7 +70,7 @@ class annotation { * Convert a compatible stdClass into an instance of this class. * @param \stdClass $record */ - public function __construct(\stdClass $record = null) { + public function __construct(?\stdClass $record = null) { if ($record) { $intcols = array('endx', 'endy', 'x', 'y'); foreach ($this as $key => $value) { diff --git a/mod/assign/feedback/editpdf/classes/comment.php b/mod/assign/feedback/editpdf/classes/comment.php index 1495286e6ea..421a9d75d35 100644 --- a/mod/assign/feedback/editpdf/classes/comment.php +++ b/mod/assign/feedback/editpdf/classes/comment.php @@ -62,7 +62,7 @@ class comment { * Convert a compatible stdClass into an instance of a comment. * @param \stdClass $record */ - public function __construct(\stdClass $record = null) { + public function __construct(?\stdClass $record = null) { if ($record) { $intcols = array('width', 'x', 'y'); foreach ($this as $key => $value) { diff --git a/mod/assign/lib.php b/mod/assign/lib.php index 3976dbfeb9f..d047febdb8f 100644 --- a/mod/assign/lib.php +++ b/mod/assign/lib.php @@ -35,7 +35,7 @@ require_once(__DIR__ . '/deprecatedlib.php'); * @param mod_assign_mod_form $form * @return int The instance id of the new assignment */ -function assign_add_instance(stdClass $data, mod_assign_mod_form $form = null) { +function assign_add_instance(stdClass $data, ?mod_assign_mod_form $form = null) { global $CFG; require_once($CFG->dirroot . '/mod/assign/locallib.php'); diff --git a/mod/assign/locallib.php b/mod/assign/locallib.php index 760cf577e73..0c6d737badc 100644 --- a/mod/assign/locallib.php +++ b/mod/assign/locallib.php @@ -1813,7 +1813,7 @@ class assign { * @param int|null $userid the id of the user to load the assign instance for. * @return stdClass The settings */ - public function get_instance(int $userid = null): stdClass { + public function get_instance(?int $userid = null): stdClass { global $USER; $userid = $userid ?? $USER->id; diff --git a/mod/assign/renderable.php b/mod/assign/renderable.php index af8af552046..af3e25b3d5c 100644 --- a/mod/assign/renderable.php +++ b/mod/assign/renderable.php @@ -599,7 +599,7 @@ class assign_grading_summary implements renderable { $coursestartdate, $cangrade = true, $isvisible = true, - cm_info $cm = null) { + ?cm_info $cm = null) { $this->participantcount = $participantcount; $this->submissiondraftsenabled = $submissiondraftsenabled; $this->submissiondraftscount = $submissiondraftscount; diff --git a/mod/assign/tests/generator/lib.php b/mod/assign/tests/generator/lib.php index ca0e93b511d..137d0f7a824 100644 --- a/mod/assign/tests/generator/lib.php +++ b/mod/assign/tests/generator/lib.php @@ -36,7 +36,7 @@ class mod_assign_generator extends testing_module_generator { * @param array|null $options * @return stdClass */ - public function create_instance($record = null, array $options = null) { + public function create_instance($record = null, ?array $options = null) { $record = (object)(array)$record; $defaultsettings = [ diff --git a/mod/bigbluebuttonbn/classes/extension.php b/mod/bigbluebuttonbn/classes/extension.php index b17bcc12e59..dff3546f33f 100644 --- a/mod/bigbluebuttonbn/classes/extension.php +++ b/mod/bigbluebuttonbn/classes/extension.php @@ -146,7 +146,7 @@ class extension { * @return array of custom completion addon classes instances */ public static function mod_form_addons_instances(\MoodleQuickForm $mform, ?stdClass $bigbluebuttondata = null, - string $suffix = null): array { + ?string $suffix = null): array { return self::get_instances_implementing(mod_form_addons::class, [$mform, $bigbluebuttondata, $suffix]); } diff --git a/mod/bigbluebuttonbn/classes/external/update_recording.php b/mod/bigbluebuttonbn/classes/external/update_recording.php index 6ba0bc05a49..2281262515f 100644 --- a/mod/bigbluebuttonbn/classes/external/update_recording.php +++ b/mod/bigbluebuttonbn/classes/external/update_recording.php @@ -48,7 +48,7 @@ class update_recording extends external_api { int $bigbluebuttonbnid, int $recordingid, string $action, - string $additionaloptions = null + ?string $additionaloptions = null ): array { // Validate the bigbluebuttonbnid ID. [ diff --git a/mod/bigbluebuttonbn/classes/local/bigbluebutton/recordings/recording_data.php b/mod/bigbluebuttonbn/classes/local/bigbluebutton/recordings/recording_data.php index 0fa9e437f46..e0b72590f8a 100644 --- a/mod/bigbluebuttonbn/classes/local/bigbluebutton/recordings/recording_data.php +++ b/mod/bigbluebuttonbn/classes/local/bigbluebutton/recordings/recording_data.php @@ -48,7 +48,7 @@ class recording_data { * @param int $courseid * @return array */ - public static function get_recording_table(array $recordings, array $tools, instance $instance = null, + public static function get_recording_table(array $recordings, array $tools, ?instance $instance = null, int $courseid = 0): array { $typeprofiles = bigbluebutton_proxy::get_instance_type_profiles(); $typeprofile = empty($instance) ? $typeprofiles[0] : $typeprofiles[$instance->get_type()]; diff --git a/mod/bigbluebuttonbn/classes/local/extension/mod_form_addons.php b/mod/bigbluebuttonbn/classes/local/extension/mod_form_addons.php index 510e6fb3ce1..ba8e3308906 100644 --- a/mod/bigbluebuttonbn/classes/local/extension/mod_form_addons.php +++ b/mod/bigbluebuttonbn/classes/local/extension/mod_form_addons.php @@ -48,7 +48,7 @@ abstract class mod_form_addons { * @param stdClass|null $bigbluebuttonbndata * @param string|null $suffix */ - public function __construct(\MoodleQuickForm &$mform, ?stdClass $bigbluebuttonbndata = null, string $suffix = null) { + public function __construct(\MoodleQuickForm &$mform, ?stdClass $bigbluebuttonbndata = null, ?string $suffix = null) { $this->mform = $mform; $this->bigbluebuttonbndata = $bigbluebuttonbndata; $this->suffix = $suffix; diff --git a/mod/bigbluebuttonbn/classes/local/helpers/roles.php b/mod/bigbluebuttonbn/classes/local/helpers/roles.php index 36c598e9a9a..5f0ce97f399 100644 --- a/mod/bigbluebuttonbn/classes/local/helpers/roles.php +++ b/mod/bigbluebuttonbn/classes/local/helpers/roles.php @@ -161,7 +161,7 @@ class roles { * * @return array $users */ - protected static function get_roles_select(context $context = null, bool $onlyviewableroles = true) { + protected static function get_roles_select(?context $context = null, bool $onlyviewableroles = true) { global $CFG; if ($onlyviewableroles == true && $CFG->branch >= 35) { diff --git a/mod/bigbluebuttonbn/classes/local/proxy/bigbluebutton_proxy.php b/mod/bigbluebuttonbn/classes/local/proxy/bigbluebutton_proxy.php index c0c0a8c0879..ed1b263d494 100644 --- a/mod/bigbluebuttonbn/classes/local/proxy/bigbluebutton_proxy.php +++ b/mod/bigbluebuttonbn/classes/local/proxy/bigbluebutton_proxy.php @@ -94,7 +94,7 @@ class bigbluebutton_proxy extends proxy_base { private static function internal_get_join_url( instance $instance, ?string $jointime, - string $userfullname = null, + ?string $userfullname = null, bool $isguestjoin = false ): string { $data = [ diff --git a/mod/bigbluebuttonbn/classes/recording.php b/mod/bigbluebuttonbn/classes/recording.php index d0565a82426..4314f6b44f4 100644 --- a/mod/bigbluebuttonbn/classes/recording.php +++ b/mod/bigbluebuttonbn/classes/recording.php @@ -91,7 +91,7 @@ class recording extends persistent { * @param stdClass|null $record If set will be passed to from_record * @param null|array $metadata */ - public function __construct($id = 0, stdClass $record = null, ?array $metadata = null) { + public function __construct($id = 0, ?stdClass $record = null, ?array $metadata = null) { if ($record) { $record->headless = $record->headless ?? false; $record->imported = $record->imported ?? false; diff --git a/mod/bigbluebuttonbn/classes/search/tags.php b/mod/bigbluebuttonbn/classes/search/tags.php index 79d749d9b65..fc132ac0def 100644 --- a/mod/bigbluebuttonbn/classes/search/tags.php +++ b/mod/bigbluebuttonbn/classes/search/tags.php @@ -45,7 +45,7 @@ class tags extends \core_search\base_activity { * @param \context|null $context * @return \moodle_recordset|null */ - public function get_document_recordset($modifiedfrom = 0, \context $context = null) { + public function get_document_recordset($modifiedfrom = 0, ?\context $context = null) { global $DB; [$contextjoin, $contextparams] = $this->get_context_restriction_sql($context, $this->get_module_name(), 'modtable'); if ($contextjoin === null) { diff --git a/mod/bigbluebuttonbn/tests/generator/lib.php b/mod/bigbluebuttonbn/tests/generator/lib.php index 81e46caa11a..3c385b6f503 100644 --- a/mod/bigbluebuttonbn/tests/generator/lib.php +++ b/mod/bigbluebuttonbn/tests/generator/lib.php @@ -48,7 +48,7 @@ class mod_bigbluebuttonbn_generator extends \testing_module_generator { * @param null|array $options general options for course module. * @return stdClass record from module-defined table with additional field cmid */ - public function create_instance($record = null, array $options = null) { + public function create_instance($record = null, ?array $options = null) { // Prior to creating the instance, make sure that the BigBlueButton module is enabled. $modules = \core_plugin_manager::instance()->get_plugins_of_type('mod'); if (!$modules['bigbluebuttonbn']->is_enabled()) { @@ -375,7 +375,7 @@ class mod_bigbluebuttonbn_generator extends \testing_module_generator { * @param mixed $record * @param array|null $options */ - public function create_log($record, array $options = null) { + public function create_log($record, ?array $options = null) { $instance = instance::get_from_instanceid($record['bigbluebuttonbnid']); $record = array_merge([ diff --git a/mod/bigbluebuttonbn/tests/output/recording_row_playback_test.php b/mod/bigbluebuttonbn/tests/output/recording_row_playback_test.php index 2c859d778ec..194dcc3adce 100644 --- a/mod/bigbluebuttonbn/tests/output/recording_row_playback_test.php +++ b/mod/bigbluebuttonbn/tests/output/recording_row_playback_test.php @@ -95,7 +95,7 @@ class recording_row_playback_test extends \advanced_testcase { * @covers \recording_row_playback::should_be_included * @dataProvider should_be_included_data_provider */ - public function test_should_be_included(string $role, array $canview, object $globalsettings = null): void { + public function test_should_be_included(string $role, array $canview, ?object $globalsettings = null): void { global $PAGE; $this->resetAfterTest(); ['recordings' => $recordingsdata, 'activity' => $activity] = $this->create_activity_with_recordings( diff --git a/mod/book/classes/search/chapter.php b/mod/book/classes/search/chapter.php index 0f17e63c080..391f09d19b8 100644 --- a/mod/book/classes/search/chapter.php +++ b/mod/book/classes/search/chapter.php @@ -46,7 +46,7 @@ class chapter extends \core_search\base_mod { * @param \context|null $context Optional context to restrict scope of returned results * @return moodle_recordset|null Recordset (or null if no results) */ - public function get_document_recordset($modifiedfrom = 0, \context $context = null) { + public function get_document_recordset($modifiedfrom = 0, ?\context $context = null) { global $DB; list ($contextjoin, $contextparams) = $this->get_context_restriction_sql( diff --git a/mod/book/tests/generator/lib.php b/mod/book/tests/generator/lib.php index 8471cf7ba30..85ee826e178 100644 --- a/mod/book/tests/generator/lib.php +++ b/mod/book/tests/generator/lib.php @@ -50,7 +50,7 @@ class mod_book_generator extends testing_module_generator { parent::reset(); } - public function create_instance($record = null, array $options = null) { + public function create_instance($record = null, ?array $options = null) { global $CFG; require_once("$CFG->dirroot/mod/book/locallib.php"); @@ -66,7 +66,7 @@ class mod_book_generator extends testing_module_generator { return parent::create_instance($record, (array)$options); } - public function create_chapter($record = null, array $options = null) { + public function create_chapter($record = null, ?array $options = null) { global $DB; $record = (object) (array) $record; diff --git a/mod/chat/tests/generator/lib.php b/mod/chat/tests/generator/lib.php index 4ddedf69bcf..bb63b30bfa0 100644 --- a/mod/chat/tests/generator/lib.php +++ b/mod/chat/tests/generator/lib.php @@ -50,7 +50,7 @@ class mod_chat_generator extends testing_module_generator { parent::reset(); } - public function create_instance($record = null, array $options = null) { + public function create_instance($record = null, ?array $options = null) { $record = (object)(array)$record; if (!isset($record->keepdays)) { diff --git a/mod/choice/tests/generator/lib.php b/mod/choice/tests/generator/lib.php index 8327fccafe8..772f01288b3 100644 --- a/mod/choice/tests/generator/lib.php +++ b/mod/choice/tests/generator/lib.php @@ -35,7 +35,7 @@ defined('MOODLE_INTERNAL') || die(); */ class mod_choice_generator extends testing_module_generator { - public function create_instance($record = null, array $options = null) { + public function create_instance($record = null, ?array $options = null) { $record = (object)(array)$record; if (!isset($record->timemodified)) { diff --git a/mod/data/classes/local/exporter/utils.php b/mod/data/classes/local/exporter/utils.php index f612c3266fc..d042c21722a 100644 --- a/mod/data/classes/local/exporter/utils.php +++ b/mod/data/classes/local/exporter/utils.php @@ -47,7 +47,7 @@ class utils { * @return void */ public static function data_exportdata(int $dataid, array $fields, array $selectedfields, entries_exporter $exporter, - int $currentgroup = 0, context $context = null, bool $userdetails = false, bool $time = false, bool $approval = false, + int $currentgroup = 0, ?context $context = null, bool $userdetails = false, bool $time = false, bool $approval = false, bool $tags = false, bool $includefiles = true): void { global $DB; diff --git a/mod/data/classes/search/entry.php b/mod/data/classes/search/entry.php index 75718e52d81..9d3438b9e4d 100644 --- a/mod/data/classes/search/entry.php +++ b/mod/data/classes/search/entry.php @@ -52,7 +52,7 @@ class entry extends \core_search\base_mod { * @param \context|null $context Optional context to restrict scope of returned results * @return moodle_recordset|null Recordset (or null if no results) */ - public function get_document_recordset($modifiedfrom = 0, \context $context = null) { + public function get_document_recordset($modifiedfrom = 0, ?\context $context = null) { global $DB; list ($contextjoin, $contextparams) = $this->get_context_restriction_sql( diff --git a/mod/data/classes/template.php b/mod/data/classes/template.php index ff36ae5d3e3..dfbc43844be 100644 --- a/mod/data/classes/template.php +++ b/mod/data/classes/template.php @@ -93,7 +93,7 @@ class template { * @param array $options an array of extra diplay options * @param array $fields alternative array of fields (for preview presets) */ - public function __construct(manager $manager, string $templatecontent, array $options = [], array $fields = null) { + public function __construct(manager $manager, string $templatecontent, array $options = [], ?array $fields = null) { $this->manager = $manager; $this->instance = $manager->get_instance(); $this->templatecontent = $templatecontent; diff --git a/mod/data/lib.php b/mod/data/lib.php index 58969f1b90f..6c422feec0b 100644 --- a/mod/data/lib.php +++ b/mod/data/lib.php @@ -1552,7 +1552,7 @@ function data_grade_item_delete($data) { * @param moodle_url|null $jumpurl a moodle_url by which to jump back to the record list (can be null) * @return mixed string with all parsed entries or nothing if $return is false */ -function data_print_template($templatename, $records, $data, $search='', $page=0, $return=false, moodle_url $jumpurl=null) { +function data_print_template($templatename, $records, $data, $search='', $page=0, $return=false, ?moodle_url $jumpurl=null) { debugging( 'data_print_template is deprecated. Use mod_data\\manager::get_template and mod_data\\template::parse_entries instead', DEBUG_DEVELOPER diff --git a/mod/data/tests/generator/lib.php b/mod/data/tests/generator/lib.php index a7bec8fdc4d..1d7d0d085e1 100644 --- a/mod/data/tests/generator/lib.php +++ b/mod/data/tests/generator/lib.php @@ -68,7 +68,7 @@ class mod_data_generator extends testing_module_generator { * @param array $options * @return StdClass */ - public function create_instance($record = null, array $options = null) { + public function create_instance($record = null, ?array $options = null) { // Note, the parent class does not type $record to cast to array and then to object. $record = (object) (array) $record; @@ -89,7 +89,7 @@ class mod_data_generator extends testing_module_generator { * @param stdClass|null $data * @return data_field_base */ - public function create_field(stdClass $record = null, $data = null) { + public function create_field(?stdClass $record = null, $data = null) { $record = (array) $record; $this->databasefieldcount++; @@ -214,7 +214,7 @@ class mod_data_generator extends testing_module_generator { * @param int $userid if defined, it will be the author of the entry * @return int id of the generated record in table {data_records} */ - public function create_entry($data, array $contents, $groupid = 0, $tags = [], array $options = null, int $userid = 0) { + public function create_entry($data, array $contents, $groupid = 0, $tags = [], ?array $options = null, int $userid = 0) { global $DB, $USER, $CFG; // Set current user if defined. @@ -387,7 +387,7 @@ class mod_data_generator extends testing_module_generator { * @param stdClass|null $record The preset information, like 'name'. * @return preset The preset that has been created. */ - public function create_preset(stdClass $instance, stdClass $record = null): preset { + public function create_preset(stdClass $instance, ?stdClass $record = null): preset { global $USER; if (is_null($record)) { diff --git a/mod/feedback/lib.php b/mod/feedback/lib.php index 845273fe735..b5934406d54 100644 --- a/mod/feedback/lib.php +++ b/mod/feedback/lib.php @@ -1062,7 +1062,7 @@ function feedback_count_complete_users($cm, $group = false) { function feedback_get_complete_users($cm, $group = false, $where = '', - array $params = null, + ?array $params = null, $sort = '', $startpage = false, $pagecount = false) { diff --git a/mod/feedback/tests/generator/lib.php b/mod/feedback/tests/generator/lib.php index 9b39bc191b4..84f22393351 100644 --- a/mod/feedback/tests/generator/lib.php +++ b/mod/feedback/tests/generator/lib.php @@ -35,7 +35,7 @@ defined('MOODLE_INTERNAL') || die(); */ class mod_feedback_generator extends testing_module_generator { - public function create_instance($record = null, array $options = null) { + public function create_instance($record = null, ?array $options = null) { global $CFG; require_once($CFG->dirroot.'/mod/feedback/lib.php'); $record = (object)(array)$record; diff --git a/mod/folder/backup/moodle1/lib.php b/mod/folder/backup/moodle1/lib.php index aeb68e07df2..39fa634463f 100644 --- a/mod/folder/backup/moodle1/lib.php +++ b/mod/folder/backup/moodle1/lib.php @@ -37,7 +37,7 @@ class moodle1_mod_folder_handler extends moodle1_resource_successor_handler { * Converts /MOODLE_BACKUP/COURSE/MODULES/MOD/RESOURCE data * Called by moodle1_mod_resource_handler::process_resource() */ - public function process_legacy_resource(array $data, array $raw = null) { + public function process_legacy_resource(array $data, ?array $raw = null) { // get the course module id and context id $instanceid = $data['id']; $currentcminfo = $this->get_cminfo($instanceid); diff --git a/mod/folder/tests/generator/lib.php b/mod/folder/tests/generator/lib.php index 00c93b5d046..dc1d2c0f37f 100644 --- a/mod/folder/tests/generator/lib.php +++ b/mod/folder/tests/generator/lib.php @@ -35,7 +35,7 @@ defined('MOODLE_INTERNAL') || die(); */ class mod_folder_generator extends testing_module_generator { - public function create_instance($record = null, array $options = null) { + public function create_instance($record = null, ?array $options = null) { // Add default values for folder. $record = (array)$record + array('display' => 0); if (!isset($record['showexpanded'])) { diff --git a/mod/forum/classes/grades/forum_gradeitem.php b/mod/forum/classes/grades/forum_gradeitem.php index 5760cb61b0e..73f21b05f9e 100644 --- a/mod/forum/classes/grades/forum_gradeitem.php +++ b/mod/forum/classes/grades/forum_gradeitem.php @@ -165,7 +165,7 @@ class forum_gradeitem extends component_gradeitem { * @return stdClass The grade value * @throws \dml_exception */ - public function get_grade_for_user(stdClass $gradeduser, stdClass $grader = null): ?stdClass { + public function get_grade_for_user(stdClass $gradeduser, ?stdClass $grader = null): ?stdClass { global $DB; $params = [ diff --git a/mod/forum/classes/local/entities/author.php b/mod/forum/classes/local/entities/author.php index 84367afc125..28e53a7a9fe 100644 --- a/mod/forum/classes/local/entities/author.php +++ b/mod/forum/classes/local/entities/author.php @@ -81,11 +81,11 @@ class author { string $fullname, string $email, bool $deleted, - string $middlename = null, - string $firstnamephonetic = null, - string $lastnamephonetic = null, - string $alternatename = null, - string $imagealt = null + ?string $middlename = null, + ?string $firstnamephonetic = null, + ?string $lastnamephonetic = null, + ?string $alternatename = null, + ?string $imagealt = null ) { $this->id = $id; $this->pictureitemid = $pictureitemid; diff --git a/mod/forum/classes/local/factories/exporter.php b/mod/forum/classes/local/factories/exporter.php index 58df6c4e25c..7b48dd8774c 100644 --- a/mod/forum/classes/local/factories/exporter.php +++ b/mod/forum/classes/local/factories/exporter.php @@ -236,7 +236,7 @@ class exporter { array $authorcontextids = [], array $attachmentsbypostid = [], array $groupsbyauthorid = [], - post_read_receipt_collection_entity $readreceiptcollection = null, + ?post_read_receipt_collection_entity $readreceiptcollection = null, array $tagsbypostid = [], array $ratingbypostid = [], bool $includehtml = false, diff --git a/mod/forum/classes/local/factories/renderer.php b/mod/forum/classes/local/factories/renderer.php index 737662bf47f..334b2a9cd3f 100644 --- a/mod/forum/classes/local/factories/renderer.php +++ b/mod/forum/classes/local/factories/renderer.php @@ -173,7 +173,7 @@ class renderer { * @param bool $readonly Should the posts include the actions to reply, delete, etc? * @return posts_renderer */ - public function get_single_discussion_posts_renderer(int $displaymode = null, bool $readonly = false): posts_renderer { + public function get_single_discussion_posts_renderer(?int $displaymode = null, bool $readonly = false): posts_renderer { $exportedpostssorter = $this->entityfactory->get_exported_posts_sorter(); switch ($displaymode) { diff --git a/mod/forum/classes/local/factories/url.php b/mod/forum/classes/local/factories/url.php index cfef7da3375..fe4dc3bffa0 100644 --- a/mod/forum/classes/local/factories/url.php +++ b/mod/forum/classes/local/factories/url.php @@ -415,7 +415,7 @@ class url { */ public function get_author_profile_image_url( author_entity $author, - int $authorcontextid = null, + ?int $authorcontextid = null, int $size = 100 ): moodle_url { global $PAGE; diff --git a/mod/forum/classes/local/managers/capability.php b/mod/forum/classes/local/managers/capability.php index bbcb8cb4684..1740eafe52d 100644 --- a/mod/forum/classes/local/managers/capability.php +++ b/mod/forum/classes/local/managers/capability.php @@ -108,7 +108,7 @@ class capability { * @param int|null $groupid The current activity group id * @return bool */ - public function can_create_discussions(stdClass $user, int $groupid = null): bool { + public function can_create_discussions(stdClass $user, ?int $groupid = null): bool { if (isguestuser($user) or !isloggedin()) { return false; } @@ -722,7 +722,7 @@ class capability { * @param stdClass $gradee The user being graded * @return bool */ - public function can_grade(stdClass $grader, stdClass $gradee = null): bool { + public function can_grade(stdClass $grader, ?stdClass $gradee = null): bool { if (!has_capability('mod/forum:grade', $this->get_context(), $grader)) { return false; } diff --git a/mod/forum/classes/local/renderers/discussion.php b/mod/forum/classes/local/renderers/discussion.php index 0c9d5e35a6f..19d783984ed 100644 --- a/mod/forum/classes/local/renderers/discussion.php +++ b/mod/forum/classes/local/renderers/discussion.php @@ -139,7 +139,7 @@ class discussion { sorter_entity $exportedpostsorter, moodle_url $baseurl, array $notifications = [], - callable $postprocessfortemplate = null + ?callable $postprocessfortemplate = null ) { $this->forum = $forum; $this->discussion = $discussion; diff --git a/mod/forum/classes/local/renderers/discussion_list.php b/mod/forum/classes/local/renderers/discussion_list.php index e57ee7e915d..a6907a88a66 100644 --- a/mod/forum/classes/local/renderers/discussion_list.php +++ b/mod/forum/classes/local/renderers/discussion_list.php @@ -116,7 +116,7 @@ class discussion_list { forum_gradeitem $forumgradeitem, string $template, array $notifications = [], - callable $postprocessfortemplate = null + ?callable $postprocessfortemplate = null ) { $this->forum = $forum; $this->renderer = $renderer; @@ -156,7 +156,7 @@ class discussion_list { ?int $sortorder, ?int $pageno, ?int $pagesize, - int $displaymode = null, + ?int $displaymode = null, bool $enablediscussioncreation = true ): string { global $PAGE; diff --git a/mod/forum/classes/local/renderers/posts.php b/mod/forum/classes/local/renderers/posts.php index aa7bfbe9a29..812092abc79 100644 --- a/mod/forum/classes/local/renderers/posts.php +++ b/mod/forum/classes/local/renderers/posts.php @@ -58,7 +58,7 @@ class posts { renderer_base $renderer, exported_posts_builder $exportedpostsbuilder, string $template, - callable $postprocessfortemplate = null + ?callable $postprocessfortemplate = null ) { $this->renderer = $renderer; $this->exportedpostsbuilder = $exportedpostsbuilder; diff --git a/mod/forum/classes/local/vaults/author.php b/mod/forum/classes/local/vaults/author.php index d0a4d5009bf..c3d3276602c 100644 --- a/mod/forum/classes/local/vaults/author.php +++ b/mod/forum/classes/local/vaults/author.php @@ -58,7 +58,7 @@ class author extends db_table_vault { * @param int|null $userid The user ID * @return string */ - protected function generate_get_records_sql(string $wheresql = null, string $sortsql = null, ?int $userid = null): string { + protected function generate_get_records_sql(?string $wheresql = null, ?string $sortsql = null, ?int $userid = null): string { $selectsql = 'SELECT * FROM {' . self::TABLE . '} ' . $this->get_table_alias(); $selectsql .= $wheresql ? ' WHERE ' . $wheresql : ''; $selectsql .= $sortsql ? ' ORDER BY ' . $sortsql : ''; diff --git a/mod/forum/classes/local/vaults/db_table_vault.php b/mod/forum/classes/local/vaults/db_table_vault.php index 2442ede3391..a9c45d2847d 100644 --- a/mod/forum/classes/local/vaults/db_table_vault.php +++ b/mod/forum/classes/local/vaults/db_table_vault.php @@ -75,7 +75,7 @@ abstract class db_table_vault { * @param object|null $user The user object * @return string */ - abstract protected function generate_get_records_sql(string $wheresql = null, string $sortsql = null, + abstract protected function generate_get_records_sql(?string $wheresql = null, ?string $sortsql = null, ?int $userid = null): string; /** diff --git a/mod/forum/classes/local/vaults/discussion.php b/mod/forum/classes/local/vaults/discussion.php index 25a894a7099..a52b095258a 100644 --- a/mod/forum/classes/local/vaults/discussion.php +++ b/mod/forum/classes/local/vaults/discussion.php @@ -62,7 +62,7 @@ class discussion extends db_table_vault { * @param int|null $userid The user ID * @return string */ - protected function generate_get_records_sql(string $wheresql = null, string $sortsql = null, ?int $userid = null): string { + protected function generate_get_records_sql(?string $wheresql = null, ?string $sortsql = null, ?int $userid = null): string { $selectsql = 'SELECT * FROM {' . self::TABLE . '} ' . $this->get_table_alias(); $selectsql .= $wheresql ? ' WHERE ' . $wheresql : ''; $selectsql .= $sortsql ? ' ORDER BY ' . $sortsql : ''; @@ -93,7 +93,7 @@ class discussion extends db_table_vault { * @param forum_entity $forum * @return array */ - public function get_all_discussions_in_forum(forum_entity $forum, string $sort = null): ?array { + public function get_all_discussions_in_forum(forum_entity $forum, ?string $sort = null): ?array { global $USER; $options = ['forum' => $forum->get_id()]; diff --git a/mod/forum/classes/local/vaults/discussion_list.php b/mod/forum/classes/local/vaults/discussion_list.php index 61a7d2148d9..ad8d84f5697 100644 --- a/mod/forum/classes/local/vaults/discussion_list.php +++ b/mod/forum/classes/local/vaults/discussion_list.php @@ -111,7 +111,7 @@ class discussion_list extends db_table_vault { * * @return string */ - protected function generate_get_records_sql(string $wheresql = null, ?string $sortsql = null, ?int $userid = null): string { + protected function generate_get_records_sql(?string $wheresql = null, ?string $sortsql = null, ?int $userid = null): string { $alias = $this->get_table_alias(); $includefavourites = $userid ? true : false; @@ -192,7 +192,7 @@ class discussion_list extends db_table_vault { * @param string|null $wheresql Where conditions for the SQL * @return string */ - protected function generate_count_records_sql(string $wheresql = null): string { + protected function generate_count_records_sql(?string $wheresql = null): string { $alias = $this->get_table_alias(); $db = $this->get_db(); diff --git a/mod/forum/classes/local/vaults/forum.php b/mod/forum/classes/local/vaults/forum.php index 841de3aa380..697c72c5258 100644 --- a/mod/forum/classes/local/vaults/forum.php +++ b/mod/forum/classes/local/vaults/forum.php @@ -64,7 +64,7 @@ class forum extends db_table_vault { * @param int|null $userid The user ID * @return string */ - protected function generate_get_records_sql(string $wheresql = null, string $sortsql = null, ?int $userid = null): string { + protected function generate_get_records_sql(?string $wheresql = null, ?string $sortsql = null, ?int $userid = null): string { $db = $this->get_db(); $alias = $this->get_table_alias(); diff --git a/mod/forum/classes/local/vaults/post.php b/mod/forum/classes/local/vaults/post.php index d587fe35fd2..7cf6c53bedf 100644 --- a/mod/forum/classes/local/vaults/post.php +++ b/mod/forum/classes/local/vaults/post.php @@ -70,7 +70,7 @@ class post extends db_table_vault { * @param int|null $userid The user ID * @return string */ - protected function generate_get_records_sql(string $wheresql = null, string $sortsql = null, ?int $userid = null): string { + protected function generate_get_records_sql(?string $wheresql = null, ?string $sortsql = null, ?int $userid = null): string { $table = self::TABLE; $alias = $this->get_table_alias(); $fields = $alias . '.*'; diff --git a/mod/forum/classes/local/vaults/post_read_receipt_collection.php b/mod/forum/classes/local/vaults/post_read_receipt_collection.php index 214e2884414..2f011bb78ea 100644 --- a/mod/forum/classes/local/vaults/post_read_receipt_collection.php +++ b/mod/forum/classes/local/vaults/post_read_receipt_collection.php @@ -60,7 +60,7 @@ class post_read_receipt_collection extends db_table_vault { * @param int|null $userid The user ID * @return string */ - protected function generate_get_records_sql(string $wheresql = null, string $sortsql = null, ?int $userid = null): string { + protected function generate_get_records_sql(?string $wheresql = null, ?string $sortsql = null, ?int $userid = null): string { $selectsql = 'SELECT * FROM {' . self::TABLE . '} ' . $this->get_table_alias(); $selectsql .= $wheresql ? ' WHERE ' . $wheresql : ''; $selectsql .= $sortsql ? ' ORDER BY ' . $sortsql : ''; diff --git a/mod/forum/classes/search/post.php b/mod/forum/classes/search/post.php index e83ddb96e60..0c9e4657be8 100644 --- a/mod/forum/classes/search/post.php +++ b/mod/forum/classes/search/post.php @@ -59,7 +59,7 @@ class post extends \core_search\base_mod { * @param \context|null $context Optional context to restrict scope of returned results * @return moodle_recordset|null Recordset (or null if no results) */ - public function get_document_recordset($modifiedfrom = 0, \context $context = null) { + public function get_document_recordset($modifiedfrom = 0, ?\context $context = null) { global $DB; list ($contextjoin, $contextparams) = $this->get_context_restriction_sql( diff --git a/mod/forum/lib.php b/mod/forum/lib.php index 5bd7100ec9b..a0f473dd6a8 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -5633,7 +5633,7 @@ function forum_get_courses_user_posted_in($user, $discussionsonly = false, $incl * @param int $limitnum The number of records to return * @return array An array of forums the user has posted within in the provided courses */ -function forum_get_forums_user_posted_in($user, array $courseids = null, $discussionsonly = false, $limitfrom = null, $limitnum = null) { +function forum_get_forums_user_posted_in($user, ?array $courseids = null, $discussionsonly = false, $limitfrom = null, $limitnum = null) { global $DB; if (!is_null($courseids)) { diff --git a/mod/forum/tests/generator/lib.php b/mod/forum/tests/generator/lib.php index de276702cc5..ab66bbfd49d 100644 --- a/mod/forum/tests/generator/lib.php +++ b/mod/forum/tests/generator/lib.php @@ -61,7 +61,7 @@ class mod_forum_generator extends testing_module_generator { parent::reset(); } - public function create_instance($record = null, array $options = null) { + public function create_instance($record = null, ?array $options = null) { global $CFG; require_once($CFG->dirroot.'/mod/forum/lib.php'); $record = (object)(array)$record; diff --git a/mod/glossary/classes/search/entry.php b/mod/glossary/classes/search/entry.php index 49d09bbfe0f..5917a09c1e3 100644 --- a/mod/glossary/classes/search/entry.php +++ b/mod/glossary/classes/search/entry.php @@ -49,7 +49,7 @@ class entry extends \core_search\base_mod { * @param \context|null $context Optional context to restrict scope of returned results * @return moodle_recordset|null Recordset (or null if no results) */ - public function get_document_recordset($modifiedfrom = 0, \context $context = null) { + public function get_document_recordset($modifiedfrom = 0, ?\context $context = null) { global $DB; list ($contextjoin, $contextparams) = $this->get_context_restriction_sql( diff --git a/mod/glossary/tests/generator/lib.php b/mod/glossary/tests/generator/lib.php index 67a3be40ebb..03a6abd3487 100644 --- a/mod/glossary/tests/generator/lib.php +++ b/mod/glossary/tests/generator/lib.php @@ -56,7 +56,7 @@ class mod_glossary_generator extends testing_module_generator { parent::reset(); } - public function create_instance($record = null, array $options = null) { + public function create_instance($record = null, ?array $options = null) { global $CFG; // Add default values for glossary. diff --git a/mod/h5pactivity/classes/external/log_report_viewed.php b/mod/h5pactivity/classes/external/log_report_viewed.php index c6faad13533..e83b1088fe6 100644 --- a/mod/h5pactivity/classes/external/log_report_viewed.php +++ b/mod/h5pactivity/classes/external/log_report_viewed.php @@ -64,7 +64,7 @@ class log_report_viewed extends external_api { * @param int|null $attemptid The attempt id * @return array of warnings and status result */ - public static function execute(int $h5pactivityid, int $userid = null, int $attemptid = null): stdClass { + public static function execute(int $h5pactivityid, ?int $userid = null, ?int $attemptid = null): stdClass { $params = external_api::validate_parameters(self::execute_parameters(), [ 'h5pactivityid' => $h5pactivityid, 'userid' => $userid, diff --git a/mod/h5pactivity/classes/local/attempt.php b/mod/h5pactivity/classes/local/attempt.php index 4e8724feeb5..74c1aed5cf7 100644 --- a/mod/h5pactivity/classes/local/attempt.php +++ b/mod/h5pactivity/classes/local/attempt.php @@ -116,7 +116,7 @@ class attempt { * @param stdClass $cm a course_module record * @param stdClass $user a user record */ - public static function delete_all_attempts(stdClass $cm, stdClass $user = null): void { + public static function delete_all_attempts(stdClass $cm, ?stdClass $user = null): void { global $DB; $where = 'a.h5pactivityid = :h5pactivityid'; diff --git a/mod/h5pactivity/classes/local/manager.php b/mod/h5pactivity/classes/local/manager.php index c5ec3aaed0b..579f3352c7c 100644 --- a/mod/h5pactivity/classes/local/manager.php +++ b/mod/h5pactivity/classes/local/manager.php @@ -177,7 +177,7 @@ class manager { * @param stdClass|null $user user record (default $USER) * @return bool if the user has permission to submit in this activity */ - public function can_submit(stdClass $user = null): bool { + public function can_submit(?stdClass $user = null): bool { global $USER; if (empty($user)) { @@ -192,7 +192,7 @@ class manager { * @param stdClass|null $user user record (default $USER) * @return bool if the user can see the attempts link */ - public function can_view_all_attempts(stdClass $user = null): bool { + public function can_view_all_attempts(?stdClass $user = null): bool { global $USER; if (!$this->instance->enabletracking) { return false; @@ -209,7 +209,7 @@ class manager { * @param stdClass|null $user user record (default $USER) * @return bool if the user can see the own attempts link */ - public function can_view_own_attempts(stdClass $user = null): bool { + public function can_view_own_attempts(?stdClass $user = null): bool { global $USER; if (!$this->instance->enabletracking) { return false; @@ -302,7 +302,7 @@ class manager { * @param int|null $userid optional user id (default null) * @return int the total amount of attempts */ - public function count_attempts(int $userid = null): int { + public function count_attempts(?int $userid = null): int { global $DB; // Counting records is enough for one user. @@ -460,7 +460,7 @@ class manager { * @param int|bool $currentgroup False if groups not used, 0 for all groups, group id (int) to filter by specific group * @return report|null available report (or null if no report available) */ - public function get_report(int $userid = null, int $attemptid = null, $currentgroup = false): ?report { + public function get_report(?int $userid = null, ?int $attemptid = null, $currentgroup = false): ?report { global $USER, $CFG; require_once("{$CFG->dirroot}/user/lib.php"); diff --git a/mod/h5pactivity/classes/output/attempt.php b/mod/h5pactivity/classes/output/attempt.php index 24880ea0e75..2b1911fb163 100644 --- a/mod/h5pactivity/classes/output/attempt.php +++ b/mod/h5pactivity/classes/output/attempt.php @@ -58,7 +58,7 @@ class attempt implements renderable, templatable { * @param stdClass $user a user record (default null). * @param int $courseid optional course id (default null). */ - public function __construct(activity_attempt $attempt, stdClass $user = null, int $courseid = null) { + public function __construct(activity_attempt $attempt, ?stdClass $user = null, ?int $courseid = null) { $this->attempt = $attempt; $this->user = $user; $this->courseid = $courseid; @@ -123,7 +123,7 @@ class attempt implements renderable, templatable { * @param bool $showtext if the icon must have a text or only icon * @return string icon HTML */ - private function completion_icon(renderer_base $output, int $completion = null, bool $showtext = false): string { + private function completion_icon(renderer_base $output, ?int $completion = null, bool $showtext = false): string { if ($completion === null) { return ''; } @@ -149,7 +149,7 @@ class attempt implements renderable, templatable { * @param bool $showtext if the icon must have a text or only icon * @return string icon HTML */ - private function success_icon(renderer_base $output, int $success = null, bool $showtext = false): string { + private function success_icon(renderer_base $output, ?int $success = null, bool $showtext = false): string { if ($success === null) { $alt = get_string('attempt_success_unknown', 'mod_h5pactivity'); if ($showtext) { diff --git a/mod/h5pactivity/classes/output/reportattempts.php b/mod/h5pactivity/classes/output/reportattempts.php index 84b15e50f83..c17762088ff 100644 --- a/mod/h5pactivity/classes/output/reportattempts.php +++ b/mod/h5pactivity/classes/output/reportattempts.php @@ -70,7 +70,7 @@ class reportattempts implements renderable, templatable { * @param string|null $title title to display on the scored attempt (null if none attempt is the scored one) * @param attempt|null $scored the scored attempt (null if none) */ - public function __construct(array $attempts, stdClass $user, int $courseid, string $title = null, attempt $scored = null) { + public function __construct(array $attempts, stdClass $user, int $courseid, ?string $title = null, ?attempt $scored = null) { $this->attempts = $attempts; $this->user = $user; $this->courseid = $courseid; diff --git a/mod/h5pactivity/classes/output/result.php b/mod/h5pactivity/classes/output/result.php index 67f681ae2b7..ad722a3a5a5 100644 --- a/mod/h5pactivity/classes/output/result.php +++ b/mod/h5pactivity/classes/output/result.php @@ -276,7 +276,7 @@ class result implements renderable, templatable { * @param string $answer the extra text to display (default null) * @return stdClass with "answer" text and the state attribute to be displayed */ - protected function get_answer(int $state, string $answer = null): stdClass { + protected function get_answer(int $state, ?string $answer = null): stdClass { $states = [ self::CORRECT => 'correct', self::INCORRECT => 'incorrect', diff --git a/mod/h5pactivity/classes/privacy/provider.php b/mod/h5pactivity/classes/privacy/provider.php index 4769b3bf807..e30b350f467 100644 --- a/mod/h5pactivity/classes/privacy/provider.php +++ b/mod/h5pactivity/classes/privacy/provider.php @@ -309,7 +309,7 @@ class provider implements * @param stdClass $cm a course_module record * @param stdClass $user a user record */ - private static function delete_all_attempts(stdClass $cm, stdClass $user = null): void { + private static function delete_all_attempts(stdClass $cm, ?stdClass $user = null): void { global $DB; $where = 'a.h5pactivityid = :h5pactivityid'; diff --git a/mod/h5pactivity/lib.php b/mod/h5pactivity/lib.php index 26a35a264e7..3d4ee53263b 100644 --- a/mod/h5pactivity/lib.php +++ b/mod/h5pactivity/lib.php @@ -82,7 +82,7 @@ function h5pactivity_supports(string $feature) { * @param mod_h5pactivity_mod_form $mform The form. * @return int The id of the newly inserted record. */ -function h5pactivity_add_instance(stdClass $data, mod_h5pactivity_mod_form $mform = null): int { +function h5pactivity_add_instance(stdClass $data, ?mod_h5pactivity_mod_form $mform = null): int { global $DB; $data->timecreated = time(); @@ -111,7 +111,7 @@ function h5pactivity_add_instance(stdClass $data, mod_h5pactivity_mod_form $mfor * @param mod_h5pactivity_mod_form $mform The form. * @return bool True if successful, false otherwise. */ -function h5pactivity_update_instance(stdClass $data, mod_h5pactivity_mod_form $mform = null): bool { +function h5pactivity_update_instance(stdClass $data, ?mod_h5pactivity_mod_form $mform = null): bool { global $DB; $data->timemodified = time(); @@ -854,7 +854,7 @@ function h5pactivity_fetch_recent_activity(array $submissions, int $courseid): a * @param navigation_node $h5pactivitynode The node to add module settings to */ function h5pactivity_extend_settings_navigation(settings_navigation $settingsnav, - navigation_node $h5pactivitynode = null) { + ?navigation_node $h5pactivitynode = null) { global $USER; $manager = manager::create_from_coursemodule($settingsnav->get_page()->cm); diff --git a/mod/h5pactivity/tests/generator/lib.php b/mod/h5pactivity/tests/generator/lib.php index 3f4c4b2fe06..3d9019999b3 100644 --- a/mod/h5pactivity/tests/generator/lib.php +++ b/mod/h5pactivity/tests/generator/lib.php @@ -47,7 +47,7 @@ class mod_h5pactivity_generator extends testing_module_generator { * @return stdClass record from module-defined table with additional field * cmid (corresponding id in course_modules table) */ - public function create_instance($record = null, array $options = null): stdClass { + public function create_instance($record = null, ?array $options = null): stdClass { global $CFG, $USER; // Ensure the record can be modified without affecting calling code. $record = (object)(array)$record; diff --git a/mod/imscp/backup/moodle1/lib.php b/mod/imscp/backup/moodle1/lib.php index 969e332bd2d..7029257f393 100644 --- a/mod/imscp/backup/moodle1/lib.php +++ b/mod/imscp/backup/moodle1/lib.php @@ -39,7 +39,7 @@ class moodle1_mod_imscp_handler extends moodle1_resource_successor_handler { * Converts /MOODLE_BACKUP/COURSE/MODULES/MOD/RESOURCE data * Called by moodle1_mod_resource_handler::process_resource() */ - public function process_legacy_resource(array $data, array $raw = null) { + public function process_legacy_resource(array $data, ?array $raw = null) { $instanceid = $data['id']; $currentcminfo = $this->get_cminfo($instanceid); diff --git a/mod/imscp/tests/generator/lib.php b/mod/imscp/tests/generator/lib.php index 8c869466538..2bbc60f7f30 100644 --- a/mod/imscp/tests/generator/lib.php +++ b/mod/imscp/tests/generator/lib.php @@ -35,7 +35,7 @@ defined('MOODLE_INTERNAL') || die(); */ class mod_imscp_generator extends testing_module_generator { - public function create_instance($record = null, array $options = null) { + public function create_instance($record = null, ?array $options = null) { global $CFG, $USER; // Add default values for imscp. diff --git a/mod/label/tests/generator/lib.php b/mod/label/tests/generator/lib.php index 465305617ce..a4ac1949757 100644 --- a/mod/label/tests/generator/lib.php +++ b/mod/label/tests/generator/lib.php @@ -36,7 +36,7 @@ defined('MOODLE_INTERNAL') || die(); */ class mod_label_generator extends testing_module_generator { - public function create_instance($record = null, array $options = null) { + public function create_instance($record = null, ?array $options = null) { $record = (array)$record; $record['showdescription'] = 1; return parent::create_instance($record, $options); diff --git a/mod/lesson/renderer.php b/mod/lesson/renderer.php index d32f557b138..1cbf9ed1c7e 100644 --- a/mod/lesson/renderer.php +++ b/mod/lesson/renderer.php @@ -152,7 +152,7 @@ class mod_lesson_renderer extends plugin_renderer_base { * @param single_button $button * @return string */ - public function message($message, single_button $button = null) { + public function message($message, ?single_button $button = null) { $output = $this->output->box_start('generalbox boxaligncenter'); $output .= $message; if ($button !== null) { diff --git a/mod/lesson/tests/generator/lib.php b/mod/lesson/tests/generator/lib.php index 6f76c14c0e8..ae2c47624de 100644 --- a/mod/lesson/tests/generator/lib.php +++ b/mod/lesson/tests/generator/lib.php @@ -79,7 +79,7 @@ class mod_lesson_generator extends testing_module_generator { * @param null|array $options general options for course module. * @return stdClass record from module-defined table with additional field cmid (corresponding id in course_modules table) */ - public function create_instance($record = null, array $options = null) { + public function create_instance($record = null, ?array $options = null) { global $CFG; // Add default values for lesson. @@ -127,7 +127,7 @@ class mod_lesson_generator extends testing_module_generator { * @param null|array|stdClass $record data for page being generated. * @param null|array $options general options. */ - public function create_page($record = null, array $options = null) { + public function create_page($record = null, ?array $options = null) { $record = (array) $record; // Pages require answers to work. Add it as a candidate page to be created once answers have been added. @@ -655,7 +655,7 @@ class mod_lesson_generator extends testing_module_generator { * @param null|array $options general options. * @throws coding_exception */ - public function create_answer($record = null, array $options = null) { + public function create_answer($record = null, ?array $options = null) { $record = (array) $record; $candidatepage = null; diff --git a/mod/lti/classes/local/ltiopenid/registration_helper.php b/mod/lti/classes/local/ltiopenid/registration_helper.php index a96c62bc6f4..34db0068737 100644 --- a/mod/lti/classes/local/ltiopenid/registration_helper.php +++ b/mod/lti/classes/local/ltiopenid/registration_helper.php @@ -281,7 +281,7 @@ class registration_helper { * * @return array the Client Registration as an associative array. */ - public function config_to_registration(object $config, int $typeid, object $type = null): array { + public function config_to_registration(object $config, int $typeid, ?object $type = null): array { $configarray = []; foreach ((array)$config as $k => $v) { if (substr($k, 0, 4) == 'lti_') { diff --git a/mod/lti/service/gradebookservices/classes/local/service/gradebookservices.php b/mod/lti/service/gradebookservices/classes/local/service/gradebookservices.php index 55b6e623e11..47383c42dc4 100644 --- a/mod/lti/service/gradebookservices/classes/local/service/gradebookservices.php +++ b/mod/lti/service/gradebookservices/classes/local/service/gradebookservices.php @@ -446,7 +446,7 @@ class gradebookservices extends service_base { */ public function add_standalone_lineitem(string $courseid, string $label, float $maximumscore, string $baseurl, ?int $ltilinkid, ?string $resourceid, ?string $tag, int $typeid, - int $toolproxyid = null): int { + ?int $toolproxyid = null): int { global $DB; $params = array(); $params['itemname'] = $label; diff --git a/mod/lti/service/gradebookservices/tests/gradebookservices_test.php b/mod/lti/service/gradebookservices/tests/gradebookservices_test.php index d6225119a18..9d20fad7f74 100644 --- a/mod/lti/service/gradebookservices/tests/gradebookservices_test.php +++ b/mod/lti/service/gradebookservices/tests/gradebookservices_test.php @@ -379,7 +379,7 @@ class gradebookservices_test extends \advanced_testcase { * */ private function create_standalone_lineitem(int $courseid, int $typeid, ?string $resourceid, - ?string $tag, int $ltiinstanceid = null): void { + ?string $tag, ?int $ltiinstanceid = null): void { $gbservice = new gradebookservices(); $gbservice->add_standalone_lineitem($courseid, "manualtest", diff --git a/mod/lti/tests/generator/lib.php b/mod/lti/tests/generator/lib.php index 1cd39709ae0..80b2ce7bdf5 100644 --- a/mod/lti/tests/generator/lib.php +++ b/mod/lti/tests/generator/lib.php @@ -40,7 +40,7 @@ require_once($CFG->dirroot . '/mod/lti/locallib.php'); */ class mod_lti_generator extends testing_module_generator { - public function create_instance($record = null, array $options = null) { + public function create_instance($record = null, ?array $options = null) { $record = (object) (array) $record; if (!isset($record->toolurl)) { diff --git a/mod/page/backup/moodle1/lib.php b/mod/page/backup/moodle1/lib.php index f1e4bc3be3f..08cb46b0d7e 100644 --- a/mod/page/backup/moodle1/lib.php +++ b/mod/page/backup/moodle1/lib.php @@ -37,7 +37,7 @@ class moodle1_mod_page_handler extends moodle1_resource_successor_handler { * Converts /MOODLE_BACKUP/COURSE/MODULES/MOD/RESOURCE data * Called by moodle1_mod_resource_handler::process_resource() */ - public function process_legacy_resource(array $data, array $raw = null) { + public function process_legacy_resource(array $data, ?array $raw = null) { // get the course module id and context id $instanceid = $data['id']; diff --git a/mod/page/tests/generator/lib.php b/mod/page/tests/generator/lib.php index 63cc3a277a2..5383556bc35 100644 --- a/mod/page/tests/generator/lib.php +++ b/mod/page/tests/generator/lib.php @@ -36,7 +36,7 @@ defined('MOODLE_INTERNAL') || die(); */ class mod_page_generator extends testing_module_generator { - public function create_instance($record = null, array $options = null) { + public function create_instance($record = null, ?array $options = null) { global $CFG; require_once($CFG->dirroot . '/lib/resourcelib.php'); diff --git a/mod/quiz/accessrule/seb/classes/helper.php b/mod/quiz/accessrule/seb/classes/helper.php index 9cd263e8918..c835a2531f1 100644 --- a/mod/quiz/accessrule/seb/classes/helper.php +++ b/mod/quiz/accessrule/seb/classes/helper.php @@ -93,7 +93,7 @@ class helper { * @param int|null $expiretime Unix timestamp * @return array */ - public static function get_seb_file_headers(int $expiretime = null): array { + public static function get_seb_file_headers(?int $expiretime = null): array { if (is_null($expiretime)) { $expiretime = time(); } diff --git a/mod/quiz/accessrule/seb/classes/template_controller.php b/mod/quiz/accessrule/seb/classes/template_controller.php index 97bd63aa9d0..c7b6b3aebb2 100644 --- a/mod/quiz/accessrule/seb/classes/template_controller.php +++ b/mod/quiz/accessrule/seb/classes/template_controller.php @@ -132,7 +132,7 @@ class template_controller { * * @return \quizaccess_seb\template */ - protected function get_instance($id = 0, \stdClass $data = null) { + protected function get_instance($id = 0, ?\stdClass $data = null) { return new template($id, $data); } diff --git a/mod/quiz/accessrule/seb/rule.php b/mod/quiz/accessrule/seb/rule.php index d92a3e9c626..5e670b14384 100644 --- a/mod/quiz/accessrule/seb/rule.php +++ b/mod/quiz/accessrule/seb/rule.php @@ -478,7 +478,7 @@ class quizaccess_seb extends access_rule_base { * * @return string HTML code of the provided buttons. */ - private function display_buttons(string $buttonshtml, $class = '', array $attributes = null): string { + private function display_buttons(string $buttonshtml, $class = '', ?array $attributes = null): string { $html = ''; if (!empty($buttonshtml)) { diff --git a/mod/quiz/accessrule/seb/tests/test_helper_trait.php b/mod/quiz/accessrule/seb/tests/test_helper_trait.php index 8c59bbe063c..9f02428d73c 100644 --- a/mod/quiz/accessrule/seb/tests/test_helper_trait.php +++ b/mod/quiz/accessrule/seb/tests/test_helper_trait.php @@ -226,7 +226,7 @@ trait quizaccess_seb_test_helper_trait { * @param string|null $xml Template content. * @return \quizaccess_seb\template Just created template. */ - public function create_template(string $xml = null) { + public function create_template(?string $xml = null) { $data = []; if (!is_null($xml)) { diff --git a/mod/quiz/classes/local/reports/attempts_report_table.php b/mod/quiz/classes/local/reports/attempts_report_table.php index cff27296312..55532137abe 100644 --- a/mod/quiz/classes/local/reports/attempts_report_table.php +++ b/mod/quiz/classes/local/reports/attempts_report_table.php @@ -452,7 +452,7 @@ abstract class attempts_report_table extends \table_sql { * in the query. See {@see qubaid_condition}. * @return array of records. See the SQL in this function to see the fields available. */ - protected function load_question_latest_steps(qubaid_condition $qubaids = null) { + protected function load_question_latest_steps(?qubaid_condition $qubaids = null) { if ($qubaids === null) { $qubaids = $this->get_qubaids_condition(); } diff --git a/mod/quiz/classes/output/renderer.php b/mod/quiz/classes/output/renderer.php index a3d6c91ef56..bd647da6433 100644 --- a/mod/quiz/classes/output/renderer.php +++ b/mod/quiz/classes/output/renderer.php @@ -975,7 +975,7 @@ class renderer extends plugin_renderer_base { * @return string HTML fragment. */ public function start_attempt_button($buttontext, moodle_url $url, - preflight_check_form $preflightcheckform = null, + ?preflight_check_form $preflightcheckform = null, $popuprequired = false, $popupoptions = null) { $button = new single_button($url, $buttontext, 'post', single_button::BUTTON_PRIMARY); diff --git a/mod/quiz/classes/question/bank/qbank_helper.php b/mod/quiz/classes/question/bank/qbank_helper.php index bcdd68fdd62..2ee0b3a3102 100644 --- a/mod/quiz/classes/question/bank/qbank_helper.php +++ b/mod/quiz/classes/question/bank/qbank_helper.php @@ -85,7 +85,7 @@ class qbank_helper { * @return array indexed by slot, with information about the content of each slot. */ public static function get_question_structure(int $quizid, context_module $quizcontext, - int $slotid = null): array { + ?int $slotid = null): array { global $DB; $params = [ diff --git a/mod/quiz/classes/question/bank/quiz_managecategories_feature.php b/mod/quiz/classes/question/bank/quiz_managecategories_feature.php index 6ff8744510f..6e23901ff54 100644 --- a/mod/quiz/classes/question/bank/quiz_managecategories_feature.php +++ b/mod/quiz/classes/question/bank/quiz_managecategories_feature.php @@ -31,7 +31,7 @@ use mod_quiz\question\bank\filter\custom_category_condition; */ class quiz_managecategories_feature extends \qbank_managecategories\plugin_feature { - public function get_question_filters(view $qbank = null): array { + public function get_question_filters(?view $qbank = null): array { return [ new custom_category_condition($qbank), ]; diff --git a/mod/quiz/classes/quiz_settings.php b/mod/quiz/classes/quiz_settings.php index 3454abfae8e..7216ff69b2f 100644 --- a/mod/quiz/classes/quiz_settings.php +++ b/mod/quiz/classes/quiz_settings.php @@ -113,7 +113,7 @@ class quiz_settings { * @param int|null $userid the the userid (optional). If passed, relevant overrides are applied. * @return quiz_settings the new quiz settings object. */ - public static function create(int $quizid, int $userid = null): self { + public static function create(int $quizid, ?int $userid = null): self { $quiz = access_manager::load_quiz_and_settings($quizid); [$course, $cm] = get_course_and_cm_from_instance($quiz, 'quiz'); @@ -127,7 +127,7 @@ class quiz_settings { * @param int|null $userid the the userid (optional). If passed, relevant overrides are applied. * @return quiz_settings the new quiz settings object. */ - public static function create_for_cmid(int $cmid, int $userid = null): self { + public static function create_for_cmid(int $cmid, ?int $userid = null): self { [$course, $cm] = get_course_and_cm_from_cmid($cmid, 'quiz'); $quiz = access_manager::load_quiz_and_settings($cm->instance); @@ -507,7 +507,7 @@ class quiz_settings { * @param int|null $attemptsubmittime time this attempt was submitted. (Optional, but should be given.) * @return string an appropraite message. */ - public function cannot_review_message($when, $short = false, int $attemptsubmittime = null) { + public function cannot_review_message($when, $short = false, ?int $attemptsubmittime = null) { if ($attemptsubmittime === null) { debugging('It is recommended that you pass $attemptsubmittime to cannot_review_message', DEBUG_DEVELOPER); diff --git a/mod/quiz/report/reportlib.php b/mod/quiz/report/reportlib.php index 21f4a47150c..60025363d10 100644 --- a/mod/quiz/report/reportlib.php +++ b/mod/quiz/report/reportlib.php @@ -200,7 +200,7 @@ function quiz_report_grade_method_sql($grademethod, $quizattemptsalias = 'quiza' * @param \core\dml\sql_join $usersjoins (joins, wheres, params) to get enrolled users * @return array band number => number of users with scores in that band. */ -function quiz_report_grade_bands($bandwidth, $bands, $quizid, \core\dml\sql_join $usersjoins = null) { +function quiz_report_grade_bands($bandwidth, $bands, $quizid, ?\core\dml\sql_join $usersjoins = null) { global $DB; if (!is_int($bands)) { debugging('$bands passed to quiz_report_grade_bands must be an integer. (' . diff --git a/mod/quiz/report/statistics/classes/calculator.php b/mod/quiz/report/statistics/classes/calculator.php index 976ed2f043c..e6ea21cd561 100644 --- a/mod/quiz/report/statistics/classes/calculator.php +++ b/mod/quiz/report/statistics/classes/calculator.php @@ -36,7 +36,7 @@ class calculator { */ protected $progress; - public function __construct(\core\progress\base $progress = null) { + public function __construct(?\core\progress\base $progress = null) { if ($progress === null) { $progress = new \core\progress\none(); } diff --git a/mod/quiz/report/statistics/statistics_table.php b/mod/quiz/report/statistics/statistics_table.php index a8442b45d9d..31a8f6cfacb 100644 --- a/mod/quiz/report/statistics/statistics_table.php +++ b/mod/quiz/report/statistics/statistics_table.php @@ -516,7 +516,7 @@ class quiz_statistics_table extends flexible_table { * @param string|null $max The maximum value in the range * @return string */ - protected function format_range(string $min = null, string $max = null) { + protected function format_range(?string $min = null, ?string $max = null) { if (is_null($min) && is_null($max)) { return ''; } else { @@ -552,7 +552,7 @@ class quiz_statistics_table extends flexible_table { * @param int $decimals Sets the number of decimal points * @return string A formatted string that represents a range between $min to $max. */ - protected function format_percentage_range(float $min = null, float $max = null, bool $fraction = true, int $decimals = 2) { + protected function format_percentage_range(?float $min = null, ?float $max = null, bool $fraction = true, int $decimals = 2) { if (is_null($min) && is_null($max)) { return ''; } else { diff --git a/mod/quiz/tests/generator/lib.php b/mod/quiz/tests/generator/lib.php index 0a6150b467b..319fe05cf23 100644 --- a/mod/quiz/tests/generator/lib.php +++ b/mod/quiz/tests/generator/lib.php @@ -28,7 +28,7 @@ defined('MOODLE_INTERNAL') || die(); */ class mod_quiz_generator extends testing_module_generator { - public function create_instance($record = null, array $options = null) { + public function create_instance($record = null, ?array $options = null) { global $CFG; require_once($CFG->dirroot.'/mod/quiz/locallib.php'); diff --git a/mod/resource/tests/generator/lib.php b/mod/resource/tests/generator/lib.php index 22d6caa483c..3ca3011aa69 100644 --- a/mod/resource/tests/generator/lib.php +++ b/mod/resource/tests/generator/lib.php @@ -46,7 +46,7 @@ class mod_resource_generator extends testing_module_generator { * @return stdClass record from module-defined table with additional field * cmid (corresponding id in course_modules table) */ - public function create_instance($record = null, array $options = null) { + public function create_instance($record = null, ?array $options = null) { global $CFG, $USER; require_once($CFG->dirroot . '/lib/resourcelib.php'); // Ensure the record can be modified without affecting calling code. diff --git a/mod/scorm/tests/generator/lib.php b/mod/scorm/tests/generator/lib.php index 25ed5b82b87..8cb8b161951 100644 --- a/mod/scorm/tests/generator/lib.php +++ b/mod/scorm/tests/generator/lib.php @@ -35,7 +35,7 @@ defined('MOODLE_INTERNAL') || die(); */ class mod_scorm_generator extends testing_module_generator { - public function create_instance($record = null, array $options = null) { + public function create_instance($record = null, ?array $options = null) { global $CFG, $USER; require_once($CFG->dirroot.'/mod/scorm/lib.php'); require_once($CFG->dirroot.'/mod/scorm/locallib.php'); diff --git a/mod/survey/classes/search/activity.php b/mod/survey/classes/search/activity.php index e25520d7bab..d809dbf322d 100644 --- a/mod/survey/classes/search/activity.php +++ b/mod/survey/classes/search/activity.php @@ -53,7 +53,7 @@ class activity extends \core_search\base_activity { * @param \context|null $context Context * @return \moodle_recordset|null Recordset, or null if no possible activities in given context */ - public function get_document_recordset($modifiedfrom = 0, \context $context = null) { + public function get_document_recordset($modifiedfrom = 0, ?\context $context = null) { global $DB; list ($contextjoin, $contextparams) = $this->get_context_restriction_sql( $context, $this->get_module_name(), 'modtable'); diff --git a/mod/survey/tests/generator/lib.php b/mod/survey/tests/generator/lib.php index 9551c8d805d..9ba63ea8817 100644 --- a/mod/survey/tests/generator/lib.php +++ b/mod/survey/tests/generator/lib.php @@ -46,7 +46,7 @@ class mod_survey_generator extends testing_module_generator { parent::reset(); } - public function create_instance($record = null, array $options = null) { + public function create_instance($record = null, ?array $options = null) { global $DB; if ($this->templates === null) { diff --git a/mod/url/backup/moodle1/lib.php b/mod/url/backup/moodle1/lib.php index 9ccf3788f9d..683820d7aea 100644 --- a/mod/url/backup/moodle1/lib.php +++ b/mod/url/backup/moodle1/lib.php @@ -37,7 +37,7 @@ class moodle1_mod_url_handler extends moodle1_resource_successor_handler { * Converts /MOODLE_BACKUP/COURSE/MODULES/MOD/RESOURCE data * Called by moodle1_mod_resource_handler::process_resource() */ - public function process_legacy_resource(array $data, array $raw = null) { + public function process_legacy_resource(array $data, ?array $raw = null) { // get the course module id and context id $instanceid = $data['id']; diff --git a/mod/url/tests/generator/lib.php b/mod/url/tests/generator/lib.php index b8b0103726a..4b4a7ed7b86 100644 --- a/mod/url/tests/generator/lib.php +++ b/mod/url/tests/generator/lib.php @@ -35,7 +35,7 @@ defined('MOODLE_INTERNAL') || die(); */ class mod_url_generator extends testing_module_generator { - public function create_instance($record = null, array $options = null) { + public function create_instance($record = null, ?array $options = null) { global $CFG; require_once($CFG->libdir.'/resourcelib.php'); diff --git a/mod/wiki/classes/search/collaborative_page.php b/mod/wiki/classes/search/collaborative_page.php index 81ca22955af..c54a4c4922a 100644 --- a/mod/wiki/classes/search/collaborative_page.php +++ b/mod/wiki/classes/search/collaborative_page.php @@ -48,7 +48,7 @@ class collaborative_page extends \core_search\base_mod { * @param \context|null $context Optional context to restrict scope of returned results * @return moodle_recordset|null Recordset (or null if no results) */ - public function get_document_recordset($modifiedfrom = 0, \context $context = null) { + public function get_document_recordset($modifiedfrom = 0, ?\context $context = null) { global $DB; list ($contextjoin, $contextparams) = $this->get_context_restriction_sql( diff --git a/mod/wiki/tests/generator/lib.php b/mod/wiki/tests/generator/lib.php index f99b249ac6a..451ff2d9533 100644 --- a/mod/wiki/tests/generator/lib.php +++ b/mod/wiki/tests/generator/lib.php @@ -50,7 +50,7 @@ class mod_wiki_generator extends testing_module_generator { parent::reset(); } - public function create_instance($record = null, array $options = null) { + public function create_instance($record = null, ?array $options = null) { // Add default values for wiki. $record = (array)$record + array( 'wikimode' => 'collaborative', diff --git a/mod/workshop/eval/best/lib.php b/mod/workshop/eval/best/lib.php index 72136294723..b2de9104848 100644 --- a/mod/workshop/eval/best/lib.php +++ b/mod/workshop/eval/best/lib.php @@ -110,7 +110,7 @@ class workshop_best_evaluation extends workshop_evaluation { * * @return workshop_best_evaluation_settings_form */ - public function get_settings_form(moodle_url $actionurl=null) { + public function get_settings_form(?moodle_url $actionurl=null) { $customdata['workshop'] = $this->workshop; $customdata['current'] = $this->settings; diff --git a/mod/workshop/eval/lib.php b/mod/workshop/eval/lib.php index 33296baf62e..ec8010cb7f3 100644 --- a/mod/workshop/eval/lib.php +++ b/mod/workshop/eval/lib.php @@ -51,7 +51,7 @@ abstract class workshop_evaluation { * * @return workshop_evaluation_settings_form */ - public function get_settings_form(moodle_url $actionurl=null) { + public function get_settings_form(?moodle_url $actionurl=null) { $customdata = array('workshop' => $this->workshop); $attributes = array('class' => 'evalsettingsform'); diff --git a/mod/workshop/form/accumulative/lib.php b/mod/workshop/form/accumulative/lib.php index 9e7a07895f5..5e22ae1ef6c 100644 --- a/mod/workshop/form/accumulative/lib.php +++ b/mod/workshop/form/accumulative/lib.php @@ -204,7 +204,7 @@ class workshop_accumulative_strategy implements workshop_strategy { * @param bool $editable * @param array $options */ - public function get_assessment_form(moodle_url $actionurl=null, $mode='preview', stdclass $assessment=null, $editable=true, $options=array()) { + public function get_assessment_form(?moodle_url $actionurl=null, $mode='preview', ?stdclass $assessment=null, $editable=true, $options=array()) { global $CFG; // needed because the included files use it global $PAGE; global $DB; diff --git a/mod/workshop/form/comments/lib.php b/mod/workshop/form/comments/lib.php index 52587853ae6..67970cdfa30 100644 --- a/mod/workshop/form/comments/lib.php +++ b/mod/workshop/form/comments/lib.php @@ -204,7 +204,7 @@ class workshop_comments_strategy implements workshop_strategy { * @param bool $editable * @param array $options */ - public function get_assessment_form(moodle_url $actionurl=null, $mode='preview', stdclass $assessment=null, $editable=true, $options=array()) { + public function get_assessment_form(?moodle_url $actionurl=null, $mode='preview', ?stdclass $assessment=null, $editable=true, $options=array()) { global $CFG; // needed because the included files use it global $PAGE; global $DB; diff --git a/mod/workshop/form/lib.php b/mod/workshop/form/lib.php index 1f5d930ff5d..b6e807590b6 100644 --- a/mod/workshop/form/lib.php +++ b/mod/workshop/form/lib.php @@ -58,7 +58,7 @@ interface workshop_strategy { * @param bool $editable Shall the form be opened as editable (true) or read-only (false) * @param array $options More assessment form options, editableweight implemented only now */ - public function get_assessment_form(moodle_url $actionurl=null, $mode='preview', stdclass $assessment=null, $editable=true, $options=array()); + public function get_assessment_form(?moodle_url $actionurl=null, $mode='preview', ?stdclass $assessment=null, $editable=true, $options=array()); /** * Saves the filled assessment and returns the grade for submission as suggested by the reviewer diff --git a/mod/workshop/form/numerrors/lib.php b/mod/workshop/form/numerrors/lib.php index 0118d89b9ad..7e61be3a423 100644 --- a/mod/workshop/form/numerrors/lib.php +++ b/mod/workshop/form/numerrors/lib.php @@ -241,7 +241,7 @@ class workshop_numerrors_strategy implements workshop_strategy { * @param bool $editable * @param array $options */ - public function get_assessment_form(moodle_url $actionurl=null, $mode='preview', stdclass $assessment=null, $editable=true, $options=array()) { + public function get_assessment_form(?moodle_url $actionurl=null, $mode='preview', ?stdclass $assessment=null, $editable=true, $options=array()) { global $CFG; // needed because the included files use it global $PAGE; global $DB; diff --git a/mod/workshop/form/rubric/lib.php b/mod/workshop/form/rubric/lib.php index e107ace1a31..9ea68854b5f 100644 --- a/mod/workshop/form/rubric/lib.php +++ b/mod/workshop/form/rubric/lib.php @@ -245,7 +245,7 @@ class workshop_rubric_strategy implements workshop_strategy { * @param bool $editable * @param array $options */ - public function get_assessment_form(moodle_url $actionurl=null, $mode='preview', stdclass $assessment=null, $editable=true, $options=array()) { + public function get_assessment_form(?moodle_url $actionurl=null, $mode='preview', ?stdclass $assessment=null, $editable=true, $options=array()) { global $CFG; // needed because the included files use it global $DB; require_once(__DIR__ . '/assessment_form.php'); diff --git a/mod/workshop/lib.php b/mod/workshop/lib.php index d454cb8565c..ceb410e1a28 100644 --- a/mod/workshop/lib.php +++ b/mod/workshop/lib.php @@ -1627,7 +1627,7 @@ function workshop_extend_navigation(navigation_node $navref, stdclass $course, s * @param settings_navigation $settingsnav {@link settings_navigation} * @param navigation_node $workshopnode {@link navigation_node} */ -function workshop_extend_settings_navigation(settings_navigation $settingsnav, navigation_node $workshopnode=null) { +function workshop_extend_settings_navigation(settings_navigation $settingsnav, ?navigation_node $workshopnode=null) { if (has_capability('mod/workshop:editdimensions', $settingsnav->get_page()->cm->context)) { $url = new moodle_url('/mod/workshop/editform.php', array('cmid' => $settingsnav->get_page()->cm->id)); $workshopnode->add(get_string('assessmentform', 'workshop'), $url, diff --git a/mod/workshop/locallib.php b/mod/workshop/locallib.php index 13449ea1d64..c779c6c588c 100644 --- a/mod/workshop/locallib.php +++ b/mod/workshop/locallib.php @@ -208,7 +208,7 @@ class workshop { * @param stdClass $course Course record from {course} table * @param stdClass $context The context of the workshop instance */ - public function __construct(stdclass $dbrecord, $cm, $course, stdclass $context=null) { + public function __construct(stdclass $dbrecord, $cm, $course, ?stdclass $context=null) { $this->dbrecord = $dbrecord; foreach ($this->dbrecord as $field => $value) { if (property_exists('workshop', $field)) { @@ -1800,7 +1800,7 @@ class workshop { * @param bool $return true to return the arguments for add_to_log. * @return void|array array of arguments for add_to_log if $return is true */ - public function log($action, moodle_url $url = null, $info = null, $return = false) { + public function log($action, ?moodle_url $url = null, $info = null, $return = false) { debugging('The log method is now deprecated, please use event classes instead', DEBUG_DEVELOPER); if (is_null($url)) { diff --git a/mod/workshop/tests/generator/lib.php b/mod/workshop/tests/generator/lib.php index 3fc2dcd2265..5f3b64ccd90 100644 --- a/mod/workshop/tests/generator/lib.php +++ b/mod/workshop/tests/generator/lib.php @@ -35,7 +35,7 @@ defined('MOODLE_INTERNAL') || die(); */ class mod_workshop_generator extends testing_module_generator { - public function create_instance($record = null, array $options = null) { + public function create_instance($record = null, ?array $options = null) { global $CFG; require_once($CFG->libdir.'/filelib.php'); diff --git a/question/bank/deletequestion/classes/plugin_feature.php b/question/bank/deletequestion/classes/plugin_feature.php index 65d1a35f472..188d33979f4 100644 --- a/question/bank/deletequestion/classes/plugin_feature.php +++ b/question/bank/deletequestion/classes/plugin_feature.php @@ -50,7 +50,7 @@ class plugin_feature extends plugin_features_base { ]; } - public function get_question_filters(view $qbank = null): array { + public function get_question_filters(?view $qbank = null): array { return [ new hidden_condition($qbank), ]; diff --git a/question/bank/editquestion/classes/editquestion_helper.php b/question/bank/editquestion/classes/editquestion_helper.php index 77493bbc888..6eb1b25e901 100644 --- a/question/bank/editquestion/classes/editquestion_helper.php +++ b/question/bank/editquestion/classes/editquestion_helper.php @@ -50,7 +50,7 @@ class editquestion_helper { * @param bool $enablejs * @return bool|string */ - public static function print_choose_qtype_to_add_form(array $hiddenparams, array $allowedqtypes = null, $enablejs = true) { + public static function print_choose_qtype_to_add_form(array $hiddenparams, ?array $allowedqtypes = null, $enablejs = true) { global $PAGE; $chooser = \qbank_editquestion\qbank_chooser::get($PAGE->course, $hiddenparams, $allowedqtypes); diff --git a/question/bank/editquestion/classes/qbank_chooser.php b/question/bank/editquestion/classes/qbank_chooser.php index 099ea0cbd2f..6c77bff1e7d 100644 --- a/question/bank/editquestion/classes/qbank_chooser.php +++ b/question/bank/editquestion/classes/qbank_chooser.php @@ -84,7 +84,7 @@ class qbank_chooser extends \core\output\chooser { * @param array|null $allowedqtypes Allowed question types. * @return qbank_chooser */ - public static function get($course, $hiddenparams, array $allowedqtypes = null): qbank_chooser { + public static function get($course, $hiddenparams, ?array $allowedqtypes = null): qbank_chooser { $realqtypes = array(); $fakeqtypes = array(); diff --git a/question/bank/history/classes/question_history_view.php b/question/bank/history/classes/question_history_view.php index 8da85e895a6..769de64b7c1 100644 --- a/question/bank/history/classes/question_history_view.php +++ b/question/bank/history/classes/question_history_view.php @@ -59,7 +59,7 @@ class question_history_view extends view { question_edit_contexts $contexts, moodle_url $pageurl, stdClass $course, - stdClass $cm = null, + ?stdClass $cm = null, array $params = [], array $extraparams = [], ) { diff --git a/question/bank/managecategories/classes/category_condition.php b/question/bank/managecategories/classes/category_condition.php index 76ea895a741..e9b1f16d2be 100644 --- a/question/bank/managecategories/classes/category_condition.php +++ b/question/bank/managecategories/classes/category_condition.php @@ -52,7 +52,7 @@ class category_condition extends condition { * * @param view $qbank qbank view */ - public function __construct(view $qbank = null) { + public function __construct(?view $qbank = null) { if (is_null($qbank)) { return; } diff --git a/question/bank/managecategories/classes/plugin_feature.php b/question/bank/managecategories/classes/plugin_feature.php index c182800887b..44619064a35 100644 --- a/question/bank/managecategories/classes/plugin_feature.php +++ b/question/bank/managecategories/classes/plugin_feature.php @@ -37,7 +37,7 @@ class plugin_feature extends plugin_features_base { return new navigation(); } - public function get_question_filters(view $qbank = null): array { + public function get_question_filters(?view $qbank = null): array { return [ new category_condition($qbank), ]; diff --git a/question/bank/managecategories/classes/question_category_object.php b/question/bank/managecategories/classes/question_category_object.php index 2837486023e..def8356c1f0 100644 --- a/question/bank/managecategories/classes/question_category_object.php +++ b/question/bank/managecategories/classes/question_category_object.php @@ -253,7 +253,7 @@ class question_category_object { * @param string $sort - [[sortfield [,sortfield]] {ASC|DESC}]. * @return array categories. */ - public function get_question_categories(int $parent = null, string $sort = "sortorder ASC"): array { + public function get_question_categories(?int $parent = null, string $sort = "sortorder ASC"): array { global $COURSE, $DB; if (is_null($parent)) { $categories = $DB->get_records('question_categories', ['course' => $COURSE->id], $sort); diff --git a/question/bank/tagquestion/classes/plugin_feature.php b/question/bank/tagquestion/classes/plugin_feature.php index cdce4ae2e3f..097b8e1e5e7 100644 --- a/question/bank/tagquestion/classes/plugin_feature.php +++ b/question/bank/tagquestion/classes/plugin_feature.php @@ -34,7 +34,7 @@ class plugin_feature extends plugin_features_base{ ]; } - public function get_question_filters(view $qbank = null): array { + public function get_question_filters(?view $qbank = null): array { global $CFG; if ($CFG->usetags) { return [ diff --git a/question/classes/local/bank/condition.php b/question/classes/local/bank/condition.php index f1715adb60b..c337613fda7 100644 --- a/question/classes/local/bank/condition.php +++ b/question/classes/local/bank/condition.php @@ -61,7 +61,7 @@ abstract class condition { * * @param view|null $qbank */ - public function __construct(view $qbank = null) { + public function __construct(?view $qbank = null) { if (is_null($qbank)) { return; } diff --git a/question/classes/local/bank/plugin_features_base.php b/question/classes/local/bank/plugin_features_base.php index 904fa407d51..ff77d86238f 100644 --- a/question/classes/local/bank/plugin_features_base.php +++ b/question/classes/local/bank/plugin_features_base.php @@ -111,7 +111,7 @@ class plugin_features_base { * @param view|null $qbank * @return condition[] */ - public function get_question_filters(view $qbank = null): array { + public function get_question_filters(?view $qbank = null): array { return []; } } diff --git a/question/classes/privacy/provider.php b/question/classes/privacy/provider.php index 59798447ebb..23fc4193596 100644 --- a/question/classes/privacy/provider.php +++ b/question/classes/privacy/provider.php @@ -414,7 +414,7 @@ class provider implements * @param int|null $contextid An optional context id, in case the $sql query is not already filtered by that. */ public static function get_users_in_context_from_sql(userlist $userlist, string $prefix, string $insql, $params, - int $contextid = null) { + ?int $contextid = null) { $sql = "SELECT {$prefix}_qas.userid FROM {question_attempt_steps} {$prefix}_qas diff --git a/question/classes/statistics/questions/calculated_question_summary.php b/question/classes/statistics/questions/calculated_question_summary.php index bbce6db836d..b4d6dfa95a2 100644 --- a/question/classes/statistics/questions/calculated_question_summary.php +++ b/question/classes/statistics/questions/calculated_question_summary.php @@ -146,7 +146,7 @@ class calculated_question_summary extends calculated { * @param float|null $value2 * @return float|null */ - protected function max(float $value1 = null, float $value2 = null) { + protected function max(?float $value1 = null, ?float $value2 = null) { $temp1 = $value1 ?: 0; $temp2 = $value2 ?: 0; @@ -170,7 +170,7 @@ class calculated_question_summary extends calculated { * @param float|null $value2 * @return mixed|null */ - protected function min(float $value1 = null, float $value2 = null) { + protected function min(?float $value1 = null, ?float $value2 = null) { $temp1 = $value1 ?: 0; $temp2 = $value2 ?: 0; diff --git a/question/classes/statistics/responses/analysis_for_question.php b/question/classes/statistics/responses/analysis_for_question.php index b491cdc810a..1ef8fbaf6a5 100644 --- a/question/classes/statistics/responses/analysis_for_question.php +++ b/question/classes/statistics/responses/analysis_for_question.php @@ -64,7 +64,7 @@ class analysis_for_question { * This is the return value from {@link \question_type::get_possible_responses()} * see that method for fuller documentation. */ - public function __construct(array $possiblereponses = null) { + public function __construct(?array $possiblereponses = null) { if ($possiblereponses !== null) { $this->possibleresponses = $possiblereponses; } diff --git a/question/classes/statistics/responses/analysis_for_subpart.php b/question/classes/statistics/responses/analysis_for_subpart.php index 6ead7edb1db..aeef1ae3fb1 100644 --- a/question/classes/statistics/responses/analysis_for_subpart.php +++ b/question/classes/statistics/responses/analysis_for_subpart.php @@ -57,7 +57,7 @@ class analysis_for_subpart { * * @param \question_possible_response[] $responseclasses as returned from {@link \question_type::get_possible_responses()}. */ - public function __construct(array $responseclasses = null) { + public function __construct(?array $responseclasses = null) { if (is_array($responseclasses)) { foreach ($responseclasses as $responseclassid => $responseclass) { $this->responseclasses[$responseclassid] = new analysis_for_class($responseclass, $responseclassid); diff --git a/question/engine/datalib.php b/question/engine/datalib.php index 723112fd88d..d645a760ea1 100644 --- a/question/engine/datalib.php +++ b/question/engine/datalib.php @@ -62,7 +62,7 @@ class question_engine_data_mapper { /** * @param moodle_database $db a database connectoin. Defaults to global $DB. */ - public function __construct(moodle_database $db = null) { + public function __construct(?moodle_database $db = null) { if (is_null($db)) { global $DB; $this->db = $DB; diff --git a/question/engine/lib.php b/question/engine/lib.php index 35d13a90222..d7d3ca77c63 100644 --- a/question/engine/lib.php +++ b/question/engine/lib.php @@ -79,7 +79,7 @@ abstract class question_engine { * @param moodle_database $db a database connectoin. Defaults to global $DB. * @return question_usage_by_activity loaded from the database. */ - public static function load_questions_usage_by_activity($qubaid, moodle_database $db = null) { + public static function load_questions_usage_by_activity($qubaid, ?moodle_database $db = null) { $dm = new question_engine_data_mapper($db); return $dm->load_questions_usage_by_activity($qubaid); } @@ -91,7 +91,7 @@ abstract class question_engine { * @param question_usage_by_activity the usage to save. * @param moodle_database $db a database connectoin. Defaults to global $DB. */ - public static function save_questions_usage_by_activity(question_usage_by_activity $quba, moodle_database $db = null) { + public static function save_questions_usage_by_activity(question_usage_by_activity $quba, ?moodle_database $db = null) { $dm = new question_engine_data_mapper($db); $observer = $quba->get_observer(); if ($observer instanceof question_engine_unit_of_work) { @@ -154,7 +154,7 @@ abstract class question_engine { * @return boolean whether any of these questions are being used by any of * those usages. */ - public static function questions_in_use(array $questionids, qubaid_condition $qubaids = null) { + public static function questions_in_use(array $questionids, ?qubaid_condition $qubaids = null) { if (is_null($qubaids)) { return false; } diff --git a/question/engine/questionattempt.php b/question/engine/questionattempt.php index 34d09486050..4176f60d379 100644 --- a/question/engine/questionattempt.php +++ b/question/engine/questionattempt.php @@ -202,7 +202,7 @@ class question_attempt { * passed, $question->defaultmark is used. */ public function __construct(question_definition $question, $usageid, - question_usage_observer $observer = null, $maxmark = null) { + ?question_usage_observer $observer = null, $maxmark = null) { $this->question = $question; $this->questioninitialised = self::QUESTION_STATE_NOT_APPLIED; $this->usageid = $usageid; diff --git a/question/engine/questionusage.php b/question/engine/questionusage.php index 798e369d738..a709a244e1f 100644 --- a/question/engine/questionusage.php +++ b/question/engine/questionusage.php @@ -594,7 +594,7 @@ class question_usage_by_activity { * @param int $timestamp optional, the timstamp to record for this action. Defaults to now. * @param int $userid optional, the user to attribute this action to. Defaults to the current user. */ - public function start_all_questions(question_variant_selection_strategy $variantstrategy = null, + public function start_all_questions(?question_variant_selection_strategy $variantstrategy = null, $timestamp = null, $userid = null) { if (is_null($variantstrategy)) { $variantstrategy = new question_variant_random_strategy(); @@ -920,7 +920,7 @@ class question_usage_by_activity { * in the regrade. (By default, the regrode will use exactly the same question version.) */ public function regrade_question($slot, $finished = false, $newmaxmark = null, - question_definition $otherversion = null) { + ?question_definition $otherversion = null) { $oldqa = $this->get_question_attempt($slot); if ($otherversion && $otherversion->questionbankentryid !== $oldqa->get_question(false)->questionbankentryid) { diff --git a/question/engine/tests/helpers.php b/question/engine/tests/helpers.php index 407374e8562..46630f1b224 100644 --- a/question/engine/tests/helpers.php +++ b/question/engine/tests/helpers.php @@ -879,11 +879,11 @@ abstract class qbehaviour_walkthrough_test_base extends question_testcase { $this->quba->manual_grade($this->slot, $comment, $mark, $commentformat); } - protected function save_quba(moodle_database $db = null) { + protected function save_quba(?moodle_database $db = null) { question_engine::save_questions_usage_by_activity($this->quba, $db); } - protected function load_quba(moodle_database $db = null) { + protected function load_quba(?moodle_database $db = null) { $this->quba = question_engine::load_questions_usage_by_activity($this->quba->get_id(), $db); } diff --git a/question/type/ordering/question.php b/question/type/ordering/question.php index fce4b9b2125..c6e0132c998 100644 --- a/question/type/ordering/question.php +++ b/question/type/ordering/question.php @@ -649,7 +649,7 @@ class qtype_ordering_question extends question_graded_automatically { * @return array|string array if $type is not specified and single string if $type is specified * @codeCoverageIgnore */ - public static function get_select_types(int $type = null): array|string { + public static function get_select_types(?int $type = null): array|string { $plugin = 'qtype_ordering'; $types = [ self::SELECT_ALL => get_string('selectall', $plugin), @@ -666,7 +666,7 @@ class qtype_ordering_question extends question_graded_automatically { * @return array|string array if $type is not specified and single string if $type is specified * @codeCoverageIgnore */ - public static function get_layout_types(int $type = null): array|string { + public static function get_layout_types(?int $type = null): array|string { $plugin = 'qtype_ordering'; $types = [ self::LAYOUT_VERTICAL => get_string('vertical', $plugin), @@ -682,7 +682,7 @@ class qtype_ordering_question extends question_graded_automatically { * @return array|string array if $type is not specified and single string if $type is specified * @codeCoverageIgnore */ - public static function get_grading_types(int $type = null): array|string { + public static function get_grading_types(?int $type = null): array|string { $plugin = 'qtype_ordering'; $types = [ self::GRADING_ALL_OR_NOTHING => get_string('allornothing', $plugin), @@ -709,7 +709,7 @@ class qtype_ordering_question extends question_graded_automatically { * The keys are style identifiers, and the values are the corresponding language strings. * @codeCoverageIgnore */ - public static function get_numbering_styles(string $style = null): array|string { + public static function get_numbering_styles(?string $style = null): array|string { $plugin = 'qtype_ordering'; $styles = [ 'none' => get_string('numberingstylenone', $plugin), diff --git a/question/type/ordering/questiontype.php b/question/type/ordering/questiontype.php index e93d89bd044..8dc38dd9ad0 100644 --- a/question/type/ordering/questiontype.php +++ b/question/type/ordering/questiontype.php @@ -308,7 +308,7 @@ class qtype_ordering extends question_type { * @param string|null $extra (optional, default=null) * @return stdClass|bool Question instance */ - public function import_from_gift(array $lines, ?stdClass $question, qformat_gift $format, string $extra = null): bool|stdClass { + public function import_from_gift(array $lines, ?stdClass $question, qformat_gift $format, ?string $extra = null): bool|stdClass { global $CFG; require_once($CFG->dirroot.'/question/type/ordering/question.php'); @@ -514,7 +514,7 @@ class qtype_ordering extends question_type { * @param string|null $extra (optional, default=null) * @return string GIFT representation of question */ - public function export_to_gift(stdClass $question, qformat_gift $format, string $extra = null): string { + public function export_to_gift(stdClass $question, qformat_gift $format, ?string $extra = null): string { global $CFG; require_once($CFG->dirroot.'/question/type/ordering/question.php'); diff --git a/rating/classes/privacy/provider.php b/rating/classes/privacy/provider.php index bb68ea95fe1..4212467ffa9 100644 --- a/rating/classes/privacy/provider.php +++ b/rating/classes/privacy/provider.php @@ -192,8 +192,8 @@ class provider implements * @param string $ratingarea Rating area to delete. * @param int $itemid The item ID for use with deletion. */ - public static function delete_ratings(\context $context, string $component = null, - string $ratingarea = null, int $itemid = null) { + public static function delete_ratings(\context $context, ?string $component = null, + ?string $ratingarea = null, ?int $itemid = null) { global $DB; $options = ['contextid' => $context->id]; diff --git a/report/log/tests/renderable_test.php b/report/log/tests/renderable_test.php index 0b26d247cb7..677c724f6da 100644 --- a/report/log/tests/renderable_test.php +++ b/report/log/tests/renderable_test.php @@ -319,7 +319,7 @@ class renderable_test extends \advanced_testcase { * @return void */ public function test_get_user_list(int $courseindex, string $username, array $expectedusers, - string $groupname = null): void { + ?string $groupname = null): void { global $PAGE, $CFG; $currentcourse = $this->courses[$courseindex]; $PAGE->set_url('/report/log/index.php?id=' . $currentcourse->id); diff --git a/report/stats/classes/privacy/provider.php b/report/stats/classes/privacy/provider.php index 5176bd9754d..e72dcbefb20 100644 --- a/report/stats/classes/privacy/provider.php +++ b/report/stats/classes/privacy/provider.php @@ -260,7 +260,7 @@ class provider implements * @param int $courseid The course ID to delete the stats for. * @param int $userid Optionally a user id to delete records with. */ - protected static function delete_stats(int $courseid, int $userid = null) { + protected static function delete_stats(int $courseid, ?int $userid = null) { global $DB; $params = (isset($userid)) ? ['courseid' => $courseid, 'userid' => $userid] : ['courseid' => $courseid]; $DB->delete_records('stats_user_daily', $params); diff --git a/reportbuilder/classes/local/helpers/database.php b/reportbuilder/classes/local/helpers/database.php index 0277881230d..ba896902da2 100644 --- a/reportbuilder/classes/local/helpers/database.php +++ b/reportbuilder/classes/local/helpers/database.php @@ -154,7 +154,7 @@ class database { * @param string|null $sort A valid SQL ORDER BY to sort the concatenated fields, if omitted then $field will be used * @return string */ - public static function sql_group_concat_sort(string $field, string $sort = null): string { + public static function sql_group_concat_sort(string $field, ?string $sort = null): string { global $DB; // Fallback to sorting by the specified field, unless it contains parameters which would be duplicated. diff --git a/reportbuilder/classes/local/helpers/user_filter_manager.php b/reportbuilder/classes/local/helpers/user_filter_manager.php index 0bf19202498..55ac67c76a1 100644 --- a/reportbuilder/classes/local/helpers/user_filter_manager.php +++ b/reportbuilder/classes/local/helpers/user_filter_manager.php @@ -56,7 +56,7 @@ class user_filter_manager { * @param int|null $userid * @return bool */ - public static function set(int $reportid, array $values, int $userid = null): bool { + public static function set(int $reportid, array $values, ?int $userid = null): bool { $jsonvalues = json_encode($values); $jsonchunks = str_split($jsonvalues, static::PREFERENCE_CHUNK_SIZE); @@ -78,7 +78,7 @@ class user_filter_manager { * @param int|null $userid * @return array */ - public static function get(int $reportid, int $userid = null): array { + public static function get(int $reportid, ?int $userid = null): array { $jsonvalues = ''; $index = 0; @@ -100,7 +100,7 @@ class user_filter_manager { * @param int|null $userid * @return bool */ - public static function merge(int $reportid, array $values, int $userid = null): bool { + public static function merge(int $reportid, array $values, ?int $userid = null): bool { $existing = static::get($reportid, $userid); return static::set($reportid, array_merge($existing, $values), $userid); @@ -114,7 +114,7 @@ class user_filter_manager { * @param int $index If specified, then preferences will be reset starting from this index * @return bool */ - public static function reset_all(int $reportid, int $userid = null, int $index = 0): bool { + public static function reset_all(int $reportid, ?int $userid = null, int $index = 0): bool { // We'll repeatedly retrieve and reset preferences, until we hit one that is below the maximum length. do { $userpreference = static::user_preference_name($reportid, $index++); @@ -133,7 +133,7 @@ class user_filter_manager { * @param int|null $userid * @return bool */ - public static function reset_single(int $reportid, string $uniqueidentifier, int $userid = null): bool { + public static function reset_single(int $reportid, string $uniqueidentifier, ?int $userid = null): bool { $originalvalues = static::get($reportid, $userid); // Remove any filters whose name is prefixed by given identifier. diff --git a/repository/dropbox/lib.php b/repository/dropbox/lib.php index 469fe3f2dc1..17dcabc4e73 100644 --- a/repository/dropbox/lib.php +++ b/repository/dropbox/lib.php @@ -68,7 +68,7 @@ class repository_dropbox extends repository { * * @inheritDocs */ - public function send_file($storedfile, $lifetime=null , $filter=0, $forcedownload=false, array $options = null) { + public function send_file($storedfile, $lifetime=null , $filter=0, $forcedownload=false, ?array $options = null) { $reference = $this->unpack_reference($storedfile->get_reference()); $maxcachesize = $this->max_cache_bytes(); diff --git a/repository/equella/lib.php b/repository/equella/lib.php index a3d7626515b..db58b086309 100644 --- a/repository/equella/lib.php +++ b/repository/equella/lib.php @@ -247,7 +247,7 @@ class repository_equella extends repository { * @param bool $forcedownload If true (default false), forces download of file rather than view in browser/plugin * @param array $options additional options affecting the file serving */ - public function send_file($stored_file, $lifetime=null , $filter=0, $forcedownload=false, array $options = null) { + public function send_file($stored_file, $lifetime=null , $filter=0, $forcedownload=false, ?array $options = null) { $reference = unserialize(base64_decode($stored_file->get_reference())); $url = $this->appendtoken($reference->url); if ($url) { diff --git a/repository/filesystem/lib.php b/repository/filesystem/lib.php index 4e6166cb0db..c0c62ccac1f 100644 --- a/repository/filesystem/lib.php +++ b/repository/filesystem/lib.php @@ -613,7 +613,7 @@ class repository_filesystem extends repository { * @param bool $forcedownload If true (default false), forces download of file rather than view in browser/plugin * @param array $options additional options affecting the file serving */ - public function send_file($storedfile, $lifetime=null , $filter=0, $forcedownload=false, array $options = null) { + public function send_file($storedfile, $lifetime=null , $filter=0, $forcedownload=false, ?array $options = null) { $reference = $storedfile->get_reference(); $file = $this->get_rootpath() . ltrim($reference, '/'); if ($this->is_in_repository($reference) && is_readable($file)) { diff --git a/repository/googledocs/lib.php b/repository/googledocs/lib.php index 143ce82ccf2..0c810ae71b4 100644 --- a/repository/googledocs/lib.php +++ b/repository/googledocs/lib.php @@ -673,7 +673,7 @@ class repository_googledocs extends repository { * @param bool $forcedownload If true (default false), forces download of file rather than view in browser/plugin * @param array $options additional options affecting the file serving */ - public function send_file($storedfile, $lifetime=null , $filter=0, $forcedownload=false, array $options = null) { + public function send_file($storedfile, $lifetime=null , $filter=0, $forcedownload=false, ?array $options = null) { if (!$this->issuer->get('enabled')) { throw new repository_exception('cannotdownload', 'repository'); } diff --git a/repository/lib.php b/repository/lib.php index 249b79eea46..af96fc0b234 100644 --- a/repository/lib.php +++ b/repository/lib.php @@ -1221,7 +1221,7 @@ abstract class repository implements cacheable_object { * @param bool $forcedownload If true (default false), forces download of file rather than view in browser/plugin * @param array $options additional options affecting the file serving */ - public function send_file($storedfile, $lifetime=null , $filter=0, $forcedownload=false, array $options = null) { + public function send_file($storedfile, $lifetime=null , $filter=0, $forcedownload=false, ?array $options = null) { if ($this->has_moodle_files()) { $fs = get_file_storage(); $params = file_storage::unpack_reference($storedfile->get_reference(), true); diff --git a/repository/nextcloud/lib.php b/repository/nextcloud/lib.php index c256073c938..c2580ba7f14 100644 --- a/repository/nextcloud/lib.php +++ b/repository/nextcloud/lib.php @@ -431,7 +431,7 @@ class repository_nextcloud extends repository { * @throws coding_exception * @throws moodle_exception */ - public function send_file($storedfile, $lifetime=null , $filter=0, $forcedownload=false, array $options = null) { + public function send_file($storedfile, $lifetime=null , $filter=0, $forcedownload=false, ?array $options = null) { $repositoryname = $this->get_name(); $reference = json_decode($storedfile->get_reference()); diff --git a/repository/onedrive/lib.php b/repository/onedrive/lib.php index 417783e938a..4da65f1fc9a 100644 --- a/repository/onedrive/lib.php +++ b/repository/onedrive/lib.php @@ -561,7 +561,7 @@ class repository_onedrive extends repository { * @param bool $forcedownload If true (default false), forces download of file rather than view in browser/plugin * @param array $options additional options affecting the file serving */ - public function send_file($storedfile, $lifetime=null , $filter=0, $forcedownload=false, array $options = null) { + public function send_file($storedfile, $lifetime=null , $filter=0, $forcedownload=false, ?array $options = null) { if ($this->disabled) { throw new repository_exception('cannotdownload', 'repository'); } diff --git a/search/classes/base.php b/search/classes/base.php index bc98d472910..d372e2d58ec 100644 --- a/search/classes/base.php +++ b/search/classes/base.php @@ -314,7 +314,7 @@ abstract class base { * @return \moodle_recordset|null|false Recordset / null if no results / false if not supported * @since Moodle 3.4 */ - public function get_document_recordset($modifiedfrom = 0, \context $context = null) { + public function get_document_recordset($modifiedfrom = 0, ?\context $context = null) { return false; } diff --git a/search/classes/base_activity.php b/search/classes/base_activity.php index 8519b5bdf98..22374020365 100644 --- a/search/classes/base_activity.php +++ b/search/classes/base_activity.php @@ -64,7 +64,7 @@ abstract class base_activity extends base_mod { * @param int $modifiedfrom Return only records modified after this date * @return \moodle_recordset|null Recordset, or null if no possible activities in given context */ - public function get_document_recordset($modifiedfrom = 0, \context $context = null) { + public function get_document_recordset($modifiedfrom = 0, ?\context $context = null) { global $DB; list ($contextjoin, $contextparams) = $this->get_context_restriction_sql( $context, $this->get_module_name(), 'modtable'); diff --git a/search/classes/base_block.php b/search/classes/base_block.php index 6fe23e4a6ce..cd9e7f7f45f 100644 --- a/search/classes/base_block.php +++ b/search/classes/base_block.php @@ -106,7 +106,7 @@ abstract class base_block extends base { * @param \context|null $context Context to find blocks within * @return false|\moodle_recordset|null */ - public function get_document_recordset($modifiedfrom = 0, \context $context = null) { + public function get_document_recordset($modifiedfrom = 0, ?\context $context = null) { global $DB; // Get context restrictions. @@ -287,7 +287,7 @@ abstract class base_block extends base { * @return array Array with SQL and parameters * @throws \coding_exception If called with invalid params */ - protected function get_context_restriction_sql(\context $context = null, $blocktable = 'bi', + protected function get_context_restriction_sql(?\context $context = null, $blocktable = 'bi', $paramtype = SQL_PARAMS_QM) { global $DB; diff --git a/search/classes/manager.php b/search/classes/manager.php index fd25afa2cf7..907a8913d74 100644 --- a/search/classes/manager.php +++ b/search/classes/manager.php @@ -1193,7 +1193,7 @@ class manager { * @throws \moodle_exception * @return bool Whether there was any updated document or not. */ - public function index($fullindex = false, $timelimit = 0, \progress_trace $progress = null) { + public function index($fullindex = false, $timelimit = 0, ?\progress_trace $progress = null) { global $DB; // Cannot combine time limit with reindex. @@ -1365,7 +1365,7 @@ class manager { * @return \stdClass Object indicating success */ public function index_context($context, $singleareaid = '', $timelimit = 0, - \progress_trace $progress = null, $startfromarea = '', $startfromtime = 0) { + ?\progress_trace $progress = null, $startfromarea = '', $startfromtime = 0) { if (!$progress) { $progress = new \null_progress_trace(); } @@ -1689,7 +1689,7 @@ class manager { * @param float $timelimit Time limit (0 = none) * @param \progress_trace|null $progress Optional progress indicator */ - public function process_index_requests($timelimit = 0.0, \progress_trace $progress = null) { + public function process_index_requests($timelimit = 0.0, ?\progress_trace $progress = null) { global $DB; if (!$progress) { diff --git a/search/engine/solr/classes/schema.php b/search/engine/solr/classes/schema.php index 743166f2378..03217fcbe04 100644 --- a/search/engine/solr/classes/schema.php +++ b/search/engine/solr/classes/schema.php @@ -64,7 +64,7 @@ class schema { * @throws \moodle_exception * @return void */ - public function __construct(engine $engine = null) { + public function __construct(?engine $engine = null) { if (!$this->config = get_config('search_solr')) { throw new \moodle_exception('missingconfig', 'search_solr'); } diff --git a/user/classes/search/course_teacher.php b/user/classes/search/course_teacher.php index 021a9d6d492..4c86e6c3f2a 100644 --- a/user/classes/search/course_teacher.php +++ b/user/classes/search/course_teacher.php @@ -64,7 +64,7 @@ class course_teacher extends \core_search\base { * @param \context|null $context Optional context to restrict scope of returned results * @return \moodle_recordset|null Recordset (or null if no results) */ - public function get_document_recordset($modifiedfrom = 0, \context $context = null) { + public function get_document_recordset($modifiedfrom = 0, ?\context $context = null) { global $DB; $teacherroleids = get_config('core', 'searchteacherroles'); diff --git a/user/classes/search/user.php b/user/classes/search/user.php index 9cb1115638f..2437f35d2d7 100644 --- a/user/classes/search/user.php +++ b/user/classes/search/user.php @@ -44,7 +44,7 @@ class user extends \core_search\base { * @param \context|null $context Optional context to restrict scope of returned results * @return \moodle_recordset|null Recordset (or null if no results) */ - public function get_document_recordset($modifiedfrom = 0, \context $context = null) { + public function get_document_recordset($modifiedfrom = 0, ?\context $context = null) { global $DB; // Prepare query conditions. diff --git a/user/filters/lib.php b/user/filters/lib.php index d960af8277e..3e2d057121c 100644 --- a/user/filters/lib.php +++ b/user/filters/lib.php @@ -230,7 +230,7 @@ class user_filtering { * @param array $params named params (recommended prefix ex) * @return array sql string and $params */ - public function get_sql_filter($extra='', array $params=null) { + public function get_sql_filter($extra='', ?array $params=null) { global $SESSION; $sqls = array(); diff --git a/webservice/soap/classes/wsdl.php b/webservice/soap/classes/wsdl.php index 10082ad0ed9..772e492afc3 100644 --- a/webservice/soap/classes/wsdl.php +++ b/webservice/soap/classes/wsdl.php @@ -225,7 +225,7 @@ class wsdl { * @param bool $isoutput Flag to indicate if the nodes to be generated are for input or for output. */ private function process_params($functionname, \SimpleXMLElement $porttypeoperation, \SimpleXMLElement $bindingoperation, - array $params = null, $isoutput = false) { + ?array $params = null, $isoutput = false) { // Do nothing if parameter array is empty. if (empty($params)) { return; diff --git a/webservice/soap/lib.php b/webservice/soap/lib.php index 65d7d51fe59..cbe88ef9a53 100644 --- a/webservice/soap/lib.php +++ b/webservice/soap/lib.php @@ -49,7 +49,7 @@ class webservice_soap_client { * @param string $token the token used to do the web service call * @param array $options PHP SOAP client options - see php.net */ - public function __construct($serverurl, $token = null, array $options = null) { + public function __construct($serverurl, $token = null, ?array $options = null) { $this->serverurl = new moodle_url($serverurl); $this->token = $token ?: $this->serverurl->get_param('wstoken'); $this->options = $options ?: array();