Skip to content

Commit d5d3033

Browse files
committed
Use [] for array offsets
1 parent b3d5de4 commit d5d3033

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

src/main/php/rdbms/StatementFormatter.class.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ public function format($fmt, $args) {
5555
// If offset == length, it was the last token, so return
5656
if ($offset >= $length) return $statement;
5757

58-
if ('"' === $fmt{$offset} || "'" === $fmt{$offset}) {
58+
if ('"' === $fmt[$offset] || "'" === $fmt[$offset]) {
5959

6060
// Escape string literals (which use double quote characters inside for escaping)
61-
$quote= $fmt{$offset};
61+
$quote= $fmt[$offset];
6262
$strlen= $offset+ 1;
6363
do {
6464
$strlen+= strcspn($fmt, $quote, $strlen);
65-
if ($strlen >= $length || $quote !== $fmt{$strlen+ 1}) break;
65+
if ($strlen >= $length || $quote !== $fmt[$strlen + 1]) break;
6666
$strlen+= 2;
6767
} while (true);
6868

@@ -71,39 +71,39 @@ public function format($fmt, $args) {
7171
}
7272

7373
$statement.= $this->dialect->escapeString(
74-
strtr(substr($fmt, $offset+ 1, $strlen- $offset- 1),
74+
strtr(substr($fmt, $offset + 1, $strlen- $offset- 1),
7575
['%%' => '%', $quote.$quote => $quote]
7676
));
7777
$offset= $strlen+ 1;
7878
continue;
79-
} else if (is_numeric($fmt{$offset+ 1})) {
79+
} else if (is_numeric($fmt[$offset + 1])) {
8080

8181
// Numeric argument type specifier, e.g. %1$s
8282
sscanf(substr($fmt, $offset), '%%%d$', $overrideOffset);
83-
$type= $fmt{$offset+ strlen($overrideOffset)+ 2};
84-
$offset+= strlen($overrideOffset)+ 3;
83+
$type= $fmt[$offset+ strlen($overrideOffset) + 2];
84+
$offset+= strlen($overrideOffset) + 3;
8585
if (!array_key_exists($overrideOffset- 1, $args)) {
86-
throw new SQLStateException('Missing argument #'.($overrideOffset- 1).' @offset '.$offset);
86+
throw new SQLStateException('Missing argument #'.($overrideOffset - 1).' @offset '.$offset);
8787
}
88-
$argument= $args[$overrideOffset- 1];
89-
} else if (false !== strpos($tokens, $fmt{$offset+ 1})) {
88+
$argument= $args[$overrideOffset - 1];
89+
} else if (false !== strpos($tokens, $fmt[$offset + 1])) {
9090

9191
// Known tokens
92-
$type= $fmt{$offset+ 1};
92+
$type= $fmt[$offset+ 1];
9393
$offset+= 2;
9494
if (!array_key_exists($argumentOffset, $args)) {
9595
throw new SQLStateException('Missing argument #'.$argumentOffset.' @offset '.$offset);
9696
}
9797
$argument= $args[$argumentOffset];
9898
$argumentOffset++;
99-
} else if ('%' == $fmt{$offset+ 1}) {
99+
} else if ('%' == $fmt[$offset + 1]) {
100100

101101
// Escape sign
102102
$statement.= '%';
103103
$offset+= 2;
104104
continue;
105105
} else {
106-
throw new SQLStateException('Unknown token "'.$fmt{$offset+ 1}.'"');
106+
throw new SQLStateException('Unknown token "'.$fmt[$offset + 1].'"');
107107
}
108108

109109
$statement.= $this->prepare($type, $argument);

src/main/php/rdbms/mysqlx/MySqlxProtocol.class.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ protected function length($data, &$consumed, $ll= false) {
195195
if (!isset($data[$consumed])) {
196196
return 0;
197197
}
198-
switch ($data{$consumed}) {
198+
switch ($data[$consumed]) {
199199
case "\373": $consumed+= 1; return null;
200200
case "\374": $consumed+= 3; return ord($data[$o+ 1]) + ord($data[$o+ 2]) * 256;
201201
case "\375": $consumed+= 4; return ord($data[$o+ 1]) + ord($data[$o+ 2]) * 256 + ord($data[$o+ 3]) * 65536;
@@ -234,7 +234,7 @@ protected function lbin($data, $l, &$consumed) {
234234
* @return string
235235
*/
236236
protected function lstr($data, &$consumed) {
237-
if ("\373" === $data{$consumed}) {
237+
if ("\373" === $data[$consumed]) {
238238
$consumed++;
239239
return null;
240240
}
@@ -280,7 +280,7 @@ protected function field_40($f) {
280280
$field['length']= $this->lbin($f, 4, $consumed);
281281
$field['type']= $this->lbin($f, 2, $consumed);
282282
$field['flags']= $this->lbin($f, 2, $consumed);
283-
$field['decimals']= ord($f{$consumed+ 1});
283+
$field['decimals']= ord($f[$consumed + 1]);
284284
return $field;
285285
}
286286

@@ -346,7 +346,7 @@ public function exec($sql) {
346346
*/
347347
public function fetch($fields) {
348348
$r= $this->read();
349-
if ("\376" === $r{0} && strlen($r) < 9) {
349+
if ("\376" === $r[0] && strlen($r) < 9) {
350350
$this->pkt= 0;
351351
return null;
352352
}
@@ -370,7 +370,7 @@ public function cancel() {
370370
do {
371371
$r= $this->read();
372372
$i++;
373-
} while (!("\376" === $r{0} && strlen($r) < 9));
373+
} while (!("\376" === $r[0] && strlen($r) < 9));
374374
$this->pkt= 0;
375375
return $i;
376376
}
@@ -457,7 +457,7 @@ protected function read() {
457457
// DEBUG Console::$err->writeLine('R-> ', new Bytes($buf));
458458

459459
// 0xFF indicates an error
460-
if ("\377" !== $buf{0}) return $buf;
460+
if ("\377" !== $buf[0]) return $buf;
461461

462462
$this->pkt= 0;
463463
$sqlstate= '00000';

0 commit comments

Comments
 (0)