MDL-67114 core: php74 fix. Fix use of scalar as array in core

There are various places where it's not guaranteed that the
variable being used is array, and instead, can be null, bool, int...

We need to check that because php74 warns about it.

Where possible we have used the coalesce operator as
replacement for isset() ternary operations.
This commit is contained in:
Eloy Lafuente (stronk7)
2020-01-03 11:33:23 +01:00
parent c3a6437220
commit abc8f149ce
12 changed files with 22 additions and 13 deletions
+1 -1
View File
@@ -701,7 +701,7 @@ class question_usage_by_activity {
// Behaviour vars should not be processed by question type, just add prefix.
$behaviourvars = $this->get_question_attempt($slot)->get_behaviour()->get_expected_data();
foreach (array_keys($responsedata) as $responsedatakey) {
if ($responsedatakey[0] === '-') {
if (is_string($responsedatakey) && $responsedatakey[0] === '-') {
$behaviourvarname = substr($responsedatakey, 1);
if (isset($behaviourvars[$behaviourvarname])) {
// Expected behaviour var found.