Skip to content

Commit

Permalink
Deprecated curly braces replaced
Browse files Browse the repository at this point in the history
  • Loading branch information
moroz1999 committed Sep 18, 2021
1 parent c8128b0 commit c412e59
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 27 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
}
],
"require": {
"php": ">=5.3.0"
"php": "^8.0",
"ext-gd": "*"
},
"autoload": {
"psr-0": { "GifCreator": "src" }
Expand Down
52 changes: 26 additions & 26 deletions src/GifCreator/GifCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 '!':

Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -237,7 +237,7 @@ public function addGifFrames($i, $d)
}
$Locals_img = '';

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

case '!':

Expand All @@ -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) {

Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -360,4 +360,4 @@ public function getGif()
{
return $this->gif;
}
}
}

0 comments on commit c412e59

Please sign in to comment.