From c412e59f222569a174a1240fe8aa6a0f5c74cb82 Mon Sep 17 00:00:00 2001 From: moroz1999 Date: Sat, 18 Sep 2021 21:40:11 +0300 Subject: [PATCH] Deprecated curly braces replaced --- composer.json | 3 +- src/GifCreator/GifCreator.php | 52 +++++++++++++++++------------------ 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/composer.json b/composer.json index 7280f9b..02e7fce 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,8 @@ } ], "require": { - "php": ">=5.3.0" + "php": "^8.0", + "ext-gd": "*" }, "autoload": { "psr-0": { "GifCreator": "src" } diff --git a/src/GifCreator/GifCreator.php b/src/GifCreator/GifCreator.php index d109608..8d2e5ff 100644 --- a/src/GifCreator/GifCreator.php +++ b/src/GifCreator/GifCreator.php @@ -132,9 +132,9 @@ public function create($frames = array(), $durations = array(), $loop = 0) throw new \Exception($this->version . ': ' . $i . ' ' . $this->errors['ERR01']); } - 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 '!': @@ -185,9 +185,9 @@ public function create($frames = array(), $durations = array(), $loop = 0) */ public function gifAddHeader() { - 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); @@ -209,26 +209,26 @@ public function gifAddHeader() */ public 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) . chr(($d >> 0) & 0xFF) . chr(($d >> 8) & 0xFF) . "\x0\x0"; - if ($this->colour > -1 && ord($this->frameSources[$i]{10}) & 0x80) { + if ($this->colour > -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->colour >> 16) & 0xFF) && - ord($Locals_rgb{3 * $j + 1}) == (($this->colour >> 8) & 0xFF) && - ord($Locals_rgb{3 * $j + 2}) == (($this->colour >> 0) & 0xFF) + if (ord($Locals_rgb[3 * $j + 0]) == (($this->colour >> 16) & 0xFF) && + ord($Locals_rgb[3 * $j + 1]) == (($this->colour >> 8) & 0xFF) && + ord($Locals_rgb[3 * $j + 2]) == (($this->colour >> 0) & 0xFF) ) { $Locals_ext = "!\xF9\x04" . chr(($this->dis << 2) + 1) . chr(($d >> 0) & 0xFF) . chr(($d >> 8) & 0xFF) . chr($j) . "\x0"; break; @@ -237,7 +237,7 @@ public function addGifFrames($i, $d) } $Locals_img = ''; - switch ($Locals_tmp{0}) { + switch ($Locals_tmp[0]) { case '!': @@ -253,7 +253,7 @@ public 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) { @@ -263,21 +263,21 @@ public 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; } @@ -310,9 +310,9 @@ public function gifBlockCompare($globalBlock, $localBlock, $length) { for ($i = 0; $i < $length; $i++) { - if ($globalBlock{3 * $i + 0} != $localBlock{3 * $i + 0} || - $globalBlock{3 * $i + 1} != $localBlock{3 * $i + 1} || - $globalBlock{3 * $i + 2} != $localBlock{3 * $i + 2} + if ($globalBlock[3 * $i + 0] != $localBlock[3 * $i + 0] || + $globalBlock[3 * $i + 1] != $localBlock[3 * $i + 1] || + $globalBlock[3 * $i + 2] != $localBlock[3 * $i + 2] ) { return 0; @@ -360,4 +360,4 @@ public function getGif() { return $this->gif; } -} +} \ No newline at end of file