Skip to content

Commit 2074d06

Browse files
committed
Refrain using {} for string offsets, PHP 7.4 compatibility
1 parent efe1118 commit 2074d06

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ s Logging change log
33

44
## ?.?.? / ????-??-??
55

6+
* Made compatible with PHP 7.4 - refrain using `{}` for string offsets
7+
(@thekid)
68
* Replaced all calls to the deprecated `xp::stringOf()` to use the method
79
from `util.Objects`.
810
(@thekid)

src/main/php/util/log/layout/PatternLayout.class.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php namespace util\log\layout;
22

33
use lang\IllegalArgumentException;
4-
use util\log\LoggingEvent;
54
use util\log\LogLevel;
5+
use util\log\LoggingEvent;
66

77
/**
88
* Pattern layout
@@ -37,11 +37,11 @@ class PatternLayout extends \util\log\Layout {
3737
*/
3838
public function __construct($format) {
3939
for ($i= 0, $s= strlen($format); $i < $s; $i++) {
40-
if ('%' === $format{$i}) {
40+
if ('%' === $format[$i]) {
4141
if (++$i >= $s) {
4242
throw new IllegalArgumentException('Not enough input at position '.($i - 1));
4343
}
44-
switch ($format{$i}) {
44+
switch ($format[$i]) {
4545
case '%': { // Literal percent
4646
$this->format[]= '%';
4747
break;
@@ -51,14 +51,14 @@ public function __construct($format) {
5151
break;
5252
}
5353
default: { // Any other character - verify it's supported
54-
if (!strspn($format{$i}, 'mclLtdpx')) {
55-
throw new IllegalArgumentException('Unknown format token "'.$format{$i}.'"');
54+
if (!strspn($format[$i], 'mclLtdpx')) {
55+
throw new IllegalArgumentException('Unknown format token "'.$format[$i].'"');
5656
}
57-
$this->format[]= '%'.$format{$i};
57+
$this->format[]= '%'.$format[$i];
5858
}
5959
}
6060
} else {
61-
$this->format[]= $format{$i};
61+
$this->format[]= $format[$i];
6262
}
6363
}
6464
}

0 commit comments

Comments
 (0)