diff --git a/src/pocketmine/command/FormattedCommandAlias.php b/src/pocketmine/command/FormattedCommandAlias.php index 2c6a335d2..87655da02 100644 --- a/src/pocketmine/command/FormattedCommandAlias.php +++ b/src/pocketmine/command/FormattedCommandAlias.php @@ -74,14 +74,14 @@ class FormattedCommandAlias extends Command{ $index = strpos($formatString, '$'); while($index !== false){ $start = $index; - if($index > 0 and $formatString{$start - 1} === "\\"){ + if($index > 0 and $formatString[$start - 1] === "\\"){ $formatString = substr($formatString, 0, $start - 1) . substr($formatString, $start); $index = strpos($formatString, '$', $index); continue; } $required = false; - if($formatString{$index + 1} == '$'){ + if($formatString[$index + 1] == '$'){ $required = true; ++$index; @@ -91,7 +91,7 @@ class FormattedCommandAlias extends Command{ $argStart = $index; - while($index < strlen($formatString) and self::inRange(ord($formatString{$index}) - 48, 0, 9)){ + while($index < strlen($formatString) and self::inRange(ord($formatString[$index]) - 48, 0, 9)){ ++$index; } @@ -109,7 +109,7 @@ class FormattedCommandAlias extends Command{ $rest = false; - if($index < strlen($formatString) and $formatString{$index} === "-"){ + if($index < strlen($formatString) and $formatString[$index] === "-"){ $rest = true; ++$index; } diff --git a/src/pocketmine/command/defaults/VanillaCommand.php b/src/pocketmine/command/defaults/VanillaCommand.php index 8d26e5c8d..50c5313a1 100644 --- a/src/pocketmine/command/defaults/VanillaCommand.php +++ b/src/pocketmine/command/defaults/VanillaCommand.php @@ -65,7 +65,7 @@ abstract class VanillaCommand extends Command{ * @return float */ protected function getRelativeDouble(float $original, CommandSender $sender, string $input, float $min = self::MIN_COORD, float $max = self::MAX_COORD) : float{ - if($input{0} === "~"){ + if($input[0] === "~"){ $value = $this->getDouble($sender, substr($input, 1)); return $original + $value; diff --git a/src/pocketmine/inventory/ShapedRecipe.php b/src/pocketmine/inventory/ShapedRecipe.php index 04103cbfb..fb13d96f6 100644 --- a/src/pocketmine/inventory/ShapedRecipe.php +++ b/src/pocketmine/inventory/ShapedRecipe.php @@ -79,8 +79,8 @@ class ShapedRecipe implements CraftingRecipe{ } for($x = 0; $x < $this->width; ++$x){ - if($row{$x} !== ' ' and !isset($ingredients[$row{$x}])){ - throw new \InvalidArgumentException("No item specified for symbol '" . $row{$x} . "'"); + if($row[$x] !== ' ' and !isset($ingredients[$row[$x]])){ + throw new \InvalidArgumentException("No item specified for symbol '" . $row[$x] . "'"); } } } diff --git a/src/pocketmine/lang/BaseLang.php b/src/pocketmine/lang/BaseLang.php index b4222bab8..aece04221 100644 --- a/src/pocketmine/lang/BaseLang.php +++ b/src/pocketmine/lang/BaseLang.php @@ -190,7 +190,7 @@ class BaseLang{ $len = strlen($text); for($i = 0; $i < $len; ++$i){ - $c = $text{$i}; + $c = $text[$i]; if($replaceString !== null){ $ord = ord($c); if( diff --git a/src/pocketmine/level/format/Chunk.php b/src/pocketmine/level/format/Chunk.php index deadc83df..8bbdefe19 100644 --- a/src/pocketmine/level/format/Chunk.php +++ b/src/pocketmine/level/format/Chunk.php @@ -460,7 +460,7 @@ class Chunk{ * @return int 0-255 */ public function getBiomeId(int $x, int $z) : int{ - return ord($this->biomeIds{($z << 4) | $x}); + return ord($this->biomeIds[($z << 4) | $x]); } /** @@ -472,7 +472,7 @@ class Chunk{ */ public function setBiomeId(int $x, int $z, int $biomeId){ $this->hasChanged = true; - $this->biomeIds{($z << 4) | $x} = chr($biomeId & 0xff); + $this->biomeIds[($z << 4) | $x] = chr($biomeId & 0xff); } /** diff --git a/src/pocketmine/level/format/SubChunk.php b/src/pocketmine/level/format/SubChunk.php index 5e067440f..20207c563 100644 --- a/src/pocketmine/level/format/SubChunk.php +++ b/src/pocketmine/level/format/SubChunk.php @@ -71,31 +71,31 @@ class SubChunk implements SubChunkInterface{ } public function getBlockId(int $x, int $y, int $z) : int{ - return ord($this->ids{($x << 8) | ($z << 4) | $y}); + return ord($this->ids[($x << 8) | ($z << 4) | $y]); } public function setBlockId(int $x, int $y, int $z, int $id) : bool{ - $this->ids{($x << 8) | ($z << 4) | $y} = chr($id); + $this->ids[($x << 8) | ($z << 4) | $y] = chr($id); return true; } public function getBlockData(int $x, int $y, int $z) : int{ - return (ord($this->data{($x << 7) | ($z << 3) | ($y >> 1)}) >> (($y & 1) << 2)) & 0xf; + return (ord($this->data[($x << 7) | ($z << 3) | ($y >> 1)]) >> (($y & 1) << 2)) & 0xf; } public function setBlockData(int $x, int $y, int $z, int $data) : bool{ $i = ($x << 7) | ($z << 3) | ($y >> 1); $shift = ($y & 1) << 2; - $byte = ord($this->data{$i}); - $this->data{$i} = chr(($byte & ~(0xf << $shift)) | (($data & 0xf) << $shift)); + $byte = ord($this->data[$i]); + $this->data[$i] = chr(($byte & ~(0xf << $shift)) | (($data & 0xf) << $shift)); return true; } public function getFullBlock(int $x, int $y, int $z) : int{ $i = ($x << 8) | ($z << 4) | $y; - return (ord($this->ids{$i}) << 4) | ((ord($this->data{$i >> 1}) >> (($y & 1) << 2)) & 0xf); + return (ord($this->ids[$i]) << 4) | ((ord($this->data[$i >> 1]) >> (($y & 1) << 2)) & 0xf); } public function setBlock(int $x, int $y, int $z, ?int $id = null, ?int $data = null) : bool{ @@ -103,8 +103,8 @@ class SubChunk implements SubChunkInterface{ $changed = false; if($id !== null){ $block = chr($id); - if($this->ids{$i} !== $block){ - $this->ids{$i} = $block; + if($this->ids[$i] !== $block){ + $this->ids[$i] = $block; $changed = true; } } @@ -113,10 +113,10 @@ class SubChunk implements SubChunkInterface{ $i >>= 1; $shift = ($y & 1) << 2; - $oldPair = ord($this->data{$i}); + $oldPair = ord($this->data[$i]); $newPair = ($oldPair & ~(0xf << $shift)) | (($data & 0xf) << $shift); if($newPair !== $oldPair){ - $this->data{$i} = chr($newPair); + $this->data[$i] = chr($newPair); $changed = true; } } @@ -125,29 +125,29 @@ class SubChunk implements SubChunkInterface{ } public function getBlockLight(int $x, int $y, int $z) : int{ - return (ord($this->blockLight{($x << 7) | ($z << 3) | ($y >> 1)}) >> (($y & 1) << 2)) & 0xf; + return (ord($this->blockLight[($x << 7) | ($z << 3) | ($y >> 1)]) >> (($y & 1) << 2)) & 0xf; } public function setBlockLight(int $x, int $y, int $z, int $level) : bool{ $i = ($x << 7) | ($z << 3) | ($y >> 1); $shift = ($y & 1) << 2; - $byte = ord($this->blockLight{$i}); - $this->blockLight{$i} = chr(($byte & ~(0xf << $shift)) | (($level & 0xf) << $shift)); + $byte = ord($this->blockLight[$i]); + $this->blockLight[$i] = chr(($byte & ~(0xf << $shift)) | (($level & 0xf) << $shift)); return true; } public function getBlockSkyLight(int $x, int $y, int $z) : int{ - return (ord($this->skyLight{($x << 7) | ($z << 3) | ($y >> 1)}) >> (($y & 1) << 2)) & 0xf; + return (ord($this->skyLight[($x << 7) | ($z << 3) | ($y >> 1)]) >> (($y & 1) << 2)) & 0xf; } public function setBlockSkyLight(int $x, int $y, int $z, int $level) : bool{ $i = ($x << 7) | ($z << 3) | ($y >> 1); $shift = ($y & 1) << 2; - $byte = ord($this->skyLight{$i}); - $this->skyLight{$i} = chr(($byte & ~(0xf << $shift)) | (($level & 0xf) << $shift)); + $byte = ord($this->skyLight[$i]); + $this->skyLight[$i] = chr(($byte & ~(0xf << $shift)) | (($level & 0xf) << $shift)); return true; } @@ -156,7 +156,7 @@ class SubChunk implements SubChunkInterface{ $low = ($x << 8) | ($z << 4); $i = $low | 0x0f; for(; $i >= $low; --$i){ - if($this->ids{$i} !== "\x00"){ + if($this->ids[$i] !== "\x00"){ return $i & 0x0f; } } diff --git a/src/pocketmine/level/format/io/ChunkUtils.php b/src/pocketmine/level/format/io/ChunkUtils.php index fcb980076..d14f11a51 100644 --- a/src/pocketmine/level/format/io/ChunkUtils.php +++ b/src/pocketmine/level/format/io/ChunkUtils.php @@ -47,7 +47,7 @@ if(!extension_loaded('pocketmine_chunkutils')){ for($z = $x; $z < $zM; $z += 16){ $yM = $z + 4096; for($y = $z; $y < $yM; $y += 256){ - $result{$i} = $array{$y}; + $result[$i] = $array[$y]; ++$i; } } @@ -76,13 +76,13 @@ if(!extension_loaded('pocketmine_chunkutils')){ for($y = 0; $y < 8; ++$y){ $j = (($y << 8) | $zx); $j80 = ($j | 0x80); - if($array{$j} === $commonValue and $array{$j80} === $commonValue){ + if($array[$j] === $commonValue and $array[$j80] === $commonValue){ //values are already filled }else{ - $i1 = ord($array{$j}); - $i2 = ord($array{$j80}); - $result{$i} = chr(($i2 << 4) | ($i1 & 0x0f)); - $result{$i | 0x80} = chr(($i1 >> 4) | ($i2 & 0xf0)); + $i1 = ord($array[$j]); + $i2 = ord($array[$j80]); + $result[$i] = chr(($i2 << 4) | ($i1 & 0x0f)); + $result[$i | 0x80] = chr(($i1 >> 4) | ($i2 & 0xf0)); } $i++; } @@ -104,7 +104,7 @@ if(!extension_loaded('pocketmine_chunkutils')){ public static function convertBiomeColors(array $array) : string{ $result = str_repeat("\x00", 256); foreach($array as $i => $color){ - $result{$i} = chr(($color >> 24) & 0xff); + $result[$i] = chr(($color >> 24) & 0xff); } return $result; } diff --git a/src/pocketmine/level/generator/populator/GroundCover.php b/src/pocketmine/level/generator/populator/GroundCover.php index 7da08e0f1..5961a5487 100644 --- a/src/pocketmine/level/generator/populator/GroundCover.php +++ b/src/pocketmine/level/generator/populator/GroundCover.php @@ -48,7 +48,7 @@ class GroundCover extends Populator{ $column = $chunk->getBlockIdColumn($x, $z); for($y = 127; $y > 0; --$y){ - if($column{$y} !== "\x00" and !BlockFactory::get(ord($column{$y}))->isTransparent()){ + if($column[$y] !== "\x00" and !BlockFactory::get(ord($column[$y]))->isTransparent()){ break; } } @@ -56,10 +56,10 @@ class GroundCover extends Populator{ $endY = $startY - count($cover); for($y = $startY; $y > $endY and $y >= 0; --$y){ $b = $cover[$startY - $y]; - if($column{$y} === "\x00" and $b->isSolid()){ + if($column[$y] === "\x00" and $b->isSolid()){ break; } - if($b->canBeFlowedInto() and BlockFactory::get(ord($column{$y})) instanceof Liquid){ + if($b->canBeFlowedInto() and BlockFactory::get(ord($column[$y])) instanceof Liquid){ continue; } if($b->getDamage() === 0){ diff --git a/src/pocketmine/network/mcpe/VerifyLoginTask.php b/src/pocketmine/network/mcpe/VerifyLoginTask.php index f4cdaf5ea..b56f8efe8 100644 --- a/src/pocketmine/network/mcpe/VerifyLoginTask.php +++ b/src/pocketmine/network/mcpe/VerifyLoginTask.php @@ -120,12 +120,12 @@ class VerifyLoginTask extends AsyncTask{ [$rString, $sString] = str_split($plainSignature, 48); $rString = ltrim($rString, "\x00"); - if(ord($rString{0}) >= 128){ //Would be considered signed, pad it with an extra zero + if(ord($rString[0]) >= 128){ //Would be considered signed, pad it with an extra zero $rString = "\x00" . $rString; } $sString = ltrim($sString, "\x00"); - if(ord($sString{0}) >= 128){ //Would be considered signed, pad it with an extra zero + if(ord($sString[0]) >= 128){ //Would be considered signed, pad it with an extra zero $sString = "\x00" . $sString; } diff --git a/src/pocketmine/network/mcpe/protocol/UnknownPacket.php b/src/pocketmine/network/mcpe/protocol/UnknownPacket.php index 1b5b756de..e110c4043 100644 --- a/src/pocketmine/network/mcpe/protocol/UnknownPacket.php +++ b/src/pocketmine/network/mcpe/protocol/UnknownPacket.php @@ -37,7 +37,7 @@ class UnknownPacket extends DataPacket{ public function pid(){ if(strlen($this->payload ?? "") > 0){ - return ord($this->payload{0}); + return ord($this->payload[0]); } return self::NETWORK_ID; } diff --git a/src/pocketmine/network/query/QueryHandler.php b/src/pocketmine/network/query/QueryHandler.php index 73125866b..2c605b027 100644 --- a/src/pocketmine/network/query/QueryHandler.php +++ b/src/pocketmine/network/query/QueryHandler.php @@ -92,7 +92,7 @@ class QueryHandler{ public function handle(AdvancedSourceInterface $interface, string $address, int $port, string $packet){ $offset = 2; - $packetType = ord($packet{$offset++}); + $packetType = ord($packet[$offset++]); $sessionID = Binary::readInt(substr($packet, $offset, 4)); $offset += 4; $payload = substr($packet, $offset); diff --git a/src/pocketmine/permission/BanList.php b/src/pocketmine/permission/BanList.php index d6bc206cb..de2ca150d 100644 --- a/src/pocketmine/permission/BanList.php +++ b/src/pocketmine/permission/BanList.php @@ -154,7 +154,7 @@ class BanList{ $fp = @fopen($this->file, "r"); if(is_resource($fp)){ while(($line = fgets($fp)) !== false){ - if($line{0} !== "#"){ + if($line[0] !== "#"){ try{ $entry = BanEntry::fromString($line); if($entry instanceof BanEntry){ diff --git a/src/pocketmine/utils/Utils.php b/src/pocketmine/utils/Utils.php index ef2fb0d34..5f388c592 100644 --- a/src/pocketmine/utils/Utils.php +++ b/src/pocketmine/utils/Utils.php @@ -496,7 +496,7 @@ class Utils{ public static function javaStringHash(string $string) : int{ $hash = 0; for($i = 0, $len = strlen($string); $i < $len; $i++){ - $ord = ord($string{$i}); + $ord = ord($string[$i]); if($ord & 0x80){ $ord -= 0x100; }