From e4b78070d99cc7953a2f779b7d9fc285d2f554d0 Mon Sep 17 00:00:00 2001 From: Jonathan Champ Date: Mon, 8 Apr 2024 11:56:05 -0400 Subject: [PATCH] phpcs: add blank line after header; explicit nullable types; ignore test methods --- classes/invitation.php | 6 +++--- lib.php | 18 +++++++++--------- locallib.php | 1 - participants.php | 8 ++++++-- recreate.php | 1 + report.php | 1 + tests/generator/lib.php | 4 ++-- tests/mod_zoom_webservice_test.php | 12 ++++++------ view.php | 1 + 9 files changed, 29 insertions(+), 23 deletions(-) diff --git a/classes/invitation.php b/classes/invitation.php index d6bd9c36..8185c863 100644 --- a/classes/invitation.php +++ b/classes/invitation.php @@ -59,10 +59,10 @@ public function __construct($invitation) { * Get the display string to show on the module page. * * @param int $coursemoduleid Course module where the user will view the invitation. - * @param int|null $userid Optionally supply the intended user to view the string. Defaults to global $USER. - * @return string|null + * @param ?int $userid Optionally supply the intended user to view the string. Defaults to global $USER. + * @return ?string */ - public function get_display_string(int $coursemoduleid, int $userid = null) { + public function get_display_string(int $coursemoduleid, ?int $userid = null) { if (empty($this->invitation)) { return null; } diff --git a/lib.php b/lib.php index 5f5e9674..0e27c61f 100755 --- a/lib.php +++ b/lib.php @@ -64,10 +64,10 @@ function zoom_supports($feature) { * will create a new instance and return the id number of the new instance. * * @param stdClass $zoom Submitted data from the form in mod_form.php - * @param mod_zoom_mod_form $mform The form instance (included because the function is used as a callback) + * @param ?mod_zoom_mod_form $mform The form instance (included because the function is used as a callback) * @return int The id of the newly inserted zoom record */ -function zoom_add_instance(stdClass $zoom, mod_zoom_mod_form $mform = null) { +function zoom_add_instance(stdClass $zoom, ?mod_zoom_mod_form $mform = null) { global $CFG, $DB; require_once($CFG->dirroot . '/mod/zoom/locallib.php'); @@ -143,10 +143,10 @@ function zoom_add_instance(stdClass $zoom, mod_zoom_mod_form $mform = null) { * will update an existing instance with new data. * * @param stdClass $zoom An object from the form in mod_form.php - * @param mod_zoom_mod_form $mform The form instance (included because the function is used as a callback) + * @param ?mod_zoom_mod_form $mform The form instance (included because the function is used as a callback) * @return boolean Success/Failure */ -function zoom_update_instance(stdClass $zoom, mod_zoom_mod_form $mform = null) { +function zoom_update_instance(stdClass $zoom, ?mod_zoom_mod_form $mform = null) { global $CFG, $DB; require_once($CFG->dirroot . '/mod/zoom/locallib.php'); @@ -586,10 +586,10 @@ function zoom_get_monthweek_options() { * Populate the calendar event object, based on the zoom instance * * @param stdClass $zoom The zoom instance. - * @param stdClass $occurrence The occurrence object passed from the zoom api. + * @param ?stdClass $occurrence The occurrence object passed from the zoom api. * @return stdClass The calendar event object. */ -function zoom_populate_calender_item(stdClass $zoom, stdClass $occurrence = null) { +function zoom_populate_calender_item(stdClass $zoom, ?stdClass $occurrence = null) { $event = new stdClass(); $event->type = CALENDAR_EVENT_TYPE_ACTION; $event->modulename = 'zoom'; @@ -873,7 +873,7 @@ function zoom_reset_userdata($data) { * * @param object $mform the course reset form that is being built. */ -function zoom_reset_course_form_definition(&$mform) { +function zoom_reset_course_form_definition($mform) { $mform->addElement('header', 'zoomheader', get_string('modulenameplural', 'zoom')); $mform->addElement('checkbox', 'reset_zoom_all', get_string('resetzoomsall', 'zoom')); @@ -973,9 +973,9 @@ function zoom_extend_navigation(navigation_node $navref, stdClass $course, stdCl * so it is safe to rely on the $PAGE. * * @param settings_navigation $settingsnav complete settings navigation tree - * @param navigation_node $zoomnode zoom administration node + * @param ?navigation_node $zoomnode zoom administration node */ -function zoom_extend_settings_navigation(settings_navigation $settingsnav, navigation_node $zoomnode = null) { +function zoom_extend_settings_navigation(settings_navigation $settingsnav, ?navigation_node $zoomnode = null) { } /** diff --git a/locallib.php b/locallib.php index 019b9266..0a3d8aa6 100755 --- a/locallib.php +++ b/locallib.php @@ -1319,7 +1319,6 @@ function zoom_get_registrant_join_url($useremail, $meetingid, $iswebinar) { * Get the display name for a Zoom user. * This is wrapped in a function to avoid unnecessary API calls. * - * @package mod_zoom * @param string $zoomuserid Zoom user ID. * @return ?string */ diff --git a/participants.php b/participants.php index 4576ed7f..2e90f46e 100644 --- a/participants.php +++ b/participants.php @@ -21,6 +21,7 @@ * @copyright 2015 UC Regents * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ + require(__DIR__ . '/../../config.php'); require_once(__DIR__ . '/lib.php'); require_once(__DIR__ . '/locallib.php'); @@ -166,8 +167,11 @@ 'export' => 'xls', ]); $xlsstring = get_string('application/vnd.ms-excel', 'mimetypes'); - $xlsicon = html_writer::img($OUTPUT->image_url('f/spreadsheet'), $xlsstring, - ['title' => $xlsstring, 'class' => 'mimetypeicon']); + $xlsicon = html_writer::img( + $OUTPUT->image_url('f/spreadsheet'), + $xlsstring, + ['title' => $xlsstring, 'class' => 'mimetypeicon'] + ); echo get_string('export', 'mod_zoom') . ': ' . html_writer::link($exporturl, $xlsicon); echo $OUTPUT->footer(); diff --git a/recreate.php b/recreate.php index 412645aa..9b4e3e0d 100644 --- a/recreate.php +++ b/recreate.php @@ -21,6 +21,7 @@ * @copyright 2017 UC Regents * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ + require(__DIR__ . '/../../config.php'); require_once(__DIR__ . '/lib.php'); require_once(__DIR__ . '/locallib.php'); diff --git a/report.php b/report.php index 5e35a337..3e8af364 100755 --- a/report.php +++ b/report.php @@ -21,6 +21,7 @@ * @copyright 2015 UC Regents * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ + require(__DIR__ . '/../../config.php'); require_once(__DIR__ . '/lib.php'); require_once(__DIR__ . '/locallib.php'); diff --git a/tests/generator/lib.php b/tests/generator/lib.php index cf507501..60a6d1a3 100644 --- a/tests/generator/lib.php +++ b/tests/generator/lib.php @@ -25,10 +25,10 @@ class mod_zoom_generator extends testing_module_generator { /** * Creates new Zoom module instance. * @param array|stdClass $record - * @param array $options + * @param ?array $options * @return stdClass Zoom instance */ - 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/zoom/locallib.php'); diff --git a/tests/mod_zoom_webservice_test.php b/tests/mod_zoom_webservice_test.php index d126b74f..1e2ebd06 100644 --- a/tests/mod_zoom_webservice_test.php +++ b/tests/mod_zoom_webservice_test.php @@ -54,8 +54,8 @@ public function setUp(): void { set_config('clientsecret', 'test', 'zoom'); set_config('accountid', 'test', 'zoom'); + // @codingStandardsIgnoreStart $this->notfoundmockcurl = new class { - // @codingStandardsIgnoreStart /** * Stub for curl setHeader(). * @param string $unusedparam @@ -169,8 +169,8 @@ public function test_user_not_found_exception(): void { * Tests whether invalid user errors are parsed properly */ public function test_invalid_user_exception(): void { + // @codingStandardsIgnoreStart $invalidmockcurl = new class { - // @codingStandardsIgnoreStart /** * Stub for curl setHeader(). * @param string $unusedparam @@ -230,9 +230,9 @@ public function get_info() { * is in the curl response to specify the time that the retry should be sent. */ public function test_retry_with_header(): void { + // @codingStandardsIgnoreStart $retrywithheadermockcurl = new class { public $numgetinfocalls = 0; - // @codingStandardsIgnoreStart /** * Stub for curl setHeader(). * @param string $unusedparam @@ -309,9 +309,9 @@ public function getResponse() { * header is not sent in the curl response. */ public function test_retry_without_header(): void { + // @codingStandardsIgnoreStart $retrynoheadermockcurl = new class { public $numgetinfocalls = 0; - // @codingStandardsIgnoreStart /** * Stub for curl setHeader(). * @param string $unusedparam @@ -377,9 +377,9 @@ public function getResponse() { * Tests that we throw error if we tried more than max retries. */ public function test_retry_exception(): void { + // @codingStandardsIgnoreStart $retryfailuremockcurl = new class { public $urlpath = null; - // @codingStandardsIgnoreStart /** * Stub for curl setHeader(). * @param string $unusedparam @@ -464,9 +464,9 @@ public function getResponse() { * Tests that we are waiting 1 minute for QPS rate limit types. */ public function test_retryqps_exception(): void { + // @codingStandardsIgnoreStart $retryqpsmockcurl = new class { public $urlpath = null; - // @codingStandardsIgnoreStart /** * Stub for curl setHeader(). * @param string $unusedparam diff --git a/view.php b/view.php index bf1033b8..1f7c6115 100755 --- a/view.php +++ b/view.php @@ -24,6 +24,7 @@ * @copyright 2015 UC Regents * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ + require(__DIR__ . '/../../config.php'); require_once(__DIR__ . '/lib.php'); require_once(__DIR__ . '/locallib.php');