Skip to content

Commit f49d45a

Browse files
committed
codecheck-comply - array declaration
1 parent fba9b1a commit f49d45a

File tree

269 files changed

+46354
-46354
lines changed

Some content is hidden

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

269 files changed

+46354
-46354
lines changed

adminui/answertests.php

+11-11
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@
6565
if ($anstest === 'ALL') {
6666
$tests = stack_answertest_test_data::get_all();
6767
} else if (!$anstest) {
68-
$tests = array();
68+
$tests = [];
6969
} else {
7070
$tests = stack_answertest_test_data::get_tests_for($anstest);
7171
}
7272

7373
// Set up the results table.
74-
$columns = array(
74+
$columns = [
7575
'name' => stack_string('answertest_ab'),
7676
'passed' => stack_string('testsuitecolpassed'),
7777
'studentanswer' => stack_string('studentanswer'),
@@ -81,7 +81,7 @@
8181
'error' => stack_string('testsuitecolerror'),
8282
'feedback' => stack_string('testsuitefeedback'),
8383
'answernote' => stack_string('answernote'),
84-
);
84+
];
8585

8686
if ($anstest !== 'ALL') {
8787
array_shift($columns);
@@ -102,7 +102,7 @@
102102

103103
// Run the tests.
104104
$allpassed = true;
105-
$failedtable = array();
105+
$failedtable = [];
106106
$notests = 0;
107107
$start = microtime(true);
108108

@@ -122,8 +122,8 @@
122122
reset($columns);
123123
$firstcol = key($columns);
124124
// This is a slight cludge to get multiple columns in a row.
125-
$notes = html_writer::tag('td', $test->notes, array('colspan' => '8'));
126-
$table->add_data(array($notes), 'notes');
125+
$notes = html_writer::tag('td', $test->notes, ['colspan' => '8']);
126+
$table->add_data([$notes], 'notes');
127127
}
128128

129129
set_time_limit(30);
@@ -160,7 +160,7 @@
160160
if ($rawmark !== $test->expectedscore && $test->expectedscore > 0) {
161161
$mark = $rawmark . ' <> ' . $test->expectedscore;
162162
}
163-
$row = array(
163+
$row = [
164164
'name' => $test->name,
165165
'passed' => $passedcol,
166166
'studentanswer' => html_writer::tag('pre', $sans),
@@ -170,7 +170,7 @@
170170
'error' => $error,
171171
'feedback' => format_text($feedback),
172172
'answernote' => $ansnote,
173-
);
173+
];
174174
if (!$passed) {
175175
$row['answernote'] .= html_writer::tag('pre', $trace);
176176
$failedtable[] = $row;
@@ -186,9 +186,9 @@
186186
$took = (microtime(true) - $start);
187187
$rtook = round($took, 5);
188188
$pertest = round($took / $notests, 5);
189-
echo '<p>'.stack_string('testsuitenotests', array('no' => $notests));
190-
echo '<br/>'.stack_string('testsuiteteststook', array('time' => $rtook));
191-
echo '<br/>'.stack_string('testsuiteteststookeach', array('time' => $pertest));
189+
echo '<p>'.stack_string('testsuitenotests', ['no' => $notests]);
190+
echo '<br/>'.stack_string('testsuiteteststook', ['time' => $rtook]);
191+
echo '<br/>'.stack_string('testsuiteteststookeach', ['time' => $pertest]);
192192
echo '</p>';
193193

194194
$config = get_config('qtype_stack');

adminui/bulktest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
// Calling $PAGE->set_context should be enough, but it seems that it is not.
5959
// Therefore, we get the right $cm and $course, and set things up ourselves.
6060
$cm = get_coursemodule_from_id(false, $context->instanceid, 0, false, MUST_EXIST);
61-
$PAGE->set_cm($cm, $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST));
61+
$PAGE->set_cm($cm, $DB->get_record('course', ['id' => $cm->course], '*', MUST_EXIST));
6262
}
6363

6464
// Create the helper class.

adminui/bulktestall.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
$startfromcontextid = optional_param('startfromcontextid', 0, PARAM_INT);
4242

4343
$skippreviouspasses = optional_param('skippreviouspasses', false, PARAM_BOOL);
44-
$urlparams = array();
44+
$urlparams = [];
4545
if ($skippreviouspasses) {
4646
$urlparams['skippreviouspasses'] = 1;
4747
}
@@ -63,7 +63,7 @@
6363
// Create the helper class.
6464
$bulktester = new stack_bulk_tester();
6565
$allpassed = true;
66-
$allfailing = array();
66+
$allfailing = [];
6767
$skipping = $startfromcontextid != 0;
6868

