Skip to content

Commit b1ce0c7

Browse files
authored
Removed curly brace array access for > PHP 7.4 use
As outlined in the RFC - https://wiki.php.net/rfc/deprecate_curly_braces_array_access array access via curly braces is now deprecated. And for people searching this issue in the future: ErrorException: Array and string offset access syntax with curly braces is deprecated in AnimGif.php:206
1 parent 7140162 commit b1ce0c7

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

src/GifCreator/AnimGif.php

+22-22
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,9 @@ public function create($frames, $durations = self::DEFAULT_DURATION, $loop = 0)
206206
$this->transparent_color = imagecolortransparent($resourceImg);
207207
}
208208

209-
for ($j = (13 + 3 * (2 << (ord($this->frameSources[$i] { 10 }) & 0x07))), $k = TRUE; $k; $j++) {
209+
for ($j = (13 + 3 * (2 << (ord($this->frameSources[$i][10]) & 0x07))), $k = TRUE; $k; $j++) {
210210

211-
switch ($this->frameSources[$i] { $j }) {
211+
switch ($this->frameSources[$i][$j]) {
212212

213213
case '!':
214214
if ((substr($this->frameSources[$i], ($j + 3), 8)) == 'NETSCAPE') {
@@ -295,9 +295,9 @@ protected function gifAddHeader()
295295
{
296296
$cmap = 0;
297297

298-
if (ord($this->frameSources[0] { 10 }) & 0x80) {
298+
if (ord($this->frameSources[0][10]) & 0x80) {
299299

300-
$cmap = 3 * (2 << (ord($this->frameSources[0] { 10 }) & 0x07));
300+
$cmap = 3 * (2 << (ord($this->frameSources[0][10]) & 0x07));
301301

302302
$this->gif .= substr($this->frameSources[0], 6, 7);
303303
$this->gif .= substr($this->frameSources[0], 13, $cmap);
@@ -314,34 +314,34 @@ protected function gifAddHeader()
314314
*/
315315
protected function addGifFrames($i, $d)
316316
{
317-
$Locals_str = 13 + 3 * (2 << (ord($this->frameSources[ $i ] { 10 }) & 0x07));
317+
$Locals_str = 13 + 3 * (2 << (ord($this->frameSources[ $i ][10]) & 0x07));
318318

319319
$Locals_end = strlen($this->frameSources[$i]) - $Locals_str - 1;
320320
$Locals_tmp = substr($this->frameSources[$i], $Locals_str, $Locals_end);
321321

322-
$Global_len = 2 << (ord($this->frameSources[0 ] { 10 }) & 0x07);
323-
$Locals_len = 2 << (ord($this->frameSources[$i] { 10 }) & 0x07);
322+
$Global_len = 2 << (ord($this->frameSources[0][10]) & 0x07);
323+
$Locals_len = 2 << (ord($this->frameSources[$i][10]) & 0x07);
324324

325-
$Global_rgb = substr($this->frameSources[ 0], 13, 3 * (2 << (ord($this->frameSources[ 0] { 10 }) & 0x07)));
326-
$Locals_rgb = substr($this->frameSources[$i], 13, 3 * (2 << (ord($this->frameSources[$i] { 10 }) & 0x07)));
325+
$Global_rgb = substr($this->frameSources[ 0], 13, 3 * (2 << (ord($this->frameSources[0][10]) & 0x07)));
326+
$Locals_rgb = substr($this->frameSources[$i], 13, 3 * (2 << (ord($this->frameSources[$i][10]) & 0x07)));
327327

328328
$Locals_ext = "!\xF9\x04" . chr(($this->dis << 2) + 0) . word2bin($d) . "\x0\x0";
329329

330-
if ($this->transparent_color > -1 && ord($this->frameSources[$i] { 10 }) & 0x80) {
330+
if ($this->transparent_color > -1 && ord($this->frameSources[$i][10]) & 0x80) {
331331

332-
for ($j = 0; $j < (2 << (ord($this->frameSources[$i] { 10 } ) & 0x07)); $j++) {
332+
for ($j = 0; $j < (2 << (ord($this->frameSources[$i][10]) & 0x07)); $j++) {
333333

334-
if (ord($Locals_rgb { 3 * $j + 0 }) == (($this->transparent_color >> 16) & 0xFF) &&
335-
ord($Locals_rgb { 3 * $j + 1 }) == (($this->transparent_color >> 8) & 0xFF) &&
336-
ord($Locals_rgb { 3 * $j + 2 }) == (($this->transparent_color >> 0) & 0xFF)
334+
if (ord($Locals_rgb[ 3 * $j + 0 ]) == (($this->transparent_color >> 16) & 0xFF) &&
335+
ord($Locals_rgb[ 3 * $j + 1 ]) == (($this->transparent_color >> 8) & 0xFF) &&
336+
ord($Locals_rgb[ 3 * $j + 2 ]) == (($this->transparent_color >> 0) & 0xFF)
337337
) {
338338
$Locals_ext = "!\xF9\x04".chr(($this->dis << 2) + 1).chr(($d >> 0) & 0xFF).chr(($d >> 8) & 0xFF).chr($j)."\x0";
339339
break;
340340
}
341341
}
342342
}
343343

344-
switch ($Locals_tmp { 0 }) {
344+
switch ($Locals_tmp[0]) {
345345

346346
case '!':
347347

@@ -358,7 +358,7 @@ protected function addGifFrames($i, $d)
358358
break;
359359
}
360360

361-
if (ord($this->frameSources[$i] { 10 }) & 0x80 && $this->imgBuilt) {
361+
if (ord($this->frameSources[$i][10]) & 0x80 && $this->imgBuilt) {
362362

363363
if ($Global_len == $Locals_len) {
364364

@@ -368,21 +368,21 @@ protected function addGifFrames($i, $d)
368368

369369
} else {
370370

371-
$byte = ord($Locals_img { 9 });
371+
$byte = ord($Locals_img[9]);
372372
$byte |= 0x80;
373373
$byte &= 0xF8;
374-
$byte |= (ord($this->frameSources[0] { 10 }) & 0x07);
375-
$Locals_img { 9 } = chr($byte);
374+
$byte |= (ord($this->frameSources[0][10]) & 0x07);
375+
$Locals_img[9] = chr($byte);
376376
$this->gif .= $Locals_ext.$Locals_img.$Locals_rgb.$Locals_tmp;
377377
}
378378

379379
} else {
380380

381-
$byte = ord($Locals_img { 9 });
381+
$byte = ord($Locals_img[9]);
382382
$byte |= 0x80;
383383
$byte &= 0xF8;
384-
$byte |= (ord($this->frameSources[$i] { 10 }) & 0x07);
385-
$Locals_img { 9 } = chr($byte);
384+
$byte |= (ord($this->frameSources[$i][10]) & 0x07);
385+
$Locals_img[9] = chr($byte);
386386
$this->gif .= $Locals_ext.$Locals_img.$Locals_rgb.$Locals_tmp;
387387
}
388388

0 commit comments

Comments
 (0)