MDL-66965 core: php74 curly 2 square braces changes

Note this only modified core files, still there are a lot
of curly brace uses but all them are within 3rd part
libraries and will be handled apart.
This commit is contained in:
Eloy Lafuente (stronk7)
2019-10-25 17:41:10 +02:00
parent 50a1d9372f
commit 88d29a1bb8
11 changed files with 22 additions and 22 deletions
+6 -6
View File
@@ -88,9 +88,9 @@ function stripUrl($path, $rootDir='') {
*/
function toNativePath(&$path) {
for ($count = 0 ; $count < strlen($path); ++$count) {
$chr = $path{$count};
$chr = $path[$count];
if (($chr == '\\') || ($chr == '/')) {
$path{$count} = '/';
$path[$count] = '/';
}
}
}
@@ -104,9 +104,9 @@ function toNativePath(&$path) {
*/
function toNativePath2(&$path) {
for ($count = 0 ; $count < strlen($path); ++$count) {
$chr = $path{$count};
$chr = $path[$count];
if (($chr == '\\') || ($chr == '/')) {
$path{$count} = DIRECTORY_SEPARATOR;
$path[$count] = DIRECTORY_SEPARATOR;
}
}
}
@@ -118,9 +118,9 @@ function toNativePath2(&$path) {
*/
function toUrlPath(&$path) {
for ($count = 0 ; $count < strlen($path); ++$count) {
$chr = $path{$count};
$chr = $path[$count];
if (($chr == '\\')) {
$path{$count} = '/';
$path[$count] = '/';
}
}
}
+1 -1
View File
@@ -41,7 +41,7 @@ $preview = optional_param('preview', null, PARAM_ALPHANUM);
// relative path must start with '/'
if (!$relativepath) {
print_error('invalidargorconf');
} else if ($relativepath{0} != '/') {
} else if ($relativepath[0] != '/') {
print_error('pathdoesnotstartslash');
}
+1 -1
View File
@@ -434,7 +434,7 @@ class enrol_ldap_plugin extends enrol_plugin {
$ignorehidden = $this->get_config('ignorehiddencourses');
foreach($flat_records as $course) {
$course = array_change_key_case($course, CASE_LOWER);
$idnumber = $course{$this->config->course_idnumber}[0];
$idnumber = $course[$this->config->course_idnumber][0];
$trace->output(get_string('synccourserole', 'enrol_ldap', array('idnumber'=>$idnumber, 'role_shortname'=>$role->shortname)));
// Does the course exist in moodle already?
+1 -1
View File
@@ -42,7 +42,7 @@ $forcedownload = optional_param('forcedownload', 0, PARAM_BOOL);
// relative path must start with '/', because of backup/restore!!!
if (!$relativepath) {
print_error('invalidargorconf');
} else if ($relativepath{0} != '/') {
} else if ($relativepath[0] != '/') {
print_error('pathdoesnotstartslash');
}
+4 -4
View File
@@ -721,19 +721,19 @@ class core_text {
if ($utf8char == '') {
return 0;
}
$ord0 = ord($utf8char{0});
$ord0 = ord($utf8char[0]);
if ($ord0 >= 0 && $ord0 <= 127) {
return $ord0;
}
$ord1 = ord($utf8char{1});
$ord1 = ord($utf8char[1]);
if ($ord0 >= 192 && $ord0 <= 223) {
return ($ord0 - 192) * 64 + ($ord1 - 128);
}
$ord2 = ord($utf8char{2});
$ord2 = ord($utf8char[2]);
if ($ord0 >= 224 && $ord0 <= 239) {
return ($ord0 - 224) * 4096 + ($ord1 - 128) * 64 + ($ord2 - 128);
}
$ord3 = ord($utf8char{3});
$ord3 = ord($utf8char[3]);
if ($ord0 >= 240 && $ord0 <= 247) {
return ($ord0 - 240) * 262144 + ($ord1 - 128 )* 4096 + ($ord2 - 128) * 64 + ($ord3 - 128);
}
+1 -1
View File
@@ -5734,7 +5734,7 @@ function moodle_process_email($modargs, $body) {
global $DB;
// The first char should be an unencoded letter. We'll take this as an action.
switch ($modargs{0}) {
switch ($modargs[0]) {
case 'B': { // Bounce.
list(, $userid) = unpack('V', base64_decode(substr($modargs, 1, 8)));
if ($user = $DB->get_record("user", array('id' => $userid), "id,email")) {
+3 -3
View File
@@ -2978,10 +2978,10 @@ function obfuscate_email($email) {
$length = strlen($email);
$obfuscated = '';
while ($i < $length) {
if (rand(0, 2) && $email{$i}!='@') { // MDL-20619 some browsers have problems unobfuscating @.
$obfuscated.='%'.dechex(ord($email{$i}));
if (rand(0, 2) && $email[$i]!='@') { // MDL-20619 some browsers have problems unobfuscating @.
$obfuscated.='%'.dechex(ord($email[$i]));
} else {
$obfuscated.=$email{$i};
$obfuscated.=$email[$i];
}
$i++;
}
+1 -1
View File
@@ -147,7 +147,7 @@ class WikiToMarkdown {
$count = 0;
}
else {
$listchar = $line{0};
$listchar = $line[0];
$count = strspn( $line, $listchar );
$line = preg_replace( "/^[".$listchar."]+ /i", "", $line );
}
@@ -157,9 +157,9 @@ class quiz_statistics_question_stats_testcase extends basic_testcase {
$cnt = count($items);
for ($key = 0; $key < $cnt; $key++) {
if ($items[$key]!='') {
if ($start = ($items[$key]{0}=='"')) {
if ($start = ($items[$key][0]=='"')) {
$items[$key] = substr($items[$key], 1);
while (!$end = ($items[$key]{strlen($items[$key])-1}=='"')) {
while (!$end = ($items[$key][strlen($items[$key])-1]=='"')) {
$item = $items[$key];
unset($items[$key]);
$key++;
+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 ($responsedatakey[0] === '-') {
$behaviourvarname = substr($responsedatakey, 1);
if (isset($behaviourvars[$behaviourvarname])) {
// Expected behaviour var found.
+1 -1
View File
@@ -283,7 +283,7 @@ class qformat_gift extends qformat_default {
} else if ($answertext == '') {
$question->qtype = 'essay';
} else if ($answertext{0} == '#') {
} else if ($answertext[0] == '#') {
$question->qtype = 'numerical';
} else if (strpos($answertext, '~') !== false) {