Skip to content

Commit d009e73

Browse files
committed
PHP 8.0: Curly braces need to be square brackets for accessing arrays or strings
1 parent a86fc08 commit d009e73

File tree

6 files changed

+31
-31
lines changed

6 files changed

+31
-31
lines changed

functions/date_functions.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ function resolve_path($url, $rel_path) {
9292
);
9393

9494
$rel_path = str_replace('\\', '/', $rel_path);
95-
if ($rel_path{0} == '/') {
95+
if ($rel_path[0] == '/') {
9696
// Absolute path
9797
return $uri['proto'] . '://' . $auth . $uri['host'] . $uri['port'] . $rel_path;
9898
}

functions/ical_parser.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133
$nextline = fgets($ifile, 1024);
134134
$nextline = preg_replace("/[\r\n]/", '', $nextline);
135135
#handle continuation lines that start with either a space or a tab (MS Outlook)
136-
while (isset($nextline{0}) && ($nextline{0} == ' ' || $nextline{0} == "\t")) {
136+
while (isset($nextline[0]) && ($nextline[0] == ' ' || $nextline[0] == "\t")) {
137137
$line = $line . substr($nextline, 1);
138138
$nextline = fgets($ifile, 1024);
139139
$nextline = preg_replace("/[\r\n]/", '', $nextline);

functions/parse/parse_tzs.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
$nextline = fgets($ifile, 1024);
1515
$nextline = preg_replace("/[\r\n]/", '', $nextline);
1616
#handle continuation lines that start with either a space or a tab (MS Outlook)
17-
while (isset($nextline{0}) && ($nextline{0} == ' ' || $nextline{0} == "\t")) {
17+
while (isset($nextline[0]) && ($nextline[0] == ' ' || $nextline[0] == "\t")) {
1818
$line = $line . substr($nextline, 1);
1919
$nextline = fgets($ifile, 1024);
2020
$nextline = preg_replace("/[\r\n]/", '', $nextline);

lib/HTTP/WebDAV/Server.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -1713,7 +1713,7 @@ function lock_response_helper($options, $status)
17131713
// set headers before we start printing
17141714
$this->http_status($status);
17151715

1716-
if ($status{0} == 2) { // 2xx states are ok
1716+
if ($status[0] == 2) { // 2xx states are ok
17171717
header('Content-Type: text/xml; charset="utf-8"');
17181718
header("Lock-Token: <$options[token]>");
17191719

@@ -1980,10 +1980,10 @@ function _new_uuid()
19801980
$uuid = md5(microtime() . getmypid()); // this should be random enough for now
19811981

19821982
// set variant and version fields for 'true' random uuid
1983-
$uuid{12} = '4';
1984-
$n = 8 + (ord($uuid{16}) & 3);
1983+
$uuid[12] = '4';
1984+
$n = 8 + (ord($uuid[16]) & 3);
19851985
$hex = '0123456789abcdef';
1986-
$uuid{16} = $hex{$n};
1986+
$uuid[16] = $hex[$n];
19871987

19881988
// return formated uuid
19891989
return substr($uuid, 0, 8) . '-' .
@@ -2018,7 +2018,7 @@ function _new_locktoken()
20182018
function _if_header_lexer($string, &$pos)
20192019
{
20202020
// skip whitespace
2021-
while (ctype_space($string{$pos})) {
2021+
while (ctype_space($string[$pos])) {
20222022
++$pos;
20232023
}
20242024

@@ -2028,7 +2028,7 @@ function _if_header_lexer($string, &$pos)
20282028
}
20292029

20302030
// get next character
2031-
$c = $string{$pos++};
2031+
$c = $string[$pos++];
20322032

20332033
// now it depends on what we found
20342034
switch ($c) {
@@ -2043,7 +2043,7 @@ function _if_header_lexer($string, &$pos)
20432043
// ETags are enclosed in [...]
20442044
case '[':
20452045
$type = 'ETAG_STRONG';
2046-
if ($string{$pos} == 'W') {
2046+
if ($string[$pos] == 'W') {
20472047
$type = 'ETAG_WEAK';
20482048
$pos += 2;
20492049
}

lib/bennu/iCalendar_properties.php

+11-11
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ function is_valid_value($value) {
713713
}
714714

715715
// Value must be positive
716-
return ($value{0} != '-');
716+
return ($value[0] != '-');
717717
}
718718
}
719719

@@ -736,11 +736,11 @@ function is_valid_value($value) {
736736
}
737737

738738
$pos = strpos($value, '/'); // We know there's only one / in there
739-
if($value{$pos - 1} != 'Z') {
739+
if($value[$pos - 1] != 'Z') {
740740
// Start time MUST be in UTC
741741
return false;
742742
}
743-
if($value{$pos + 1} != 'P' && $substr($value, -1) != 'Z') {
743+
if($value[$pos + 1] != 'P' && $substr($value, -1) != 'Z') {
744744
// If the second part is not a period, it MUST be in UTC
745745
return false;
746746
}
@@ -1170,13 +1170,13 @@ function is_valid_value($value) {
11701170
$escch = false;
11711171

11721172
for($i = 0; $i < $len; ++$i) {
1173-
if($value{$i} == ';' && !$escch) {
1173+
if($value[$i] == ';' && !$escch) {
11741174
// Token completed
11751175
$parts[] = substr($value, $from, $i - $from);
11761176
$from = $i + 1;
11771177
continue;
11781178
}
1179-
$escch = ($value{$i} == '\\');
1179+
$escch = ($value[$i] == '\\');
11801180
}
11811181
// Add one last token with the remaining text; if the value
11821182
// ended with a ';' it was illegal, so check that this token
@@ -1197,23 +1197,23 @@ function is_valid_value($value) {
11971197
return false;
11981198
}
11991199

1200-
if($parts[0]{0} < '1' || $parts[0]{0} > '4') {
1200+
if($parts[0][0] < '1' || $parts[0][0] > '4') {
12011201
return false;
12021202
}
12031203

12041204
$len = strlen($parts[0]);
12051205

12061206
// Max 3 levels, and can't end with a period
1207-
if($len > 5 || $parts[0]{$len - 1} == '.') {
1207+
if($len > 5 || $parts[0][$len - 1] == '.') {
12081208
return false;
12091209
}
12101210

12111211
for($i = 1; $i < $len; ++$i) {
1212-
if(($i & 1) == 1 && $parts[0]{$i} != '.') {
1212+
if(($i & 1) == 1 && $parts[0][$i] != '.') {
12131213
// Even-indexed chars must be periods
12141214
return false;
12151215
}
1216-
else if(($i & 1) == 0 && ($parts[0]{$i} < '0' || $parts[0]{$i} > '9')) {
1216+
else if(($i & 1) == 0 && ($parts[0][$i] < '0' || $parts[0][$i] > '9')) {
12171217
// Odd-indexed chars must be numbers
12181218
return false;
12191219
}
@@ -1237,8 +1237,8 @@ function is_valid_value($value) {
12371237
$parts[$i] .= '#'; // This guard token saves some conditionals in the loop
12381238

12391239
for($j = 0; $j < $len; ++$j) {
1240-
$thischar = $parts[$i]{$j};
1241-
$nextchar = $parts[$i]{$j + 1};
1240+
$thischar = $parts[$i][$j];
1241+
$nextchar = $parts[$i][$j + 1];
12421242
if($thischar == '\\') {
12431243
// Next char must now be one of ";,\nN"
12441244
if($nextchar != ';' && $nextchar != ',' && $nextchar != '\\' &&

lib/bennu/iCalendar_rfc2445.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,13 @@ function rfc2445_is_valid_value($value, $type) {
139139
}
140140

141141
$len = strlen($value);
142-
142+
143143
if($len % 4 != 0) {
144144
return false;
145145
}
146146

147147
for($i = 0; $i < $len; ++$i) {
148-
$ch = $value{$i};
148+
$ch = $value[$i];
149149
if(!($ch >= 'a' && $ch <= 'z' || $ch >= 'A' && $ch <= 'Z' || $ch >= '0' && $ch <= '9' || $ch == '-' || $ch == '+')) {
150150
if($ch == '=' && $len - $i <= 2) {
151151
continue;
@@ -194,7 +194,7 @@ function rfc2445_is_valid_value($value, $type) {
194194
return false;
195195
}
196196

197-
return($value{8} == 'T' &&
197+
return($value[8] == 'T' &&
198198
rfc2445_is_valid_value(substr($value, 0, 8), RFC2445_TYPE_DATE) &&
199199
rfc2445_is_valid_value(substr($value, 9), RFC2445_TYPE_TIME));
200200
break;
@@ -211,12 +211,12 @@ function rfc2445_is_valid_value($value, $type) {
211211
return false;
212212
}
213213

214-
if($value{0} == '+' || $value{0} == '-') {
214+
if($value[0] == '+' || $value[0] == '-') {
215215
$value = substr($value, 1);
216216
--$len; // Don't forget to update this!
217217
}
218218

219-
if($value{0} != 'P') {
219+
if($value[0] != 'P') {
220220
return false;
221221
}
222222

@@ -225,7 +225,7 @@ function rfc2445_is_valid_value($value, $type) {
225225
$allowed = 'WDT';
226226

227227
for($i = 1; $i < $len; ++$i) {
228-
$ch = $value{$i};
228+
$ch = $value[$i];
229229
if($ch >= '0' && $ch <= '9') {
230230
$num .= $ch;
231231
continue;
@@ -292,7 +292,7 @@ function rfc2445_is_valid_value($value, $type) {
292292
$int = false;
293293
$len = strlen($value);
294294
for($i = 0; $i < $len; ++$i) {
295-
switch($value{$i}) {
295+
switch($value[$i]) {
296296
case '-': case '+':
297297
// A sign can only be seen at position 0 and cannot be the only char
298298
if($i != 0 || $len == 1) {
@@ -332,7 +332,7 @@ function rfc2445_is_valid_value($value, $type) {
332332
return false;
333333
}
334334

335-
if($value{0} == '+' || $value{0} == '-') {
335+
if($value[0] == '+' || $value[0] == '-') {
336336
if(strlen($value) == 1) {
337337
return false;
338338
}
@@ -367,7 +367,7 @@ function rfc2445_is_valid_value($value, $type) {
367367
}
368368
else if(rfc2445_is_valid_value($parts[1], RFC2445_TYPE_DURATION)) {
369369
// The period MUST NOT be negative
370-
return ($parts[1]{0} != '-');
370+
return ($parts[1][0] != '-');
371371
}
372372

373373
// It seems to be illegal
@@ -734,7 +734,7 @@ function rfc2445_is_valid_value($value, $type) {
734734
return false;
735735
}
736736

737-
if($value{0} != '+' && $value{0} != '-') {
737+
if($value[0] != '+' && $value[0] != '-') {
738738
return false;
739739
}
740740

0 commit comments

Comments
 (0)