Skip to content

Commit adeacf9

Browse files
authored
Fix all errors for PHPCS (#867)
* Resolve phpcs errors and some warnings.
1 parent 5472bf5 commit adeacf9

File tree

247 files changed

+1358
-1263
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

247 files changed

+1358
-1263
lines changed

ajax/moveback_to_log.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
//
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/>.
16+
1617
/**
1718
* Prepare events to replay.
1819
*

classes/log/moveback.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
* @subpackage log
2828
* @author Záborski László <[email protected]>
2929
* @copyright 2020 Learning Pool Ltd (http://learningpool.com)
30+
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
3031
*/
3132
class moveback {
3233

@@ -40,7 +41,7 @@ class moveback {
4041
*
4142
* @var array event ids[]
4243
*/
43-
protected $eventids = array();
44+
protected $eventids = [];
4445

4546
/**
4647
* The table where the process works
@@ -68,7 +69,7 @@ class moveback {
6869
*
6970
* @var string
7071
*/
71-
protected $params = array();
72+
protected $params = [];
7273

7374
/**
7475
* Standard constructor for class.
@@ -123,9 +124,9 @@ protected function move_event($event) {
123124
$event->type = $this->type;
124125

125126
if ($this->historical) {
126-
$params = array(
127-
'logstorestandardlogid' => $event->id
128-
);
127+
$params = [
128+
'logstorestandardlogid' => $event->id,
129+
];
129130

130131
$event->logstorestandardlogid = $event->id;
131132

@@ -136,9 +137,9 @@ protected function move_event($event) {
136137
} else {
137138
unset($event->errortype, $event->response);
138139

139-
$params = array(
140-
'id' => $event->id
141-
);
140+
$params = [
141+
'id' => $event->id,
142+
];
142143
}
143144

144145
if (!$skipinsert) {

classes/log/store.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
require_once($CFG->dirroot . '/admin/tool/log/store/xapi/lib.php');
2222

2323
use core_plugin_manager;
24-
use \tool_log\log\writer as log_writer;
25-
use \tool_log\log\manager as log_manager;
26-
use \tool_log\helper\store as helper_store;
27-
use \tool_log\helper\reader as helper_reader;
28-
use \tool_log\helper\buffered_writer as helper_writer;
29-
use \core\event\base as event_base;
30-
use \stdClass as php_obj;
24+
use tool_log\log\writer as log_writer;
25+
use tool_log\log\manager as log_manager;
26+
use tool_log\helper\store as helper_store;
27+
use tool_log\helper\reader as helper_reader;
28+
use tool_log\helper\buffered_writer as helper_writer;
29+
use core\event\base as event_base;
30+
use stdClass as php_obj;
3131
/**
3232
* Processes events and enables them to be sent to a logstore.
3333
*
@@ -80,8 +80,8 @@ protected function is_event_ignored(event_base $event) {
8080
protected function get_event_id($event) {
8181
global $DB;
8282

83-
$sqlparams = array();
84-
$where = array('1 = 1');
83+
$sqlparams = [];
84+
$where = ['1 = 1'];
8585

8686
if (!empty($event->eventname)) {
8787
$sqlparams['eventname'] = $event->eventname;
@@ -292,13 +292,13 @@ protected function get_handler_config() {
292292
$source = [
293293
'source_url' => 'http://totaralearning.com',
294294
'source_name' => 'Totara Learn',
295-
'source_version' => $CFG->totara_version
295+
'source_version' => $CFG->totara_version,
296296
];
297297
} else {
298298
$source = [
299299
'source_url' => 'http://moodle.org',
300300
'source_name' => 'Moodle',
301-
'source_version' => $CFG->release
301+
'source_version' => $CFG->release,
302302
];
303303
}
304304

@@ -322,7 +322,7 @@ public function is_logging() {
322322
* @return array of objects of events.
323323
*/
324324
protected function convert_array_to_objects($events) {
325-
$return = array();
325+
$return = [];
326326

327327
if (!empty($events)) {
328328
foreach ($events as $event) {

classes/privacy/provider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class provider implements
4949
* @param collection $collection a reference to the collection to use to store the metadata.
5050
* @return collection the updated collection of metadata items.
5151
*/
52-
public static function get_metadata(collection $collection) : collection {
52+
public static function get_metadata(collection $collection): collection {
5353
$collection->add_database_table(
5454
'logstore_xapi_log',
5555
[
@@ -75,7 +75,7 @@ public static function get_metadata(collection $collection) : collection {
7575
* @param int $userid The user to search.
7676
* @return contextlist $contextlist The contextlist containing the list of contexts used in this plugin.
7777
*/
78-
public static function get_contexts_for_userid(int $userid) : contextlist {
78+
public static function get_contexts_for_userid(int $userid): contextlist {
7979
return new contextlist();
8080
}
8181

classes/task/sendfailednotifications_task.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ private function get_failed_last_id($lastsentid) {
9797

9898
$params = [
9999
'threshold' => get_config('logstore_xapi', 'errornotificationtrigger'),
100-
'lastsentid' => $lastsentid
100+
'lastsentid' => $lastsentid,
101101
];
102102

103103
$lastnotification = $DB->get_record_sql($sql, $params);

cli/testdataseeder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ function create_user($username, $firstname, $lastname) {
274274
global $DB;
275275

276276
// Check if user exists.
277-
$user = $DB->get_record('user', array('username' => $username), "id,username");
277+
$user = $DB->get_record('user', ['username' => $username], "id,username");
278278
if ($user) {
279279
return $user->id;
280280
}
@@ -285,7 +285,7 @@ function create_user($username, $firstname, $lastname) {
285285
$user = $generator->create_user([
286286
'username' => $username,
287287
'firstname' => $firstname,
288-
'lastname' => $lastname
288+
'lastname' => $lastname,
289289
]);
290290
} catch (Exception $e) {
291291
echo $e->getMessage() . PHP_EOL;

db/access.php

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,29 +25,29 @@
2525

2626
defined('MOODLE_INTERNAL') || die();
2727

28-
$capabilities = array(
29-
'logstore/xapi:viewerrorlog' => array(
30-
'riskbitmask' => RISK_CONFIG,
31-
'captype' => 'read',
32-
'contextlevel' => CONTEXT_SYSTEM,
33-
'archetypes' => array(
34-
'manager' => CAP_ALLOW
35-
)
36-
),
37-
'logstore/xapi:manageerrors' => array(
38-
'riskbitmask' => RISK_CONFIG,
39-
'captype' => 'read',
40-
'contextlevel' => CONTEXT_SYSTEM,
41-
'archetypes' => array(
42-
'manager' => CAP_ALLOW
43-
)
44-
),
45-
'logstore/xapi:managehistoric' => array(
46-
'riskbitmask' => RISK_CONFIG,
47-
'captype' => 'read',
48-
'contextlevel' => CONTEXT_SYSTEM,
49-
'archetypes' => array(
50-
'manager' => CAP_ALLOW
51-
)
52-
)
53-
);
28+
$capabilities = [
29+
'logstore/xapi:viewerrorlog' => [
30+
'riskbitmask' => RISK_CONFIG,
31+
'captype' => 'read',
32+
'contextlevel' => CONTEXT_SYSTEM,
33+
'archetypes' => [
34+
'manager' => CAP_ALLOW,
35+
],
36+
],
37+
'logstore/xapi:manageerrors' => [
38+
'riskbitmask' => RISK_CONFIG,
39+
'captype' => 'read',
40+
'contextlevel' => CONTEXT_SYSTEM,
41+
'archetypes' => [
42+
'manager' => CAP_ALLOW,
43+
],
44+
],
45+
'logstore/xapi:managehistoric' => [
46+
'riskbitmask' => RISK_CONFIG,
47+
'captype' => 'read',
48+
'contextlevel' => CONTEXT_SYSTEM,
49+
'archetypes' => [
50+
'manager' => CAP_ALLOW,
51+
],
52+
],
53+
];

db/tasks.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,41 +26,41 @@
2626

2727
defined('MOODLE_INTERNAL') || die();
2828

29-
$tasks = array(
30-
array(
29+
$tasks = [
30+
[
3131
'classname' => '\logstore_xapi\task\emit_task',
3232
'blocking' => 0,
3333
'minute' => '*/1',
3434
'hour' => '*',
3535
'day' => '*',
3636
'dayofweek' => '*',
37-
'month' => '*'
38-
),
39-
array(
37+
'month' => '*',
38+
],
39+
[
4040
'classname' => '\logstore_xapi\task\failed_task',
4141
'blocking' => 0,
4242
'minute' => '*/30',
4343
'hour' => '*',
4444
'day' => '*',
4545
'dayofweek' => '*',
46-
'month' => '*'
47-
),
48-
array(
46+
'month' => '*',
47+
],
48+
[
4949
'classname' => '\logstore_xapi\task\historical_task',
5050
'blocking' => 0,
5151
'minute' => '0',
5252
'hour' => '*',
5353
'day' => '*',
5454
'dayofweek' => '*',
55-
'month' => '*'
56-
),
57-
array(
55+
'month' => '*',
56+
],
57+
[
5858
'classname' => '\logstore_xapi\task\sendfailednotifications_task',
5959
'blocking' => 0,
6060
'minute' => '*',
6161
'hour' => '*/2',
6262
'day' => '*',
6363
'dayofweek' => '*',
64-
'month' => '*'
65-
),
66-
);
64+
'month' => '*',
65+
],
66+
];

db/upgrade.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,19 @@ function create_xapi_log_table($dbman, $tablename) {
5959
$table->add_field('realuserid', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
6060

6161
// Adding keys to table.
62-
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
62+
$table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
6363

6464
// Adding indexes to table.
65-
$table->add_index('timecreated', XMLDB_INDEX_NOTUNIQUE, array('timecreated'));
66-
$table->add_index('course-time', XMLDB_INDEX_NOTUNIQUE, array('courseid', 'anonymous', 'timecreated'));
67-
$table->add_index('user-module', XMLDB_INDEX_NOTUNIQUE, array(
65+
$table->add_index('timecreated', XMLDB_INDEX_NOTUNIQUE, ['timecreated']);
66+
$table->add_index('course-time', XMLDB_INDEX_NOTUNIQUE, ['courseid', 'anonymous', 'timecreated']);
67+
$table->add_index('user-module', XMLDB_INDEX_NOTUNIQUE, [
6868
'userid',
6969
'contextlevel',
7070
'contextinstanceid',
7171
'crud',
7272
'edulevel',
73-
'timecreated'
74-
));
73+
'timecreated',
74+
]);
7575

7676
// Conditionally launch create table.
7777
if (!$dbman->table_exists($table)) {
@@ -97,12 +97,12 @@ function create_xapi_sent_log_table($dbman, $tablename) {
9797
$table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
9898

9999
// Adding keys to table.
100-
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
100+
$table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
101101

102102
// Adding indexes to table.
103-
$table->add_index('logstorestandardlogid', XMLDB_INDEX_NOTUNIQUE, array('logstorestandardlogid'));
104-
$table->add_index('type', XMLDB_INDEX_NOTUNIQUE, array('type'));
105-
$table->add_index('timecreated', XMLDB_INDEX_NOTUNIQUE, array('timecreated'));
103+
$table->add_index('logstorestandardlogid', XMLDB_INDEX_NOTUNIQUE, ['logstorestandardlogid']);
104+
$table->add_index('type', XMLDB_INDEX_NOTUNIQUE, ['type']);
105+
$table->add_index('timecreated', XMLDB_INDEX_NOTUNIQUE, ['timecreated']);
106106

107107
// Conditionally launch create table.
108108
if (!$dbman->table_exists($table)) {
@@ -127,7 +127,7 @@ function add_logstorestandardlogid_type_to_table($dbman, $tablename) {
127127
$dbman->add_field($table, $field);
128128
}
129129

130-
$index = new xmldb_index("logstorestandardlogid", XMLDB_INDEX_NOTUNIQUE, array('logstorestandardlogid'));
130+
$index = new xmldb_index("logstorestandardlogid", XMLDB_INDEX_NOTUNIQUE, ['logstorestandardlogid']);
131131
if (!$dbman->index_exists($table, $index)) {
132132
$dbman->add_index($table, $index);
133133
}
@@ -138,7 +138,7 @@ function add_logstorestandardlogid_type_to_table($dbman, $tablename) {
138138
$dbman->add_field($table, $field);
139139
}
140140

141-
$index = new xmldb_index("type", XMLDB_INDEX_NOTUNIQUE, array('type'));
141+
$index = new xmldb_index("type", XMLDB_INDEX_NOTUNIQUE, ['type']);
142142
if (!$dbman->index_exists($table, $index)) {
143143
$dbman->add_index($table, $index);
144144
}
@@ -173,12 +173,12 @@ function create_xapi_notification_table($dbman, $tablename) {
173173
$table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
174174

175175
// Adding keys to table.
176-
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
176+
$table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
177177

178178
// Adding indexes to table.
179-
$table->add_index('failedlogid', XMLDB_INDEX_NOTUNIQUE, array('failedlogid'));
180-
$table->add_index('email', XMLDB_INDEX_NOTUNIQUE, array('email'));
181-
$table->add_index('timecreated', XMLDB_INDEX_NOTUNIQUE, array('timecreated'));
179+
$table->add_index('failedlogid', XMLDB_INDEX_NOTUNIQUE, ['failedlogid']);
180+
$table->add_index('email', XMLDB_INDEX_NOTUNIQUE, ['email']);
181+
$table->add_index('timecreated', XMLDB_INDEX_NOTUNIQUE, ['timecreated']);
182182

183183
// Conditionally launch create table.
184184
if (!$dbman->table_exists($table)) {

0 commit comments

Comments
 (0)