32
32
*/
33
33
class auth_plugin_basic extends auth_plugin_base {
34
34
35
+ /**
36
+ * Defaults.
37
+ *
38
+ * @var int[]
39
+ */
35
40
public $ defaults = array (
36
41
'debug ' => 0 ,
37
42
'send401 ' => 0 ,
@@ -49,9 +54,9 @@ public function __construct() {
49
54
/**
50
55
* A debug function, dumps to the php log as well as into the
51
56
* response headers for easy curl based debugging
52
- *
57
+ * @param string $msg Message
53
58
*/
54
- private function log ($ msg ) {
59
+ private function log (string $ msg ) {
55
60
if ($ this ->config ->debug ) {
56
61
// @codingStandardsIgnoreStart
57
62
error_log ('auth_basic: ' . $ msg );
@@ -161,17 +166,16 @@ public function loginpage_hook() {
161
166
* @param string $username The username
162
167
* @param string $password The password
163
168
* @return bool Authentication success or failure.
164
- *
165
- * @SuppressWarnings("unused")
166
169
*/
167
170
public function user_login ($ username , $ password ) {
168
171
return false ;
169
172
}
170
173
171
174
/**
172
- * @param $userpassword
175
+ * Check if provided password is master password.
176
+ *
177
+ * @param string $userpassword User password.
173
178
* @return bool
174
- * @throws dml_exception
175
179
*/
176
180
private function is_master_password ($ userpassword ) {
177
181
global $ CFG , $ DB ;
@@ -213,8 +217,9 @@ private function get_random_user() {
213
217
214
218
/**
215
219
* Get a user by site role.
220
+ *
221
+ * @param mixed $roleid Role ID
216
222
* @return bool|mixed
217
- * @throws dml_exception
218
223
*/
219
224
private function get_random_user_by_roleid ($ roleid ) {
220
225
$ sql = "SELECT u.*
@@ -226,7 +231,7 @@ private function get_random_user_by_roleid($roleid) {
226
231
227
232
/**
228
233
* Get a user who is enrolled in a course.
229
- * @param $courseid
234
+ * @param int $courseid
230
235
* @return bool|mixed
231
236
* @throws dml_exception
232
237
*/
@@ -243,7 +248,10 @@ private function get_random_user_by_courseid($courseid) {
243
248
* Get a user who is enrolled in a course with a specified role.
244
249
* This will only get student with role at Course Level.
245
250
* It will ignore roles at other context level (module, category, block, site).
246
- * @param $courseid
251
+ *
252
+ * @param int $courseid
253
+ * @param int $roleid Role ID
254
+ *
247
255
* @return bool|mixed
248
256
* @throws dml_exception
249
257
*/
@@ -260,9 +268,9 @@ private function get_random_user_by_courseid_with_roleid($courseid, $roleid) {
260
268
261
269
/**
262
270
* Get user based on template value.
263
- * @param $template
271
+ *
272
+ * @param mixed $template
264
273
* @return bool|mixed
265
- * @throws dml_exception
266
274
*/
267
275
private function get_user ($ template ) {
268
276
$ user = false ;
@@ -300,12 +308,13 @@ private function get_user($template) {
300
308
301
309
/**
302
310
* Get random record.
303
- * @param $sql
304
- * @param null $params
311
+ *
312
+ * @param string $sql SQL
313
+ * @param null|array $params
305
314
* @return mixed
306
315
* @throws dml_exception
307
316
*/
308
- private function random_record ($ sql , $ params= null ) {
317
+ private function random_record (string $ sql , ? array $ params = null ) {
309
318
global $ DB ;
310
319
if ($ DB ->get_dbfamily () == 'mysql ' ) {
311
320
$ sql = $ sql . " ORDER BY rand() LIMIT 1 " ;
0 commit comments