Skip to content

Commit

Permalink
Removed curly brace array access for > PHP 7.4 use
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mattkirwan authored Sep 9, 2020
1 parent 7140162 commit b1ce0c7
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions src/GifCreator/AnimGif.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ public function create($frames, $durations = self::DEFAULT_DURATION, $loop = 0)
$this->transparent_color = imagecolortransparent($resourceImg);
}

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

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

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

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

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

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

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

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

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

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

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

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

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

switch ($Locals_tmp { 0 }) {
switch ($Locals_tmp[0]) {

case '!':

Expand All @@ -358,7 +358,7 @@ protected function addGifFrames($i, $d)
break;
}

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

if ($Global_len == $Locals_len) {

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

} else {

$byte = ord($Locals_img { 9 });
$byte = ord($Locals_img[9]);
$byte |= 0x80;
$byte &= 0xF8;
$byte |= (ord($this->frameSources[0] { 10 }) & 0x07);
$Locals_img { 9 } = chr($byte);
$byte |= (ord($this->frameSources[0][10]) & 0x07);
$Locals_img[9] = chr($byte);
$this->gif .= $Locals_ext.$Locals_img.$Locals_rgb.$Locals_tmp;
}

} else {

$byte = ord($Locals_img { 9 });
$byte = ord($Locals_img[9]);
$byte |= 0x80;
$byte &= 0xF8;
$byte |= (ord($this->frameSources[$i] { 10 }) & 0x07);
$Locals_img { 9 } = chr($byte);
$byte |= (ord($this->frameSources[$i][10]) & 0x07);
$Locals_img[9] = chr($byte);
$this->gif .= $Locals_ext.$Locals_img.$Locals_rgb.$Locals_tmp;
}

Expand Down

0 comments on commit b1ce0c7

Please sign in to comment.