6969
// Release the session, so the user can do other things while this runs.
@@ -91,7 +91,7 @@
9191
foreach ($failing as $key => $arrvals) {
9292
// Guard clause here to future proof any new fields from the bulk tester.
9393
if (!array_key_exists($key, $allfailing)) {
94-
$allfailing[$key] = array();
94+
$allfailing[$key] = [];
9595
}
9696
$allfailing[$key] = array_merge($allfailing[$key], $arrvals);
9797
}

adminui/bulktestindex.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656

5757
// Find in which contexts the user can edit questions.
5858
$questionsbycontext = $bulktester->get_num_stack_questions_by_context();
59-
$availablequestionsbycontext = array();
59+
$availablequestionsbycontext = [];
6060
foreach ($questionsbycontext as $contextid => $numquestions) {
6161
$context = context::instance_by_id($contextid);
6262
if (has_capability('moodle/question:editall', $context)) {
@@ -69,9 +69,9 @@
6969
$name = $course->get_context_name(true, true) . ': ' . $name;
7070
}
7171
}
72-
$availablequestionsbycontext[$name] = array(
72+
$availablequestionsbycontext[$name] = [
7373
'contextid' => $contextid,
74-
'numquestions' => $numquestions);
74+
'numquestions' => $numquestions];
7575
}
7676
}
7777

@@ -86,24 +86,24 @@
8686
$contextid = $info['contextid'];
8787
$numquestions = $info['numquestions'];
8888

89-
$testallurl = new moodle_url('/question/type/stack/adminui/bulktest.php', array('contextid' => $contextid));
89+
$testallurl = new moodle_url('/question/type/stack/adminui/bulktest.php', ['contextid' => $contextid]);
9090
$testalllink = html_writer::link($testallurl,
91-
get_string('bulktestallincontext', 'qtype_stack'), array('title' => get_string('testalltitle', 'qtype_stack')));
91+
get_string('bulktestallincontext', 'qtype_stack'), ['title' => get_string('testalltitle', 'qtype_stack')]);
9292
$litext = $name . ' (' . $numquestions . ') ' . $testalllink;
9393

9494
echo html_writer::start_tag('details');
9595
echo html_writer::tag('summary', $litext);
9696

9797
$categories = $bulktester->get_categories_for_context($contextid);
98-
echo html_writer::start_tag('ul', array('class' => 'expandable'));
98+
echo html_writer::start_tag('ul', ['class' => 'expandable']);
9999
foreach ($categories as $cat) {
100100
if ($cat->count > 0) {
101101
$url = new moodle_url('/question/type/stack/adminui/bulktest.php',
102-
array('contextid' => $contextid, 'categoryid' => $cat->id));
102+
['contextid' => $contextid, 'categoryid' => $cat->id]);
103103
$linktext = $cat->name . ' (' . $cat->count . ')';
104104
$link = html_writer::link($url, $linktext);
105105
echo html_writer::tag('li', $link,
106-
array('title' => get_string('testallincategory', 'qtype_stack')));
106+
['title' => get_string('testallincategory', 'qtype_stack')]);
107107
}
108108
}
109109
echo html_writer::end_tag('ul');

adminui/cascacheview.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
$context = context_system::instance();
3636
require_capability('qtype/stack:usediagnostictools', $context);
3737

38-
$urlparams = array();
38+
$urlparams = [];
3939

4040
$context = context_system::instance();
4141
$PAGE->set_context($context);
@@ -57,7 +57,7 @@
5757
// Ends with $ which is bad.
5858
// Now can contain $ signs elsewhere as well...
5959
$ast = maxima_parser_utils::parse(str_replace('$', ';', $item->command));
60-
$str = $ast->toString(array('pretty' => true));
60+
$str = $ast->toString(['pretty' => true]);
6161
$str = str_replace('&', '&amp;', $str);
6262
$str = str_replace('<', '&lt;', $str);
6363
$str = str_replace('>', '&gt;', $str);

adminui/caschat.php

