Skip to content

Commit 9060871

Browse files
committed
Fix remaining PHPCS errors
1 parent 0437fd1 commit 9060871

16 files changed

+83
-13
lines changed

classes/issuer_management.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
* @copyright 2018 Jan Dageförde (Learnweb, University of Münster)
3434
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
3535
*/
36-
3736
class issuer_management {
3837
/**
3938
* Create an ownCloud/Nextcloud ready OAuth 2 service. Generates all required endpoints and field mappings.

classes/local/clients/system_client.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@
2424

2525
namespace mod_collaborativefolders\local\clients;
2626

27+
/**
28+
* Extend oauth\client to store token in application cache, not in the SESSION
29+
*/
2730
class system_client extends \core\oauth2\client {
31+
#[\Override]
2832
protected function store_token($token) {
2933
// Call parent function, as $this->accesstoken is private, so can't set directly.
3034
parent::store_token($token);
@@ -38,6 +42,7 @@ protected function store_token($token) {
3842
}
3943
}
4044

45+
#[\Override]
4146
protected function get_stored_token() {
4247
$name = $this->get_tokenname();
4348
$cache = \cache::make('mod_collaborativefolders', 'token');
@@ -48,6 +53,7 @@ protected function get_stored_token() {
4853
return null;
4954
}
5055

56+
#[\Override]
5157
public function upgrade_refresh_token(\core\oauth2\system_account $systemaccount): bool {
5258
$this->store_token(null); // Make sure the existing token is cleared, before calling refresh.
5359
return parent::upgrade_refresh_token($systemaccount);

classes/local/clients/system_folder_access.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,12 @@ private function verify_system_access() {
175175
*
176176
* @param string $path path to the folder (relative to sharing private storage).
177177
* @param string $username Receiving ownCloud username.
178-
* @param string $chosenname (optional) the name of the shared folder within the user's ownCloud
178+
* @param string|null $chosenname (optional) the name of the shared folder within the user's ownCloud
179179
* @return \SimpleXMLElement Excerpt from the XML response on success.
180180
* @throws share_exists_exception If the folder had already been shared prior.
181181
* @throws share_failed_exception If calling the OCS API resulted in an unknown state.
182182
*/
183-
public function generate_share(string $path, string $username, string $chosenname = null) {
183+
public function generate_share(string $path, string $username, string|null $chosenname = null) {
184184
$this->verify_system_access();
185185

186186
if (!$this->make_folder($path)) {

classes/local/clients/user_folder_access.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ class user_folder_access {
4646
*/
4747
const SCOPES = 'files';
4848

49+
/**
50+
* User information cache key.
51+
*/
4952
const USERINFO_CACHE_KEY = 1;
5053

5154
/**
@@ -276,6 +279,9 @@ public function get_userinfo() {
276279
return $user;
277280
}
278281

282+
/**
283+
* Return username.
284+
*/
279285
public function get_username() {
280286
$userinfo = $this->get_userinfo();
281287
return $userinfo['username'];

classes/name_form.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
3030
*/
3131
class name_form extends \moodleform {
32+
#[\Override]
3233
public function definition() {
3334
$mform = $this->_form;
3435

@@ -42,6 +43,7 @@ public function definition() {
4243
$mform->addElement('submit', 'enter', get_string('getaccess', 'mod_collaborativefolders'));
4344
}
4445

46+
#[\Override]
4547
public function validation($data, $files) {
4648
$errors = parent::validation($data, $files);
4749

@@ -52,6 +54,7 @@ public function validation($data, $files) {
5254
return $errors;
5355
}
5456

57+
#[\Override]
5558
protected function get_form_identifier() {
5659
$formid = $this->_customdata['id'] . '_' . get_class($this);
5760
return $formid;

classes/output/renderer.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
// You should have received a copy of the GNU General Public License
1515
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
1616

17-
namespace mod_collaborativefolders\output;
18-
1917
/**
2018
* Renderer for the Web interface of collaborativefolders module.
2119
*
@@ -24,6 +22,8 @@
2422
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
2523
*/
2624

25+
namespace mod_collaborativefolders\output;
26+
2727
use core\output\notification;
2828
use core\output\plugin_renderer_base;
2929
use mod_collaborativefolders\name_form;
@@ -62,6 +62,9 @@ public function render_widget_login(\moodle_url $loginurl) {
6262
return html_writer::link($loginurl, get_string('btnlogin', 'mod_collaborativefolders'), ['class' => 'btn btn-primary']);
6363
}
6464

65+
/**
66+
* Render teachersnotallowed notification.
67+
*/
6568
public function render_widget_teachermaynotaccess() {
6669
$notification = new notification(
6770
get_string('teachersnotallowed', 'mod_collaborativefolders'),
@@ -71,6 +74,9 @@ public function render_widget_teachermaynotaccess() {
7174
return $this->render($notification);
7275
}
7376

77+
/**
78+
* Render notingroup notification.
79+
*/
7480
public function render_widget_nogroups(): string {
7581
$notification = new notification(
7682
get_string('notingroup', 'mod_collaborativefolders'),
@@ -80,6 +86,9 @@ public function render_widget_nogroups(): string {
8086
return $this->render($notification);
8187
}
8288

89+
/**
90+
* Render problem_nosystemconnection notification.
91+
*/
8392
public function render_widget_nosystemconnection() {
8493
$servicename = get_config('collaborativefolders', 'servicename');
8594
$notification = new notification(
@@ -90,6 +99,9 @@ public function render_widget_nosystemconnection() {
9099
return $this->render($notification);
91100
}
92101

102+
/**
103+
* Render problem_misconfiguration notification.
104+
*/
93105
public function render_widget_misconfiguration() {
94106
$notification = new notification(
95107
get_string('problem_misconfiguration', 'mod_collaborativefolders'),
@@ -99,6 +111,9 @@ public function render_widget_misconfiguration() {
99111
return $this->render($notification);
100112
}
101113

114+
/**
115+
* Render problem_sharessuppressed notification.
116+
*/
102117
public function render_widget_noconnection_suppressed_share(int $sharessuppressed) {
103118
$info = (object)[
104119
'sharessuppressed' => $sharessuppressed,
@@ -114,6 +129,7 @@ public function render_widget_noconnection_suppressed_share(int $sharessuppresse
114129
}
115130

116131
/**
132+
* Render the name form.
117133
* @param name_form $form
118134
*/
119135
public function output_name_form($group, name_form $form) {

classes/privacy/provider.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,13 @@
2828
use core_privacy\local\request\helper;
2929
use core_privacy\local\request\writer;
3030

31+
/**
32+
* Privacy provider for mod_collaborativefolders
33+
*/
3134
class provider implements
3235
\core_privacy\local\metadata\provider,
3336
\core_privacy\local\request\plugin\provider {
37+
#[\Override]
3438
public static function get_metadata(collection $collection): collection {
3539
$collection->add_database_table(
3640
'collaborativefolders_link',
@@ -46,6 +50,7 @@ public static function get_metadata(collection $collection): collection {
4650
return $collection;
4751
}
4852

53+
#[\Override]
4954
public static function get_contexts_for_userid(int $userid): \core_privacy\local\request\contextlist {
5055
$contextlist = new \core_privacy\local\request\contextlist();
5156

@@ -62,6 +67,7 @@ public static function get_contexts_for_userid(int $userid): \core_privacy\local
6267
return $contextlist;
6368
}
6469

70+
#[\Override]
6571
public static function export_user_data(\core_privacy\local\request\approved_contextlist $contextlist) {
6672
global $DB;
6773
if (!$contextlist->count()) {
@@ -108,6 +114,12 @@ public static function export_user_data(\core_privacy\local\request\approved_con
108114
}
109115
}
110116

117+
/**
118+
* Export user data for mod_collaborativefolders
119+
* @param array $links links
120+
* @param int $cmid course module ID
121+
* @param \stdClass $user user record.
122+
*/
111123
private static function export_collaborativefolders_data_for_user(array $links, int $cmid, \stdClass $user) {
112124
// Fetch the generic module data for the choice.
113125
$context = \context_module::instance($cmid);
@@ -121,6 +133,7 @@ private static function export_collaborativefolders_data_for_user(array $links,
121133
helper::export_context_files($context, $user);
122134
}
123135

136+
#[\Override]
124137
public static function delete_data_for_all_users_in_context(\context $context) {
125138
global $DB;
126139
if (!$context) {
@@ -139,6 +152,7 @@ public static function delete_data_for_all_users_in_context(\context $context) {
139152
);
140153
}
141154

155+
#[\Override]
142156
public static function delete_data_for_user(\core_privacy\local\request\approved_contextlist $contextlist) {
143157
global $DB;
144158
if (!$contextlist->count()) {

classes/view_controller.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ private static function get_instance_status($collaborativefolder, \cm_info $cm,
184184
* @param bool $systemclientcanshare true if there is a connected system account that could create a share
185185
* @param user_folder_access $userclient connected client for the current user.
186186
* @return string Rendered view
187-
* @internal param user_folder_access $userclient
188187
*/
189188
private static function share_and_view_folders(
190189
\cm_info $cm,
@@ -250,7 +249,13 @@ private static function share_and_view_folders(
250249
return $out;
251250
}
252251

253-
private static function obtain_folders(statusinfo $statusinfo, \cm_info $cm, $isteacher) {
252+
/**
253+
* Obtain the folders.
254+
* @param statusinfo $statusinfo status information.
255+
* @param cm_info $cm course module information
256+
* @param bool $isteacher whether a teacher
257+
*/
258+
private static function obtain_folders(statusinfo $statusinfo, \cm_info $cm, bool $isteacher) {
254259
// Get applicable groups from $statusinfo.
255260
if ($isteacher && !$statusinfo->teachermayaccess) {
256261
// Refuse access for teacher because user config says so.
@@ -279,6 +284,7 @@ private static function obtain_folders(statusinfo $statusinfo, \cm_info $cm, $is
279284
}
280285

281286
/**
287+
* Handle folder form submission.
282288
* @param array $userfolders array of folders applicable for the user
283289
* @param \cm_info $cm current coursemodule
284290
* @param user_folder_access $userclient connected client of the user

db/upgrade.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
2323
*/
2424

25+
/**
26+
* Execute mod_collaborativefolders upgrade from the given old version.
27+
*
28+
* @param int $oldversion
29+
* @return bool
30+
*/
2531
function xmldb_collaborativefolders_upgrade($oldversion = 0) {
2632
global $DB;
2733
$dbman = $DB->get_manager();

lib.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ function collaborativefolders_supports($feature) {
6565
* of the new instance.
6666
*
6767
* @param stdClass $collaborativefolders Submitted data from the form in mod_form.php
68-
* @param mod_collaborativefolders_mod_form $mform The form instance itself (if needed)
68+
* @param mod_collaborativefolders_mod_form|null $mform The form instance itself (if needed)
6969
* @return int The id of the newly inserted collaborativefolders record
7070
*/
71-
function collaborativefolders_add_instance(stdClass $collaborativefolders, mod_collaborativefolders_mod_form $mform = null) {
71+
function collaborativefolders_add_instance(stdClass $collaborativefolders, mod_collaborativefolders_mod_form|null $mform = null) {
7272
global $DB;
7373

7474
$collaborativefolders->timecreated = time();
@@ -86,10 +86,10 @@ function collaborativefolders_add_instance(stdClass $collaborativefolders, mod_c
8686
* will update an existing instance with new data.
8787
*
8888
* @param stdClass $collaborativefolders An object from the form in mod_form.php
89-
* @param mod_collaborativefolders_mod_form $mform The form instance itself (if needed)
89+
* @param mod_collaborativefolders_mod_form|null $mform The form instance itself (if needed)
9090
* @return boolean Success/Fail
9191
*/
92-
function collaborativefolders_update_instance(stdClass $collaborativefolders, mod_collaborativefolders_mod_form $mform = null) {
92+
function collaborativefolders_update_instance(stdClass $collaborativefolders, mod_collaborativefolders_mod_form|null $mform = null) {
9393
global $DB;
9494

9595
$collaborativefolders->timemodified = time();

0 commit comments

Comments
 (0)