diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 8b8536793..c836b1d22 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -208,7 +208,7 @@ use pocketmine\utils\UUID; /** * Main class that handles networking, recovery, and packet sending to the server part */ -class Player extends Human implements CommandSender, InventoryHolder, ChunkLoader, IPlayer, NetworkSession{ +class Player extends Human implements CommandSender, ChunkLoader, IPlayer, NetworkSession{ const SURVIVAL = 0; const CREATIVE = 1; @@ -699,13 +699,11 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade * @return bool */ public function hasAchievement($achievementId){ - if(!isset(Achievement::$list[$achievementId]) or !isset($this->achievements)){ - $this->achievements = []; - + if(!isset(Achievement::$list[$achievementId])){ return false; } - return isset($this->achievements[$achievementId]) and $this->achievements[$achievementId] != false; + return isset($this->achievements[$achievementId]) and $this->achievements[$achievementId] !== false; } /** @@ -786,7 +784,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade } private function unloadChunk($x, $z, Level $level = null){ - $level = $level === null ? $this->level : $level; + $level = $level ?? $this->level; $index = Level::chunkHash($x, $z); if(isset($this->usedChunks[$index])){ foreach($level->getChunkEntities($x, $z) as $entity){ @@ -1565,7 +1563,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $from = new Location($this->lastX, $this->lastY, $this->lastZ, $this->lastYaw, $this->lastPitch, $this->level); $to = $this->getLocation(); - $delta = pow($this->lastX - $to->x, 2) + pow($this->lastY - $to->y, 2) + pow($this->lastZ - $to->z, 2); + $delta = (($this->lastX - $to->x) ** 2) + (($this->lastY - $to->y) ** 2) + (($this->lastZ - $to->z) ** 2); $deltaAngle = abs($this->lastYaw - $to->yaw) + abs($this->lastPitch - $to->pitch); if(!$revert and ($delta > 0.0001 or $deltaAngle > 1.0)){ @@ -1601,7 +1599,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade } } - $this->speed = ($to->subtract($from))->divide($tickDiff); + $this->speed = $to->subtract($from)->divide($tickDiff); }elseif($distanceSquared == 0){ $this->speed = new Vector3(0, 0, 0); } @@ -1828,7 +1826,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade /** @var ByteTag $achievement */ foreach($this->namedtag->Achievements as $achievement){ - $this->achievements[$achievement->getName()] = $achievement->getValue() > 0 ? true : false; + $this->achievements[$achievement->getName()] = $achievement->getValue() !== 0; } $this->namedtag->lastPlayed = new LongTag("lastPlayed", (int) floor(microtime(true) * 1000)); @@ -2653,7 +2651,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $diff = ($this->server->getTick() - $this->startAction); $p = $diff / 20; $f = min((($p ** 2) + $p * 2) / 3, 1) * 2; - $ev = new EntityShootBowEvent($this, $bow, Entity::createEntity("Arrow", $this->getLevel(), $nbt, $this, $f == 2 ? true : false), $f); + $ev = new EntityShootBowEvent($this, $bow, Entity::createEntity("Arrow", $this->getLevel(), $nbt, $this, $f == 2), $f); if($f < 0.1 or $diff < 5){ $ev->setCancelled(); @@ -3981,8 +3979,8 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade } public function sendPosition(Vector3 $pos, float $yaw = null, float $pitch = null, int $mode = MovePlayerPacket::MODE_NORMAL, array $targets = null, float $baseOffsetOverride = null){ - $yaw = $yaw === null ? $this->yaw : $yaw; - $pitch = $pitch === null ? $this->pitch : $pitch; + $yaw = $yaw ?? $this->yaw; + $pitch = $pitch ?? $this->pitch; $pk = new MovePlayerPacket(); $pk->entityRuntimeId = $this->getId(); @@ -4003,41 +4001,6 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $this->newPosition = null; } - protected function checkChunks(){ - if($this->chunk === null or ($this->chunk->getX() !== ($this->x >> 4) or $this->chunk->getZ() !== ($this->z >> 4))){ - if($this->chunk !== null){ - $this->chunk->removeEntity($this); - } - $this->chunk = $this->level->getChunk($this->x >> 4, $this->z >> 4, true); - - if(!$this->justCreated){ - $newChunk = $this->level->getChunkPlayers($this->x >> 4, $this->z >> 4); - unset($newChunk[$this->getLoaderId()]); - - /** @var Player[] $reload */ - $reload = []; - foreach($this->hasSpawned as $player){ - if(!isset($newChunk[$player->getLoaderId()])){ - $this->despawnFrom($player); - }else{ - unset($newChunk[$player->getLoaderId()]); - $reload[] = $player; - } - } - - foreach($newChunk as $player){ - $this->spawnTo($player); - } - } - - if($this->chunk === null){ - return; - } - - $this->chunk->addEntity($this); - } - } - /** * {@inheritdoc} */ @@ -4075,6 +4038,8 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade * @param Vector3 $pos * @param float|null $yaw * @param float|null $pitch + * + * @return bool */ public function teleportImmediate(Vector3 $pos, float $yaw = null, float $pitch = null) : bool{ return $this->teleport($pos, $yaw, $pitch); diff --git a/src/pocketmine/PocketMine.php b/src/pocketmine/PocketMine.php index e5935b327..69c470671 100644 --- a/src/pocketmine/PocketMine.php +++ b/src/pocketmine/PocketMine.php @@ -104,7 +104,7 @@ namespace pocketmine { error_reporting(-1); set_error_handler(function($severity, $message, $file, $line){ - if((error_reporting() & $severity)){ + if(error_reporting() & $severity){ throw new \ErrorException($message, 0, $severity, $file, $line); }else{ //stfu operator return true; @@ -395,7 +395,7 @@ namespace pocketmine { return (is_object($value) ? get_class($value) . " object" : gettype($value) . " " . (is_array($value) ? "Array()" : Utils::printable(@strval($value)))); }, $args)); } - $messages[] = "#$j " . (isset($trace[$i]["file"]) ? cleanPath($trace[$i]["file"]) : "") . "(" . (isset($trace[$i]["line"]) ? $trace[$i]["line"] : "") . "): " . (isset($trace[$i]["class"]) ? $trace[$i]["class"] . (($trace[$i]["type"] === "dynamic" or $trace[$i]["type"] === "->") ? "->" : "::") : "") . $trace[$i]["function"] . "(" . Utils::printable($params) . ")"; + $messages[] = "#$j " . (isset($trace[$i]["file"]) ? cleanPath($trace[$i]["file"]) : "") . "(" . ($trace[$i]["line"] ?? "") . "): " . (isset($trace[$i]["class"]) ? $trace[$i]["class"] . (($trace[$i]["type"] === "dynamic" or $trace[$i]["type"] === "->") ? "->" : "::") : "") . $trace[$i]["function"] . "(" . Utils::printable($params) . ")"; } return $messages; diff --git a/src/pocketmine/Server.php b/src/pocketmine/Server.php index 1f920e36b..702bba328 100644 --- a/src/pocketmine/Server.php +++ b/src/pocketmine/Server.php @@ -1170,7 +1170,7 @@ class Server{ } } - return $this->propertyCache[$variable] === null ? $defaultValue : $this->propertyCache[$variable]; + return $this->propertyCache[$variable] ?? $defaultValue; } /** @@ -2264,14 +2264,14 @@ class Server{ $pk = new PlayerListPacket(); $pk->type = PlayerListPacket::TYPE_ADD; $pk->entries[] = [$uuid, $entityId, $name, $skinId, $skinData]; - $this->broadcastPacket($players === null ? $this->playerList : $players, $pk); + $this->broadcastPacket($players ?? $this->playerList, $pk); } public function removePlayerListData(UUID $uuid, array $players = null){ $pk = new PlayerListPacket(); $pk->type = PlayerListPacket::TYPE_REMOVE; $pk->entries[] = [$uuid]; - $this->broadcastPacket($players === null ? $this->playerList : $players, $pk); + $this->broadcastPacket($players ?? $this->playerList, $pk); } public function sendFullPlayerListData(Player $p){ diff --git a/src/pocketmine/block/Bed.php b/src/pocketmine/block/Bed.php index 366ca5da2..606d34c35 100644 --- a/src/pocketmine/block/Bed.php +++ b/src/pocketmine/block/Bed.php @@ -113,7 +113,7 @@ class Bed extends Transparent{ 3 => 5, ]; $d = $player instanceof Player ? $player->getDirection() : 0; - $next = $this->getSide($faces[(($d + 3) % 4)]); + $next = $this->getSide($faces[($d + 3) % 4]); $downNext = $this->getSide(0); if($next->canBeReplaced() === true and $downNext->isTransparent() === false){ $meta = (($d + 3) % 4) & 0x03; diff --git a/src/pocketmine/block/Door.php b/src/pocketmine/block/Door.php index ce6735e69..5a0e2cd1c 100644 --- a/src/pocketmine/block/Door.php +++ b/src/pocketmine/block/Door.php @@ -234,7 +234,7 @@ abstract class Door extends Transparent{ 2 => 2, 3 => 5, ]; - $next = $this->getSide($face[(($direction + 2) % 4)]); + $next = $this->getSide($face[($direction + 2) % 4]); $next2 = $this->getSide($face[$direction]); $metaUp = 0x08; if($next->getId() === $this->getId() or ($next2->isTransparent() === false and $next->isTransparent() === true)){ //Door hinge diff --git a/src/pocketmine/block/Torch.php b/src/pocketmine/block/Torch.php index 8a51cc14a..841d6a4b0 100644 --- a/src/pocketmine/block/Torch.php +++ b/src/pocketmine/block/Torch.php @@ -49,13 +49,12 @@ class Torch extends Flowable{ $below = $this->getSide(0); $side = $this->getDamage(); $faces = [ + 0 => 0, 1 => 4, 2 => 5, 3 => 2, 4 => 3, - 5 => 0, - 6 => 0, - 0 => 0, + 5 => 0 ]; if($this->getSide($faces[$side])->isTransparent() === true and !($side === 0 and ($below->getId() === self::FENCE or $below->getId() === self::COBBLE_WALL))){ diff --git a/src/pocketmine/command/Command.php b/src/pocketmine/command/Command.php index 8b891ac82..c119de043 100644 --- a/src/pocketmine/command/Command.php +++ b/src/pocketmine/command/Command.php @@ -79,7 +79,7 @@ abstract class Command{ $this->name = $name; $this->setLabel($name); $this->setDescription($description); - $this->usageMessage = $usageMessage === null ? "/" . $name : $usageMessage; + $this->usageMessage = $usageMessage ?? ("/" . $name); $this->setAliases($aliases); } diff --git a/src/pocketmine/command/CommandReader.php b/src/pocketmine/command/CommandReader.php index 093a4d9ee..f8ab76903 100644 --- a/src/pocketmine/command/CommandReader.php +++ b/src/pocketmine/command/CommandReader.php @@ -40,7 +40,7 @@ class CommandReader extends Thread{ $this->buffer = new \Threaded; $opts = getopt("", ["disable-readline"]); - if((extension_loaded("readline") and !isset($opts["disable-readline"]) and !$this->isPipe(STDIN))){ + if(extension_loaded("readline") and !isset($opts["disable-readline"]) and !$this->isPipe(STDIN)){ $this->type = self::TYPE_READLINE; } diff --git a/src/pocketmine/command/FormattedCommandAlias.php b/src/pocketmine/command/FormattedCommandAlias.php index 7cac99afc..765a5307e 100644 --- a/src/pocketmine/command/FormattedCommandAlias.php +++ b/src/pocketmine/command/FormattedCommandAlias.php @@ -102,7 +102,7 @@ class FormattedCommandAlias extends Command{ throw new \InvalidArgumentException("Invalid replacement token"); } - $position = intval(substr($formatString, $argStart, $index)); + $position = (int) (substr($formatString, $argStart, $index)); if($position === 0){ throw new \InvalidArgumentException("Invalid replacement token"); diff --git a/src/pocketmine/command/defaults/DumpMemoryCommand.php b/src/pocketmine/command/defaults/DumpMemoryCommand.php index 715948e64..4b083d5aa 100644 --- a/src/pocketmine/command/defaults/DumpMemoryCommand.php +++ b/src/pocketmine/command/defaults/DumpMemoryCommand.php @@ -52,7 +52,7 @@ class DumpMemoryCommand extends VanillaCommand{ ++self::$executions; - $sender->getServer()->getMemoryManager()->dumpServerMemory(isset($args[1]) ? $args[1] : $sender->getServer()->getDataPath() . "/memoryDump_$token", 48, 80); + $sender->getServer()->getMemoryManager()->dumpServerMemory($args[1] ?? ($sender->getServer()->getDataPath() . "/memoryDump_$token"), 48, 80); return true; } } diff --git a/src/pocketmine/command/defaults/KickCommand.php b/src/pocketmine/command/defaults/KickCommand.php index c5e57f7a6..35b8d5060 100644 --- a/src/pocketmine/command/defaults/KickCommand.php +++ b/src/pocketmine/command/defaults/KickCommand.php @@ -55,7 +55,7 @@ class KickCommand extends VanillaCommand{ if(($player = $sender->getServer()->getPlayer($name)) instanceof Player){ $player->kick($reason); - if(strlen($reason) >= 1){ + if($reason !== ""){ Command::broadcastCommandMessage($sender, new TranslationContainer("commands.kick.success.reason", [$player->getName(), $reason])); }else{ Command::broadcastCommandMessage($sender, new TranslationContainer("commands.kick.success", [$player->getName()])); diff --git a/src/pocketmine/command/defaults/ParticleCommand.php b/src/pocketmine/command/defaults/ParticleCommand.php index ce7c0c062..685cc4f42 100644 --- a/src/pocketmine/command/defaults/ParticleCommand.php +++ b/src/pocketmine/command/defaults/ParticleCommand.php @@ -203,17 +203,17 @@ class ParticleCommand extends VanillaCommand{ } - if(substr($name, 0, 10) === "iconcrack_"){ + if(strpos($name, "iconcrack_") === 0){ $d = explode("_", $name); if(count($d) === 3){ return new ItemBreakParticle($pos, Item::get((int) $d[1], (int) $d[2])); } - }elseif(substr($name, 0, 11) === "blockcrack_"){ + }elseif(strpos($name, "blockcrack_") === 0){ $d = explode("_", $name); if(count($d) === 2){ return new TerrainParticle($pos, Block::get($d[1] & 0xff, $d[1] >> 12)); } - }elseif(substr($name, 0, 10) === "blockdust_"){ + }elseif(strpos($name, "blockdust_") === 0){ $d = explode("_", $name); if(count($d) >= 4){ return new DustParticle($pos, $d[1] & 0xff, $d[2] & 0xff, $d[3] & 0xff, isset($d[4]) ? $d[4] & 0xff : 255); diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index c421408d6..65d283087 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -387,12 +387,12 @@ abstract class Entity extends Location implements Metadatable{ if(!isset($this->namedtag->OnGround)){ $this->namedtag->OnGround = new ByteTag("OnGround", 0); } - $this->onGround = $this->namedtag["OnGround"] > 0 ? true : false; + $this->onGround = $this->namedtag["OnGround"] !== 0; if(!isset($this->namedtag->Invulnerable)){ $this->namedtag->Invulnerable = new ByteTag("Invulnerable", 0); } - $this->invulnerable = $this->namedtag["Invulnerable"] > 0 ? true : false; + $this->invulnerable = $this->namedtag["Invulnerable"] !== 0; $this->attributeMap = new AttributeMap(); $this->addAttributes(); @@ -640,7 +640,7 @@ abstract class Entity extends Location implements Metadatable{ } public function getEffect($effectId){ - return isset($this->effects[$effectId]) ? $this->effects[$effectId] : null; + return $this->effects[$effectId] ?? null; } public function hasEffect($effectId){ @@ -866,7 +866,7 @@ abstract class Entity extends Location implements Metadatable{ $pk = new SetEntityDataPacket(); $pk->entityRuntimeId = $this->getId(); - $pk->metadata = $data === null ? $this->dataProperties : $data; + $pk->metadata = $data ?? $this->dataProperties; foreach($player as $p){ if($p === $this){ @@ -1794,8 +1794,8 @@ abstract class Entity extends Location implements Metadatable{ */ public function teleport(Vector3 $pos, float $yaw = null, float $pitch = null) : bool{ if($pos instanceof Location){ - $yaw = $yaw === null ? $pos->yaw : $yaw; - $pitch = $pitch === null ? $pos->pitch : $pitch; + $yaw = $yaw ?? $pos->yaw; + $pitch = $pitch ?? $pos->pitch; } $from = Position::fromObject($this, $this->level); $to = Position::fromObject($pos, $pos instanceof Position ? $pos->getLevel() : $this->level); @@ -1807,7 +1807,7 @@ abstract class Entity extends Location implements Metadatable{ $pos = $ev->getTo(); $this->setMotion($this->temporalVector->setComponents(0, 0, 0)); - if($this->setPositionAndRotation($pos, $yaw === null ? $this->yaw : $yaw, $pitch === null ? $this->pitch : $pitch) !== false){ + if($this->setPositionAndRotation($pos, $yaw ?? $this->yaw, $pitch ?? $this->pitch) !== false){ $this->resetFallDistance(); $this->onGround = true; diff --git a/src/pocketmine/entity/Human.php b/src/pocketmine/entity/Human.php index 759f1f4e4..2ada9e1b9 100644 --- a/src/pocketmine/entity/Human.php +++ b/src/pocketmine/entity/Human.php @@ -141,13 +141,16 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{ $attr = $this->attributeMap->getAttribute(Attribute::HUNGER); $old = $attr->getValue(); $attr->setValue($new); + + $reset = false; // ranges: 18-20 (regen), 7-17 (none), 1-6 (no sprint), 0 (health depletion) foreach([17, 6, 0] as $bound){ if(($old > $bound) !== ($new > $bound)){ $reset = true; + break; } } - if(isset($reset)){ + if($reset){ $this->foodTickTimer = 0; } diff --git a/src/pocketmine/entity/Squid.php b/src/pocketmine/entity/Squid.php index 0df430fe6..cd6bac256 100644 --- a/src/pocketmine/entity/Squid.php +++ b/src/pocketmine/entity/Squid.php @@ -31,7 +31,7 @@ use pocketmine\network\mcpe\protocol\AddEntityPacket; use pocketmine\network\mcpe\protocol\EntityEventPacket; use pocketmine\Player; -class Squid extends WaterAnimal implements Ageable{ +class Squid extends WaterAnimal{ const NETWORK_ID = 17; public $width = 0.95; diff --git a/src/pocketmine/event/Event.php b/src/pocketmine/event/Event.php index 40e480027..5b529dee6 100644 --- a/src/pocketmine/event/Event.php +++ b/src/pocketmine/event/Event.php @@ -45,7 +45,7 @@ abstract class Event{ * @return string */ final public function getEventName() : string{ - return $this->eventName === null ? get_class($this) : $this->eventName; + return $this->eventName ?? get_class($this); } /** diff --git a/src/pocketmine/event/block/BlockFormEvent.php b/src/pocketmine/event/block/BlockFormEvent.php index 442e4dc17..561861051 100644 --- a/src/pocketmine/event/block/BlockFormEvent.php +++ b/src/pocketmine/event/block/BlockFormEvent.php @@ -24,13 +24,8 @@ declare(strict_types=1); namespace pocketmine\event\block; use pocketmine\block\Block; -use pocketmine\event\Cancellable; -class BlockFormEvent extends BlockGrowEvent implements Cancellable{ +class BlockFormEvent extends BlockGrowEvent{ public static $handlerList = null; - public function __construct(Block $block, Block $newState){ - parent::__construct($block, $newState); - } - } \ No newline at end of file diff --git a/src/pocketmine/event/block/BlockSpreadEvent.php b/src/pocketmine/event/block/BlockSpreadEvent.php index d0a13460b..6065b2c28 100644 --- a/src/pocketmine/event/block/BlockSpreadEvent.php +++ b/src/pocketmine/event/block/BlockSpreadEvent.php @@ -24,9 +24,8 @@ declare(strict_types=1); namespace pocketmine\event\block; use pocketmine\block\Block; -use pocketmine\event\Cancellable; -class BlockSpreadEvent extends BlockFormEvent implements Cancellable{ +class BlockSpreadEvent extends BlockFormEvent{ public static $handlerList = null; /** @var Block */ diff --git a/src/pocketmine/inventory/CraftingManager.php b/src/pocketmine/inventory/CraftingManager.php index aca85258b..408930d3e 100644 --- a/src/pocketmine/inventory/CraftingManager.php +++ b/src/pocketmine/inventory/CraftingManager.php @@ -256,12 +256,12 @@ class CraftingManager{ } $hasRecipe = null; - foreach($this->recipeLookup[$idx] as $recipe){ - if($recipe instanceof ShapelessRecipe){ - if($recipe->getIngredientCount() !== count($ingredients)){ + foreach($this->recipeLookup[$idx] as $possibleRecipe){ + if($possibleRecipe instanceof ShapelessRecipe){ + if($possibleRecipe->getIngredientCount() !== count($ingredients)){ continue; } - $checkInput = $recipe->getIngredientList(); + $checkInput = $possibleRecipe->getIngredientList(); foreach($ingredients as $item){ $amount = $item->getCount(); foreach($checkInput as $k => $checkItem){ @@ -280,7 +280,7 @@ class CraftingManager{ } if(count($checkInput) === 0){ - $hasRecipe = $recipe; + $hasRecipe = $possibleRecipe; break; } } diff --git a/src/pocketmine/inventory/ShapedRecipe.php b/src/pocketmine/inventory/ShapedRecipe.php index fda4c8190..71cf21da6 100644 --- a/src/pocketmine/inventory/ShapedRecipe.php +++ b/src/pocketmine/inventory/ShapedRecipe.php @@ -137,7 +137,7 @@ class ShapedRecipe implements Recipe{ * @return null|Item */ public function getIngredient($x, $y){ - return isset($this->ingredients[$y][$x]) ? $this->ingredients[$y][$x] : Item::get(Item::AIR); + return $this->ingredients[$y][$x] ?? Item::get(Item::AIR); } /** diff --git a/src/pocketmine/inventory/TransactionGroup.php b/src/pocketmine/inventory/TransactionGroup.php index b970c6c8c..c0948903f 100644 --- a/src/pocketmine/inventory/TransactionGroup.php +++ b/src/pocketmine/inventory/TransactionGroup.php @@ -28,36 +28,36 @@ interface TransactionGroup{ /** * @return float */ - function getCreationTime(); + public function getCreationTime(); /** * @return Transaction[] */ - function getTransactions(); + public function getTransactions(); /** * @return Inventory[] */ - function getInventories(); + public function getInventories(); /** * @param Transaction $transaction */ - function addTransaction(Transaction $transaction); + public function addTransaction(Transaction $transaction); /** * @return bool */ - function canExecute(); + public function canExecute(); /** * @return bool */ - function execute(); + public function execute(); /** * @return bool */ - function hasExecuted(); + public function hasExecuted(); } \ No newline at end of file diff --git a/src/pocketmine/item/Item.php b/src/pocketmine/item/Item.php index 9b9c2c2b1..c708af210 100644 --- a/src/pocketmine/item/Item.php +++ b/src/pocketmine/item/Item.php @@ -49,7 +49,7 @@ class Item implements ItemIds, \JsonSerializable{ private static $cachedParser = null; private static function parseCompoundTag(string $tag) : CompoundTag{ - if(strlen($tag) === 0){ + if($tag === ""){ throw new \InvalidArgumentException("No NBT data found in supplied string"); } diff --git a/src/pocketmine/lang/BaseLang.php b/src/pocketmine/lang/BaseLang.php index 60b38fb31..2c9f70325 100644 --- a/src/pocketmine/lang/BaseLang.php +++ b/src/pocketmine/lang/BaseLang.php @@ -120,7 +120,7 @@ class BaseLang{ public function translate(TextContainer $c){ if($c instanceof TranslationContainer){ $baseText = $this->internalGet($c->getText()); - $baseText = $this->parseTranslation($baseText !== null ? $baseText : $c->getText()); + $baseText = $this->parseTranslation($baseText ?? $c->getText()); foreach($c->getParameters() as $i => $p){ $baseText = str_replace("{%$i}", $this->parseTranslation($p), $baseText); diff --git a/src/pocketmine/level/Explosion.php b/src/pocketmine/level/Explosion.php index a55fe2b9a..855e5540f 100644 --- a/src/pocketmine/level/Explosion.php +++ b/src/pocketmine/level/Explosion.php @@ -71,7 +71,7 @@ class Explosion{ $vector = new Vector3(0, 0, 0); $vBlock = new Vector3(0, 0, 0); - $mRays = intval($this->rays - 1); + $mRays = (int) ($this->rays - 1); for($i = 0; $i < $this->rays; ++$i){ for($j = 0; $j < $this->rays; ++$j){ for($k = 0; $k < $this->rays; ++$k){ diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index 3f198c726..cabef3ed1 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -819,7 +819,7 @@ class Level implements ChunkManager, Metadatable{ $pk->z = $z + 0.5; $pk->data = ($data << 8) | $id; - $this->server->broadcastPacket($targets === null ? $this->getChunkPlayers($x >> 4, $z >> 4) : $targets, $pk); + $this->server->broadcastPacket($targets ?? $this->getChunkPlayers($x >> 4, $z >> 4), $pk); } /** @@ -1533,7 +1533,7 @@ class Level implements ChunkManager, Metadatable{ * @param int $delay */ public function dropItem(Vector3 $source, Item $item, Vector3 $motion = null, int $delay = 10){ - $motion = $motion === null ? new Vector3(lcg_value() * 0.2 - 0.1, 0.2, lcg_value() * 0.2 - 0.1) : $motion; + $motion = $motion ?? new Vector3(lcg_value() * 0.2 - 0.1, 0.2, lcg_value() * 0.2 - 0.1); $itemTag = $item->nbtSerialize(); $itemTag->setName("Item"); @@ -1582,7 +1582,7 @@ class Level implements ChunkManager, Metadatable{ } if($player !== null){ - $ev = new BlockBreakEvent($player, $target, $item, ($player->isCreative() or $player->allowInstaBreak())); + $ev = new BlockBreakEvent($player, $target, $item, $player->isCreative() or $player->allowInstaBreak()); if(($player->isSurvival() and $item instanceof Item and !$target->isBreakable($item)) or $player->isSpectator()){ $ev->setCancelled(); @@ -1633,7 +1633,7 @@ class Level implements ChunkManager, Metadatable{ $breakTime -= 1; //1 tick compensation - if(!$ev->getInstaBreak() and ((ceil($player->lastBreak * 20)) + $breakTime) > ceil(microtime(true) * 20)){ + if(!$ev->getInstaBreak() and (ceil($player->lastBreak * 20) + $breakTime) > ceil(microtime(true) * 20)){ return false; } @@ -2590,7 +2590,7 @@ class Level implements ChunkManager, Metadatable{ } public function unloadChunk(int $x, int $z, bool $safe = true, bool $trySave = true) : bool{ - if(($safe === true and $this->isChunkInUse($x, $z))){ + if($safe === true and $this->isChunkInUse($x, $z)){ return false; } diff --git a/src/pocketmine/level/format/Chunk.php b/src/pocketmine/level/format/Chunk.php index 1ae0f5532..fc0cb74fd 100644 --- a/src/pocketmine/level/format/Chunk.php +++ b/src/pocketmine/level/format/Chunk.php @@ -90,8 +90,9 @@ class Chunk{ * @param CompoundTag[] $tiles * @param string $biomeIds * @param int[] $heightMap + * @param int[] $extraData */ - public function __construct(int $chunkX, int $chunkZ, array $subChunks = [], array $entities = [], array $tiles = [], string $biomeIds = "", array $heightMap = []){ + public function __construct(int $chunkX, int $chunkZ, array $subChunks = [], array $entities = [], array $tiles = [], string $biomeIds = "", array $heightMap = [], array $extraData = []){ $this->x = $chunkX; $this->z = $chunkZ; @@ -127,10 +128,12 @@ class Chunk{ if(strlen($biomeIds) === 256){ $this->biomeIds = $biomeIds; }else{ - assert(strlen($biomeIds) === 0, "Wrong BiomeIds value count, expected 256, got " . strlen($biomeIds)); + assert($biomeIds === "", "Wrong BiomeIds value count, expected 256, got " . strlen($biomeIds)); $this->biomeIds = str_repeat("\x00", 256); } + $this->extraData = $extraData; + $this->NBTtiles = $tiles; $this->NBTentities = $entities; } diff --git a/src/pocketmine/level/format/SubChunk.php b/src/pocketmine/level/format/SubChunk.php index d69fbf0a3..733a83a59 100644 --- a/src/pocketmine/level/format/SubChunk.php +++ b/src/pocketmine/level/format/SubChunk.php @@ -173,19 +173,19 @@ class SubChunk implements SubChunkInterface{ } public function getBlockIdColumn(int $x, int $z) : string{ - return substr($this->ids, (($x << 8) | ($z << 4)), 16); + return substr($this->ids, ($x << 8) | ($z << 4), 16); } public function getBlockDataColumn(int $x, int $z) : string{ - return substr($this->data, (($x << 7) | ($z << 3)), 8); + return substr($this->data, ($x << 7) | ($z << 3), 8); } public function getBlockLightColumn(int $x, int $z) : string{ - return substr($this->blockLight, (($x << 7) | ($z << 3)), 8); + return substr($this->blockLight, ($x << 7) | ($z << 3), 8); } public function getBlockSkyLightColumn(int $x, int $z) : string{ - return substr($this->skyLight, (($x << 7) | ($z << 3)), 8); + return substr($this->skyLight, ($x << 7) | ($z << 3), 8); } public function getBlockIdArray() : string{ diff --git a/src/pocketmine/level/format/io/leveldb/LevelDB.php b/src/pocketmine/level/format/io/leveldb/LevelDB.php index f050a7ded..a44aaeff9 100644 --- a/src/pocketmine/level/format/io/leveldb/LevelDB.php +++ b/src/pocketmine/level/format/io/leveldb/LevelDB.php @@ -436,7 +436,8 @@ class LevelDB extends BaseLevelProvider{ $entities, $tiles, $biomeIds, - $heightMap + $heightMap, + $extraData ); //TODO: tile ticks, biome states (?) diff --git a/src/pocketmine/level/format/io/region/McRegion.php b/src/pocketmine/level/format/io/region/McRegion.php index 88ea43e54..819ef3843 100644 --- a/src/pocketmine/level/format/io/region/McRegion.php +++ b/src/pocketmine/level/format/io/region/McRegion.php @@ -134,9 +134,9 @@ class McRegion extends BaseLevelProvider{ $subChunks = []; $fullIds = isset($chunk->Blocks) ? $chunk->Blocks->getValue() : str_repeat("\x00", 32768); - $fullData = isset($chunk->Data) ? $chunk->Data->getValue() : (str_repeat("\x00", 16384)); + $fullData = isset($chunk->Data) ? $chunk->Data->getValue() : str_repeat("\x00", 16384); $fullSkyLight = isset($chunk->SkyLight) ? $chunk->SkyLight->getValue() : str_repeat("\xff", 16384); - $fullBlockLight = isset($chunk->BlockLight) ? $chunk->BlockLight->getValue() : (str_repeat("\x00", 16384)); + $fullBlockLight = isset($chunk->BlockLight) ? $chunk->BlockLight->getValue() : str_repeat("\x00", 16384); for($y = 0; $y < 8; ++$y){ $offset = ($y << 4); @@ -262,7 +262,7 @@ class McRegion extends BaseLevelProvider{ new LongTag("SizeOnDisk", 0), new LongTag("Time", 0), new StringTag("generatorName", Generator::getGeneratorName($generator)), - new StringTag("generatorOptions", isset($options["preset"]) ? $options["preset"] : ""), + new StringTag("generatorOptions", $options["preset"] ?? ""), new StringTag("LevelName", $name), new CompoundTag("GameRules", []) ]); diff --git a/src/pocketmine/level/format/io/region/RegionLoader.php b/src/pocketmine/level/format/io/region/RegionLoader.php index 95ff67e35..42f6f8a06 100644 --- a/src/pocketmine/level/format/io/region/RegionLoader.php +++ b/src/pocketmine/level/format/io/region/RegionLoader.php @@ -292,7 +292,7 @@ class RegionLoader{ $index = $data[$i + 1]; $offset = $index >> 8; if($offset !== 0){ - fseek($this->filePointer, ($offset << 12)); + fseek($this->filePointer, $offset << 12); if(fgetc($this->filePointer) === false){ //Try and read from the location throw new CorruptedRegionException("Region file location offset points to invalid location"); }elseif(isset($usedOffsets[$offset])){ diff --git a/src/pocketmine/level/generator/Flat.php b/src/pocketmine/level/generator/Flat.php index 73080e4ba..fce9a1f5f 100644 --- a/src/pocketmine/level/generator/Flat.php +++ b/src/pocketmine/level/generator/Flat.php @@ -90,7 +90,7 @@ class Flat extends Generator{ $y = 0; foreach($matches[3] as $i => $b){ $b = Item::fromString($b . $matches[4][$i]); - $cnt = $matches[2][$i] === "" ? 1 : intval($matches[2][$i]); + $cnt = $matches[2][$i] === "" ? 1 : (int) ($matches[2][$i]); for($cY = $y, $y += $cnt; $cY < $y; ++$cY){ $result[$cY] = [$b->getId(), $b->getDamage()]; } diff --git a/src/pocketmine/math/Matrix.php b/src/pocketmine/math/Matrix.php index a936347e8..0f4b1aee1 100644 --- a/src/pocketmine/math/Matrix.php +++ b/src/pocketmine/math/Matrix.php @@ -55,17 +55,17 @@ class Matrix implements \ArrayAccess{ for($r = 0; $r < $this->rows; ++$r){ $this->matrix[$r] = []; for($c = 0; $c < $this->columns; ++$c){ - $this->matrix[$r][$c] = isset($m[$r][$c]) ? $m[$r][$c] : 0; + $this->matrix[$r][$c] = $m[$r][$c] ?? 0; } } } public function getRows(){ - return ($this->rows); + return $this->rows; } public function getColumns(){ - return ($this->columns); + return $this->columns; } public function setElement($row, $column, $value){ diff --git a/src/pocketmine/math/Vector2.php b/src/pocketmine/math/Vector2.php index 532871974..d6df17c23 100644 --- a/src/pocketmine/math/Vector2.php +++ b/src/pocketmine/math/Vector2.php @@ -100,7 +100,7 @@ class Vector2{ if($x instanceof Vector2){ return $this->distanceSquared($x->x, $x->y); }else{ - return pow($this->x - $x, 2) + pow($this->y - $y, 2); + return (($this->x - $x) ** 2) + (($this->y - $y) ** 2); } } diff --git a/src/pocketmine/math/Vector3.php b/src/pocketmine/math/Vector3.php index b5b8515ee..1d629b50e 100644 --- a/src/pocketmine/math/Vector3.php +++ b/src/pocketmine/math/Vector3.php @@ -189,7 +189,7 @@ class Vector3{ } public function distanceSquared(Vector3 $pos){ - return pow($this->x - $pos->x, 2) + pow($this->y - $pos->y, 2) + pow($this->z - $pos->z, 2); + return (($this->x - $pos->x) ** 2) + (($this->y - $pos->y) ** 2) + (($this->z - $pos->z) ** 2); } public function maxPlainDistance($x = 0, $z = 0){ diff --git a/src/pocketmine/nbt/NBT.php b/src/pocketmine/nbt/NBT.php index 5b4f3bd6f..bbf214f3a 100644 --- a/src/pocketmine/nbt/NBT.php +++ b/src/pocketmine/nbt/NBT.php @@ -404,7 +404,7 @@ class NBT{ public function setArray(array $data, callable $guesser = null){ $this->data = new CompoundTag("", []); - self::fromArray($this->data, $data, $guesser === null ? [self::class, "fromArrayGuesser"] : $guesser); + self::fromArray($this->data, $data, $guesser ?? [self::class, "fromArrayGuesser"]); } /** diff --git a/src/pocketmine/network/mcpe/CachedEncapsulatedPacket.php b/src/pocketmine/network/mcpe/CachedEncapsulatedPacket.php index 9ebe122ee..94e3d5fdf 100644 --- a/src/pocketmine/network/mcpe/CachedEncapsulatedPacket.php +++ b/src/pocketmine/network/mcpe/CachedEncapsulatedPacket.php @@ -30,6 +30,6 @@ class CachedEncapsulatedPacket extends EncapsulatedPacket{ private $internalData = null; public function toBinary($internal = false){ - return $this->internalData === null ? ($this->internalData = parent::toBinary($internal)) : $this->internalData; + return $this->internalData ?? ($this->internalData = parent::toBinary($internal)); } } \ No newline at end of file diff --git a/src/pocketmine/network/mcpe/protocol/BatchPacket.php b/src/pocketmine/network/mcpe/protocol/BatchPacket.php index 21962fc05..57b691fdd 100644 --- a/src/pocketmine/network/mcpe/protocol/BatchPacket.php +++ b/src/pocketmine/network/mcpe/protocol/BatchPacket.php @@ -85,7 +85,7 @@ class BatchPacket extends DataPacket{ return false; } - if(strlen($str) === 0){ + if($str === ""){ throw new \InvalidStateException("Decoded BatchPacket payload is empty"); } diff --git a/src/pocketmine/network/mcpe/protocol/LoginPacket.php b/src/pocketmine/network/mcpe/protocol/LoginPacket.php index 355a016f6..dc5f2a38c 100644 --- a/src/pocketmine/network/mcpe/protocol/LoginPacket.php +++ b/src/pocketmine/network/mcpe/protocol/LoginPacket.php @@ -94,8 +94,7 @@ class LoginPacket extends DataPacket{ } public function decodeToken($token){ - $tokens = explode(".", $token); - list($headB64, $payloadB64, $sigB64) = $tokens; + list($headB64, $payloadB64, $sigB64) = explode(".", $token); return json_decode(base64_decode($payloadB64), true); } diff --git a/src/pocketmine/network/mcpe/protocol/UpdateBlockPacket.php b/src/pocketmine/network/mcpe/protocol/UpdateBlockPacket.php index 4cf3b023c..229ca6c04 100644 --- a/src/pocketmine/network/mcpe/protocol/UpdateBlockPacket.php +++ b/src/pocketmine/network/mcpe/protocol/UpdateBlockPacket.php @@ -37,8 +37,8 @@ class UpdateBlockPacket extends DataPacket{ const FLAG_NOGRAPHIC = 0b0100; const FLAG_PRIORITY = 0b1000; - const FLAG_ALL = (self::FLAG_NEIGHBORS | self::FLAG_NETWORK); - const FLAG_ALL_PRIORITY = (self::FLAG_ALL | self::FLAG_PRIORITY); + const FLAG_ALL = self::FLAG_NEIGHBORS | self::FLAG_NETWORK; + const FLAG_ALL_PRIORITY = self::FLAG_ALL | self::FLAG_PRIORITY; public $x; public $z; diff --git a/src/pocketmine/permission/PermissibleBase.php b/src/pocketmine/permission/PermissibleBase.php index 53a3f8546..af237edbd 100644 --- a/src/pocketmine/permission/PermissibleBase.php +++ b/src/pocketmine/permission/PermissibleBase.php @@ -133,7 +133,7 @@ class PermissibleBase implements Permissible{ throw new PluginException("Plugin " . $plugin->getDescription()->getName() . " is disabled"); } - $result = new PermissionAttachment($plugin, $this->parent !== null ? $this->parent : $this); + $result = new PermissionAttachment($plugin, $this->parent ?? $this); $this->attachments[spl_object_hash($result)] = $result; if($name !== null and $value !== null){ $result->setPermission($name, $value); @@ -165,12 +165,12 @@ class PermissibleBase implements Permissible{ $this->clearPermissions(); $defaults = Server::getInstance()->getPluginManager()->getDefaultPermissions($this->isOp()); - Server::getInstance()->getPluginManager()->subscribeToDefaultPerms($this->isOp(), $this->parent !== null ? $this->parent : $this); + Server::getInstance()->getPluginManager()->subscribeToDefaultPerms($this->isOp(), $this->parent ?? $this); foreach($defaults as $perm){ $name = $perm->getName(); - $this->permissions[$name] = new PermissionAttachmentInfo($this->parent !== null ? $this->parent : $this, $name, null, true); - Server::getInstance()->getPluginManager()->subscribeToPermission($name, $this->parent !== null ? $this->parent : $this); + $this->permissions[$name] = new PermissionAttachmentInfo($this->parent ?? $this, $name, null, true); + Server::getInstance()->getPluginManager()->subscribeToPermission($name, $this->parent ?? $this); $this->calculateChildPermissions($perm->getChildren(), false, null); } @@ -202,8 +202,8 @@ class PermissibleBase implements Permissible{ foreach($children as $name => $v){ $perm = Server::getInstance()->getPluginManager()->getPermission($name); $value = ($v xor $invert); - $this->permissions[$name] = new PermissionAttachmentInfo($this->parent !== null ? $this->parent : $this, $name, $attachment, $value); - Server::getInstance()->getPluginManager()->subscribeToPermission($name, $this->parent !== null ? $this->parent : $this); + $this->permissions[$name] = new PermissionAttachmentInfo($this->parent ?? $this, $name, $attachment, $value); + Server::getInstance()->getPluginManager()->subscribeToPermission($name, $this->parent ?? $this); if($perm instanceof Permission){ $this->calculateChildPermissions($perm->getChildren(), !$value, $attachment); diff --git a/src/pocketmine/permission/Permission.php b/src/pocketmine/permission/Permission.php index f477827ac..0d8e3ad7e 100644 --- a/src/pocketmine/permission/Permission.php +++ b/src/pocketmine/permission/Permission.php @@ -101,8 +101,8 @@ class Permission{ */ public function __construct($name, $description = null, $defaultValue = null, array $children = []){ $this->name = $name; - $this->description = $description !== null ? $description : ""; - $this->defaultValue = $defaultValue !== null ? $defaultValue : self::$DEFAULT_PERMISSION; + $this->description = $description ?? ""; + $this->defaultValue = $defaultValue ?? self::$DEFAULT_PERMISSION; $this->children = $children; $this->recalculatePermissibles(); diff --git a/src/pocketmine/plugin/PluginBase.php b/src/pocketmine/plugin/PluginBase.php index c812fe41a..4847dd9c1 100644 --- a/src/pocketmine/plugin/PluginBase.php +++ b/src/pocketmine/plugin/PluginBase.php @@ -168,7 +168,7 @@ abstract class PluginBase implements Plugin{ * @return bool */ protected function isPhar(){ - return substr($this->file, 0, 7) === "phar://"; + return strpos($this->file, "phar://") === 0; } /** diff --git a/src/pocketmine/plugin/PluginManager.php b/src/pocketmine/plugin/PluginManager.php index 3f6c01a81..d344ccccc 100644 --- a/src/pocketmine/plugin/PluginManager.php +++ b/src/pocketmine/plugin/PluginManager.php @@ -145,7 +145,7 @@ class PluginManager{ * @return Plugin|null */ public function loadPlugin($path, $loaders = null){ - foreach(($loaders === null ? $this->fileAssociations : $loaders) as $loader){ + foreach($loaders ?? $this->fileAssociations as $loader){ if(preg_match($loader->getPluginFilters(), basename($path)) > 0){ $description = $loader->getPluginDescription($path); if($description instanceof PluginDescription){ diff --git a/src/pocketmine/scheduler/TaskHandler.php b/src/pocketmine/scheduler/TaskHandler.php index 1d126fb7e..3c58da9e7 100644 --- a/src/pocketmine/scheduler/TaskHandler.php +++ b/src/pocketmine/scheduler/TaskHandler.php @@ -63,7 +63,7 @@ class TaskHandler{ $this->taskId = $taskId; $this->delay = $delay; $this->period = $period; - $this->timingName = $timingName === null ? "Unknown" : $timingName; + $this->timingName = $timingName ?? "Unknown"; $this->timings = Timings::getPluginTaskTimings($this, $period); $this->task->setHandler($this); } diff --git a/src/pocketmine/tile/Furnace.php b/src/pocketmine/tile/Furnace.php index 574df3d27..96aaeb1ea 100644 --- a/src/pocketmine/tile/Furnace.php +++ b/src/pocketmine/tile/Furnace.php @@ -229,10 +229,10 @@ class Furnace extends Spawnable implements InventoryHolder, Container, Nameable{ if($this->namedtag["BurnTime"] > 0){ $this->namedtag->BurnTime = new ShortTag("BurnTime", ((int) $this->namedtag["BurnTime"]) - 1); - $this->namedtag->BurnTicks = new ShortTag("BurnTicks", (int) ceil(($this->namedtag["BurnTime"] / $this->namedtag["MaxTime"] * 200))); + $this->namedtag->BurnTicks = new ShortTag("BurnTicks", (int) ceil($this->namedtag["BurnTime"] / $this->namedtag["MaxTime"] * 200)); if($smelt instanceof FurnaceRecipe and $canSmelt){ - $this->namedtag->CookTime = new ShortTag("CookTime", (int) ($this->namedtag["CookTime"]) + 1); + $this->namedtag->CookTime = new ShortTag("CookTime", ((int) $this->namedtag["CookTime"]) + 1); if($this->namedtag["CookTime"] >= 200){ //10 seconds $product = Item::get($smelt->getResult()->getId(), $smelt->getResult()->getDamage(), $product->getCount() + 1); diff --git a/src/pocketmine/utils/BlockIterator.php b/src/pocketmine/utils/BlockIterator.php index af13843fc..1472d5891 100644 --- a/src/pocketmine/utils/BlockIterator.php +++ b/src/pocketmine/utils/BlockIterator.php @@ -179,15 +179,15 @@ class BlockIterator implements \Iterator{ } private function getXFace(Vector3 $direction){ - return (($direction->x) > 0) ? Vector3::SIDE_EAST : Vector3::SIDE_WEST; + return ($direction->x > 0) ? Vector3::SIDE_EAST : Vector3::SIDE_WEST; } private function getYFace(Vector3 $direction){ - return (($direction->y) > 0) ? Vector3::SIDE_UP : Vector3::SIDE_DOWN; + return ($direction->y > 0) ? Vector3::SIDE_UP : Vector3::SIDE_DOWN; } private function getZFace(Vector3 $direction){ - return (($direction->z) > 0) ? Vector3::SIDE_SOUTH : Vector3::SIDE_NORTH; + return ($direction->z > 0) ? Vector3::SIDE_SOUTH : Vector3::SIDE_NORTH; } private function getXLength(Vector3 $direction){ diff --git a/src/pocketmine/utils/UUID.php b/src/pocketmine/utils/UUID.php index 0aca65ad8..abdbfa0a9 100644 --- a/src/pocketmine/utils/UUID.php +++ b/src/pocketmine/utils/UUID.php @@ -92,7 +92,7 @@ class UUID{ } public function toString(){ - $hex = bin2hex(self::toBinary()); + $hex = bin2hex($this->toBinary()); //xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx 8-4-4-4-12 if($this->version !== null){ diff --git a/src/pocketmine/utils/Utils.php b/src/pocketmine/utils/Utils.php index 45794b12a..92d22e5a3 100644 --- a/src/pocketmine/utils/Utils.php +++ b/src/pocketmine/utils/Utils.php @@ -461,7 +461,9 @@ class Utils{ $headerGroup = []; foreach(explode("\r\n", $rawHeaderGroup) as $line){ $nameValue = explode(":", $line, 2); - if(isset($nameValue[1])) $headerGroup[trim(strtolower($nameValue[0]))] = trim($nameValue[1]); + if(isset($nameValue[1])){ + $headerGroup[trim(strtolower($nameValue[0]))] = trim($nameValue[1]); + } } $headers[] = $headerGroup; } diff --git a/src/pocketmine/utils/VersionString.php b/src/pocketmine/utils/VersionString.php index 3f4b3cb66..0d03d8599 100644 --- a/src/pocketmine/utils/VersionString.php +++ b/src/pocketmine/utils/VersionString.php @@ -43,9 +43,9 @@ class VersionString{ $this->generation = isset($version[2]) ? (int) $version[2] : 0; //0-15 $this->major = isset($version[3]) ? (int) $version[3] : 0; //0-15 $this->minor = isset($version[4]) ? (int) $version[4] : 0; //0-31 - $this->development = $version[5] === "dev" ? true : false; + $this->development = $version[5] === "dev"; if($version[6] !== ""){ - $this->build = intval(substr($version[6], 1)); + $this->build = (int) (substr($version[6], 1)); }else{ $this->build = 0; }