+21-21
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
$context = context_system::instance();
4747
$PAGE->set_context($context);
4848
require_capability('qtype/stack:usediagnostictools', $context);
49-
$urlparams = array();
49+
$urlparams = [];
5050
} else {
5151
// Load the necessary data.
5252
if ($qubaid !== '') {
@@ -57,7 +57,7 @@
5757
} else {
5858
$question = question_bank::load_question($questionid);
5959
}
60-
$questiondata = $DB->get_record('question', array('id' => $questionid), '*', MUST_EXIST);
60+
$questiondata = $DB->get_record('question', ['id' => $questionid], '*', MUST_EXIST);
6161

6262
// Process any other URL parameters, and do require_login.
6363
list($context, $seed, $urlparams) = qtype_stack_setup_question_test_page($question);
@@ -73,7 +73,7 @@
7373
$displaytext = '';
7474
$debuginfo = '';
7575
$errs = '';
76-
$varerrs = array();
76+
$varerrs = [];
7777

7878
if ($qubaid !== '' && optional_param('initialise', '', PARAM_RAW)) {
7979
// ISS-1110 Handle calls from questiontestrun.php.
@@ -124,14 +124,14 @@
124124
$options->set_site_defaults();
125125
$options->set_option('simplify', $simp);
126126

127-
$session = new stack_cas_session2(array(), $options);
127+
$session = new stack_cas_session2([], $options);
128128
if ($vars || $inps) {
129129
$keyvals = new stack_cas_keyval($vars . "\n" . $inps, $options, 0);
130130
$keyvals->get_valid();
131131
$varerrs = $keyvals->get_errors();
132132
if ($keyvals->get_valid()) {
133133
$kvcode = $keyvals->compile('test');
134-
$statements = array();
134+
$statements = [];
135135
if ($kvcode['contextvariables']) {
136136
$statements[] = new stack_secure_loader($kvcode['contextvariables'], 'caschat');
137137
}
@@ -155,7 +155,7 @@
155155
$errs = array_merge($errs, $session->get_errors(false));
156156
if ($errs) {
157157
$errs = stack_string_error('errors') . ': ' . implode(' ', array_unique($errs));
158-
$errs = html_writer::tag('div', $errs, array('class' => 'error'));
158+
$errs = html_writer::tag('div', $errs, ['class' => 'error']);
159159
} else {
160160
$errs = '';
161161
}
@@ -164,10 +164,10 @@
164164
// Save updated data in the DB when everything is valid.
165165
if ($questionid && $savedb) {
166166
$DB->set_field('question', 'generalfeedback', $string,
167-
array('id' => $questionid));
167+
['id' => $questionid]);
168168
$DB->set_field('qtype_stack_options', 'questionvariables', $vars,
169-
array('questionid' => $questionid));
170-
$DB->set_field('qtype_stack_options', 'compiledcache', null, array('questionid' => $questionid));
169+
['questionid' => $questionid]);
170+
$DB->set_field('qtype_stack_options', 'compiledcache', null, ['questionid' => $questionid]);
171171
// Invalidate the question definition cache.
172172
stack_clear_vle_question_cache($questionid);
173173

@@ -184,15 +184,15 @@
184184

185185
$qtype = new qtype_stack();
186186
$qtestlink = html_writer::link($qtype->get_question_test_url($question), stack_string('runquestiontests'),
187-
array('class' => 'nav-link'));
188-
echo html_writer::tag('nav', $qtestlink, array('class' => 'nav'));
187+
['class' => 'nav-link']);
188+
echo html_writer::tag('nav', $qtestlink, ['class' => 'nav']);
189189

190190
if ($savedmsg) {
191-
echo html_writer::tag('p', $savedmsg, array('class' => 'overallresult pass'));
191+
echo html_writer::tag('p', $savedmsg, ['class' => 'overallresult pass']);
192192
}
193193

194194
$out = html_writer::tag('summary', stack_string('questiontext'));
195-
$out .= html_writer::tag('pre', $question->questiontext, array('class' => 'questiontext'));
195+
$out .= html_writer::tag('pre', $question->questiontext, ['class' => 'questiontext']);
196196
echo html_writer::tag('details', $out);
197197
}
198198

@@ -207,17 +207,17 @@
207207
$fout .= html_writer::tag('p', implode($varerrs));
208208
$varlen = substr_count($vars, "\n") + 3;
209209
$fout .= html_writer::tag('p', html_writer::tag('textarea', $vars,
210-
array('cols' => 100, 'rows' => $varlen, 'name' => 'maximavars')));
210+
['cols' => 100, 'rows' => $varlen, 'name' => 'maximavars']));
211211
if ($questionid) {
212212
$inplen = substr_count($inps, "\n");
213213
$fout .= html_writer::tag('p', html_writer::tag('textarea', $inps,
214-
array('cols' => 100, 'rows' => $inplen, 'name' => 'inputs')));
214+
['cols' => 100, 'rows' => $inplen, 'name' => 'inputs']));
215215
}
216216
if ($simp) {
217217
$fout .= stack_string('autosimplify').' '.
218-
html_writer::empty_tag('input', array('type' => 'checkbox', 'checked' => $simp, 'name' => 'simp'));
218+
html_writer::empty_tag('input', ['type' => 'checkbox', 'checked' => $simp, 'name' => 'simp']);
219219
} else {
220-
$fout .= stack_string('autosimplify').' '.html_writer::empty_tag('input', array('type' => 'checkbox', 'name' => 'simp'));
220+
$fout .= stack_string('autosimplify').' '.html_writer::empty_tag('input', ['type' => 'checkbox', 'name' => 'simp']);
221221
}
222222
if ($questionid) {
223223
$fout .= html_writer::tag('h2', stack_string('generalfeedback'));
@@ -227,16 +227,16 @@
227227
$fout .= html_writer::tag('p', $errs);
228228
$stringlen = max(substr_count($string, "\n") + 3, 8);
229229
$fout .= html_writer::tag('p', html_writer::tag('textarea', $string,
230-
array('cols' => 100, 'rows' => $stringlen, 'name' => 'cas')));
230+
['cols' => 100, 'rows' => $stringlen, 'name' => 'cas']));
231231
$fout .= html_writer::start_tag('p');
232232
$fout .= html_writer::empty_tag('input',
233-
array('type' => 'submit', 'name' => 'action', 'value' => stack_string('chat')));
233+
['type' => 'submit', 'name' => 'action', 'value' => stack_string('chat')]);
234234
if ($questionid && !$varerrs) {
235235
$fout .= html_writer::empty_tag('input',
236-
array('type' => 'submit', 'name' => 'action', 'value' => stack_string('savechat')));
236+
['type' => 'submit', 'name' => 'action', 'value' => stack_string('savechat')]);
237237
}
238238
$fout .= html_writer::end_tag('p');
239-
echo html_writer::tag('form', $fout, array('action' => $PAGE->url, 'method' => 'post'));
239+
echo html_writer::tag('form', $fout, ['action' => $PAGE->url, 'method' => 'post']);
240240

241241
if ('' != trim($debuginfo)) {
242242
echo $OUTPUT->box($debuginfo);

adminui/compiledquestion.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
$context = context_system::instance();
4040
require_capability('qtype/stack:usediagnostictools', $context);
4141

42-
$urlparams = array();
42+
$urlparams = [];
4343

4444
$context = context_system::instance();
4545
$PAGE->set_context($context);

adminui/dependencies.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
$context = context_system::instance();
4141
require_capability('qtype/stack:usediagnostictools', $context);
4242

43-
$urlparams = array();
43+
$urlparams = [];
4444

4545
$context = context_system::instance();
4646
$PAGE->set_context($context);
@@ -87,25 +87,25 @@
8787
' questions that have not been succesfully compiled.</p>';
8888

8989
echo $OUTPUT->single_button(
90-
new moodle_url($PAGE->url, array('includes' => 1, 'sesskey' => sesskey())),
90+
new moodle_url($PAGE->url, ['includes' => 1, 'sesskey' => sesskey()]),
9191
'Find "includes"');
9292
echo $OUTPUT->single_button(
93-
new moodle_url($PAGE->url, array('jsxgraphs' => 1, 'sesskey' => sesskey())),
93+
new moodle_url($PAGE->url, ['jsxgraphs' => 1, 'sesskey' => sesskey()]),
9494
'Find "jsxgraphs"');
9595
echo $OUTPUT->single_button(
96-
new moodle_url($PAGE->url, array('geogebras' => 1, 'sesskey' => sesskey())),
96+
new moodle_url($PAGE->url, ['geogebras' => 1, 'sesskey' => sesskey()]),
9797
'Find "geogebra"');
9898
echo $OUTPUT->single_button(
99-
new moodle_url($PAGE->url, array('script' => 1, 'sesskey' => sesskey())),
99+
new moodle_url($PAGE->url, ['script' => 1, 'sesskey' => sesskey()]),
100100
'Find "<script"');
101101
echo $OUTPUT->single_button(
102-
new moodle_url($PAGE->url, array('PLUGINFILE' => 1, 'sesskey' => sesskey())),
102+
new moodle_url($PAGE->url, ['PLUGINFILE' => 1, 'sesskey' => sesskey()]),
103103
'Find "@@PLUGINFILE@@"');
104104
echo $OUTPUT->single_button(
105-
new moodle_url($PAGE->url, array('langs' => 1, 'sesskey' => sesskey())),
105+
new moodle_url($PAGE->url, ['langs' => 1, 'sesskey' => sesskey()]),
106106
'Find "langs"');
107107
echo $OUTPUT->single_button(
108-
new moodle_url($PAGE->url, array('todo' => 1, 'sesskey' => sesskey())),
108+
new moodle_url($PAGE->url, ['todo' => 1, 'sesskey' => sesskey()]),
109109
'Find "todo"');
110110

111111
if (data_submitted() && optional_param('includes', false, PARAM_BOOL)) {

0 commit comments

Comments
 (0)