diff --git a/src/pocketmine/Server.php b/src/pocketmine/Server.php index 9688b085a..110c2eae2 100644 --- a/src/pocketmine/Server.php +++ b/src/pocketmine/Server.php @@ -1885,7 +1885,7 @@ class Server{ $this->rcon->stop(); } - if($this->getProperty("network.upnp-forwarding", false)){ + if((bool) $this->getProperty("network.upnp-forwarding", false)){ $this->logger->info("[UPnP] Removing port forward..."); UPnP::RemovePortForward($this->getPort()); } @@ -1958,12 +1958,12 @@ class Server{ $this->network->blockAddress($entry->getName(), -1); } - if($this->getProperty("settings.send-usage", true)){ + if((bool) $this->getProperty("settings.send-usage", true)){ $this->sendUsageTicker = 6000; $this->sendUsage(SendUsageTask::TYPE_OPEN); } - if($this->getProperty("network.upnp-forwarding", false)){ + if((bool) $this->getProperty("network.upnp-forwarding", false)){ $this->logger->info("[UPnP] Trying to port forward..."); try{ UPnP::PortForward($this->getPort()); @@ -2089,7 +2089,7 @@ class Server{ } if($report){ - $url = ($this->getProperty("auto-report.use-https", true) ? "https" : "http") . "://" . $this->getProperty("auto-report.host", "crash.pmmp.io") . "/submit/api"; + $url = ((bool) $this->getProperty("auto-report.use-https", true) ? "https" : "http") . "://" . $this->getProperty("auto-report.host", "crash.pmmp.io") . "/submit/api"; $reply = Internet::postURL($url, [ "report" => "yes", "name" => $this->getName() . " " . $this->getPocketMineVersion(), diff --git a/src/pocketmine/block/Anvil.php b/src/pocketmine/block/Anvil.php index 73aceebb5..2eb8880af 100644 --- a/src/pocketmine/block/Anvil.php +++ b/src/pocketmine/block/Anvil.php @@ -78,7 +78,7 @@ class Anvil extends Fallable{ public function recalculateBoundingBox() : ?AxisAlignedBB{ $inset = 0.125; - if($this->meta & 0x01){ //east/west + if(($this->meta & 0x01) !== 0){ //east/west return new AxisAlignedBB( $this->x, $this->y, diff --git a/src/pocketmine/block/Block.php b/src/pocketmine/block/Block.php index f9e4d8cc4..df18785e1 100644 --- a/src/pocketmine/block/Block.php +++ b/src/pocketmine/block/Block.php @@ -563,7 +563,7 @@ class Block extends Position implements BlockIds, Metadatable{ * @return AxisAlignedBB[] */ protected function recalculateCollisionBoxes() : array{ - if($bb = $this->recalculateBoundingBox()){ + if(($bb = $this->recalculateBoundingBox()) !== null){ return [$bb]; } diff --git a/src/pocketmine/block/DoublePlant.php b/src/pocketmine/block/DoublePlant.php index 7ed21c5f9..ccb8c1cbd 100644 --- a/src/pocketmine/block/DoublePlant.php +++ b/src/pocketmine/block/DoublePlant.php @@ -70,7 +70,7 @@ class DoublePlant extends Flowable{ * Returns whether this double-plant has a corresponding other half. */ public function isValidHalfPlant() : bool{ - if($this->meta & self::BITFLAG_TOP){ + if(($this->meta & self::BITFLAG_TOP) !== 0){ $other = $this->getSide(Vector3::SIDE_DOWN); }else{ $other = $this->getSide(Vector3::SIDE_UP); @@ -102,7 +102,7 @@ class DoublePlant extends Flowable{ } public function getDrops(Item $item) : array{ - if($this->meta & self::BITFLAG_TOP){ + if(($this->meta & self::BITFLAG_TOP) !== 0){ if($this->isCompatibleWithTool($item)){ return parent::getDrops($item); } diff --git a/src/pocketmine/block/Leaves.php b/src/pocketmine/block/Leaves.php index a760e604e..788e4a781 100644 --- a/src/pocketmine/block/Leaves.php +++ b/src/pocketmine/block/Leaves.php @@ -172,7 +172,7 @@ class Leaves extends Transparent{ } public function getDrops(Item $item) : array{ - if($item->getBlockToolType() & BlockToolType::TYPE_SHEARS){ + if(($item->getBlockToolType() & BlockToolType::TYPE_SHEARS) !== 0){ return $this->getDropsForCompatibleTool($item); } diff --git a/src/pocketmine/block/Vine.php b/src/pocketmine/block/Vine.php index c451d0bae..dadc7a329 100644 --- a/src/pocketmine/block/Vine.php +++ b/src/pocketmine/block/Vine.php @@ -197,7 +197,7 @@ class Vine extends Flowable{ } public function getDrops(Item $item) : array{ - if($item->getBlockToolType() & BlockToolType::TYPE_SHEARS){ + if(($item->getBlockToolType() & BlockToolType::TYPE_SHEARS) !== 0){ return $this->getDropsForCompatibleTool($item); } diff --git a/src/pocketmine/entity/DataPropertyManager.php b/src/pocketmine/entity/DataPropertyManager.php index 78cdcfafa..d3f3afcb1 100644 --- a/src/pocketmine/entity/DataPropertyManager.php +++ b/src/pocketmine/entity/DataPropertyManager.php @@ -115,7 +115,7 @@ class DataPropertyManager{ } public function setBlockPos(int $key, ?Vector3 $value, bool $force = false) : void{ - $this->setPropertyValue($key, Entity::DATA_TYPE_POS, $value ? $value->floor() : null, $force); + $this->setPropertyValue($key, Entity::DATA_TYPE_POS, $value !== null ? $value->floor() : null, $force); } public function getLong(int $key) : ?int{ @@ -135,7 +135,7 @@ class DataPropertyManager{ } public function setVector3(int $key, ?Vector3 $value, bool $force = false) : void{ - $this->setPropertyValue($key, Entity::DATA_TYPE_VECTOR3F, $value ? $value->asVector3() : null, $force); + $this->setPropertyValue($key, Entity::DATA_TYPE_VECTOR3F, $value !== null ? $value->asVector3() : null, $force); } public function removeProperty(int $key) : void{ diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index acda13eb7..0c511a9ad 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -424,9 +424,9 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ new DoubleTag("", $pos->z) ]), new ListTag("Motion", [ - new DoubleTag("", $motion ? $motion->x : 0.0), - new DoubleTag("", $motion ? $motion->y : 0.0), - new DoubleTag("", $motion ? $motion->z : 0.0) + new DoubleTag("", $motion !== null ? $motion->x : 0.0), + new DoubleTag("", $motion !== null ? $motion->y : 0.0), + new DoubleTag("", $motion !== null ? $motion->z : 0.0) ]), new ListTag("Rotation", [ new FloatTag("", $yaw), diff --git a/src/pocketmine/inventory/CraftingManager.php b/src/pocketmine/inventory/CraftingManager.php index add9969e2..661811fb7 100644 --- a/src/pocketmine/inventory/CraftingManager.php +++ b/src/pocketmine/inventory/CraftingManager.php @@ -144,7 +144,7 @@ class CraftingManager{ */ public static function sort(Item $i1, Item $i2){ //Use spaceship operator to compare each property, then try the next one if they are equivalent. - ($retval = $i1->getId() <=> $i2->getId()) === 0 && ($retval = $i1->getDamage() <=> $i2->getDamage()) === 0 && ($retval = $i1->getCount() <=> $i2->getCount()); + ($retval = $i1->getId() <=> $i2->getId()) === 0 && ($retval = $i1->getDamage() <=> $i2->getDamage()) === 0 && ($retval = $i1->getCount() <=> $i2->getCount()) === 0; return $retval; } diff --git a/src/pocketmine/level/SimpleChunkManager.php b/src/pocketmine/level/SimpleChunkManager.php index da236cc50..3f8b46ea3 100644 --- a/src/pocketmine/level/SimpleChunkManager.php +++ b/src/pocketmine/level/SimpleChunkManager.php @@ -51,7 +51,7 @@ class SimpleChunkManager implements ChunkManager{ * @return int 0-255 */ public function getBlockIdAt(int $x, int $y, int $z) : int{ - if($chunk = $this->getChunk($x >> 4, $z >> 4)){ + if(($chunk = $this->getChunk($x >> 4, $z >> 4)) !== null){ return $chunk->getBlockId($x & 0xf, $y, $z & 0xf); } return 0; @@ -65,7 +65,7 @@ class SimpleChunkManager implements ChunkManager{ * @return void */ public function setBlockIdAt(int $x, int $y, int $z, int $id){ - if($chunk = $this->getChunk($x >> 4, $z >> 4)){ + if(($chunk = $this->getChunk($x >> 4, $z >> 4)) !== null){ $chunk->setBlockId($x & 0xf, $y, $z & 0xf, $id); } } @@ -76,7 +76,7 @@ class SimpleChunkManager implements ChunkManager{ * @return int 0-15 */ public function getBlockDataAt(int $x, int $y, int $z) : int{ - if($chunk = $this->getChunk($x >> 4, $z >> 4)){ + if(($chunk = $this->getChunk($x >> 4, $z >> 4)) !== null){ return $chunk->getBlockData($x & 0xf, $y, $z & 0xf); } return 0; @@ -90,13 +90,13 @@ class SimpleChunkManager implements ChunkManager{ * @return void */ public function setBlockDataAt(int $x, int $y, int $z, int $data){ - if($chunk = $this->getChunk($x >> 4, $z >> 4)){ + if(($chunk = $this->getChunk($x >> 4, $z >> 4)) !== null){ $chunk->setBlockData($x & 0xf, $y, $z & 0xf, $data); } } public function getBlockLightAt(int $x, int $y, int $z) : int{ - if($chunk = $this->getChunk($x >> 4, $z >> 4)){ + if(($chunk = $this->getChunk($x >> 4, $z >> 4)) !== null){ return $chunk->getBlockLight($x & 0xf, $y, $z & 0xf); } @@ -104,13 +104,13 @@ class SimpleChunkManager implements ChunkManager{ } public function setBlockLightAt(int $x, int $y, int $z, int $level){ - if($chunk = $this->getChunk($x >> 4, $z >> 4)){ + if(($chunk = $this->getChunk($x >> 4, $z >> 4)) !== null){ $chunk->setBlockLight($x & 0xf, $y, $z & 0xf, $level); } } public function getBlockSkyLightAt(int $x, int $y, int $z) : int{ - if($chunk = $this->getChunk($x >> 4, $z >> 4)){ + if(($chunk = $this->getChunk($x >> 4, $z >> 4)) !== null){ return $chunk->getBlockSkyLight($x & 0xf, $y, $z & 0xf); } @@ -118,7 +118,7 @@ class SimpleChunkManager implements ChunkManager{ } public function setBlockSkyLightAt(int $x, int $y, int $z, int $level){ - if($chunk = $this->getChunk($x >> 4, $z >> 4)){ + if(($chunk = $this->getChunk($x >> 4, $z >> 4)) !== null){ $chunk->setBlockSkyLight($x & 0xf, $y, $z & 0xf, $level); } } diff --git a/src/pocketmine/network/mcpe/NetworkBinaryStream.php b/src/pocketmine/network/mcpe/NetworkBinaryStream.php index 6bf5d4dac..f197ac3b7 100644 --- a/src/pocketmine/network/mcpe/NetworkBinaryStream.php +++ b/src/pocketmine/network/mcpe/NetworkBinaryStream.php @@ -516,7 +516,7 @@ class NetworkBinaryStream extends BinaryStream{ * @see NetworkBinaryStream::putVector3() */ public function putVector3Nullable(?Vector3 $vector) : void{ - if($vector){ + if($vector !== null){ $this->putVector3($vector); }else{ $this->putLFloat(0.0); diff --git a/src/pocketmine/network/mcpe/protocol/AdventureSettingsPacket.php b/src/pocketmine/network/mcpe/protocol/AdventureSettingsPacket.php index 6712ab2d7..b6c72b01e 100644 --- a/src/pocketmine/network/mcpe/protocol/AdventureSettingsPacket.php +++ b/src/pocketmine/network/mcpe/protocol/AdventureSettingsPacket.php @@ -94,7 +94,7 @@ class AdventureSettingsPacket extends DataPacket{ } public function getFlag(int $flag) : bool{ - if($flag & self::BITFLAG_SECOND_SET){ + if(($flag & self::BITFLAG_SECOND_SET) !== 0){ return ($this->flags2 & $flag) !== 0; } @@ -105,7 +105,7 @@ class AdventureSettingsPacket extends DataPacket{ * @return void */ public function setFlag(int $flag, bool $value){ - if($flag & self::BITFLAG_SECOND_SET){ + if(($flag & self::BITFLAG_SECOND_SET) !== 0){ $flagSet =& $this->flags2; }else{ $flagSet =& $this->flags; diff --git a/src/pocketmine/network/mcpe/protocol/AnimatePacket.php b/src/pocketmine/network/mcpe/protocol/AnimatePacket.php index 6b9a8e1a2..75f67a471 100644 --- a/src/pocketmine/network/mcpe/protocol/AnimatePacket.php +++ b/src/pocketmine/network/mcpe/protocol/AnimatePacket.php @@ -47,7 +47,7 @@ class AnimatePacket extends DataPacket{ protected function decodePayload(){ $this->action = $this->getVarInt(); $this->entityRuntimeId = $this->getEntityRuntimeId(); - if($this->action & 0x80){ + if(($this->action & 0x80) !== 0){ $this->float = $this->getLFloat(); } } @@ -55,7 +55,7 @@ class AnimatePacket extends DataPacket{ protected function encodePayload(){ $this->putVarInt($this->action); $this->putEntityRuntimeId($this->entityRuntimeId); - if($this->action & 0x80){ + if(($this->action & 0x80) !== 0){ $this->putLFloat($this->float); } } diff --git a/src/pocketmine/network/mcpe/protocol/AvailableCommandsPacket.php b/src/pocketmine/network/mcpe/protocol/AvailableCommandsPacket.php index d2c7104c2..883e3724f 100644 --- a/src/pocketmine/network/mcpe/protocol/AvailableCommandsPacket.php +++ b/src/pocketmine/network/mcpe/protocol/AvailableCommandsPacket.php @@ -295,13 +295,13 @@ class AvailableCommandsPacket extends DataPacket{ $parameter->isOptional = $this->getBool(); $parameter->flags = $this->getByte(); - if($parameter->paramType & self::ARG_FLAG_ENUM){ + if(($parameter->paramType & self::ARG_FLAG_ENUM) !== 0){ $index = ($parameter->paramType & 0xffff); $parameter->enum = $enums[$index] ?? null; if($parameter->enum === null){ throw new \UnexpectedValueException("deserializing $retval->commandName parameter $parameter->paramName: expected enum at $index, but got none"); } - }elseif($parameter->paramType & self::ARG_FLAG_POSTFIX){ + }elseif(($parameter->paramType & self::ARG_FLAG_POSTFIX) !== 0){ $index = ($parameter->paramType & 0xffff); $parameter->postfix = $postfixes[$index] ?? null; if($parameter->postfix === null){ @@ -365,8 +365,8 @@ class AvailableCommandsPacket extends DataPacket{ * @phpstan-param array $postfixes */ private function argTypeToString(int $argtype, array $postfixes) : string{ - if($argtype & self::ARG_FLAG_VALID){ - if($argtype & self::ARG_FLAG_ENUM){ + if(($argtype & self::ARG_FLAG_VALID) !== 0){ + if(($argtype & self::ARG_FLAG_ENUM) !== 0){ return "stringenum (" . ($argtype & 0xffff) . ")"; } @@ -392,7 +392,7 @@ class AvailableCommandsPacket extends DataPacket{ case self::ARG_TYPE_COMMAND: return "command"; } - }elseif($argtype & self::ARG_FLAG_POSTFIX){ + }elseif(($argtype & self::ARG_FLAG_POSTFIX) !== 0){ $postfix = $postfixes[$argtype & 0xffff]; return "int (postfix $postfix)"; diff --git a/src/pocketmine/network/mcpe/protocol/MoveActorDeltaPacket.php b/src/pocketmine/network/mcpe/protocol/MoveActorDeltaPacket.php index c92265abd..1728b936d 100644 --- a/src/pocketmine/network/mcpe/protocol/MoveActorDeltaPacket.php +++ b/src/pocketmine/network/mcpe/protocol/MoveActorDeltaPacket.php @@ -55,14 +55,14 @@ class MoveActorDeltaPacket extends DataPacket{ public $zRot = 0.0; private function maybeReadCoord(int $flag) : int{ - if($this->flags & $flag){ + if(($this->flags & $flag) !== 0){ return $this->getVarInt(); } return 0; } private function maybeReadRotation(int $flag) : float{ - if($this->flags & $flag){ + if(($this->flags & $flag) !== 0){ return $this->getByteRotation(); } return 0.0; @@ -80,13 +80,13 @@ class MoveActorDeltaPacket extends DataPacket{ } private function maybeWriteCoord(int $flag, int $val) : void{ - if($this->flags & $flag){ + if(($this->flags & $flag) !== 0){ $this->putVarInt($val); } } private function maybeWriteRotation(int $flag, float $val) : void{ - if($this->flags & $flag){ + if(($this->flags & $flag) !== 0){ $this->putByteRotation($val); } } diff --git a/src/pocketmine/updater/AutoUpdater.php b/src/pocketmine/updater/AutoUpdater.php index e27a406da..e0d35adcc 100644 --- a/src/pocketmine/updater/AutoUpdater.php +++ b/src/pocketmine/updater/AutoUpdater.php @@ -53,7 +53,7 @@ class AutoUpdater{ $this->server = $server; $this->endpoint = "http://$endpoint/api/"; - if($server->getProperty("auto-updater.enabled", true)){ + if((bool) $server->getProperty("auto-updater.enabled", true)){ $this->doCheck(); } } @@ -71,10 +71,10 @@ class AutoUpdater{ $this->checkUpdate(); if($this->hasUpdate()){ (new UpdateNotifyEvent($this))->call(); - if($this->server->getProperty("auto-updater.on-update.warn-console", true)){ + if((bool) $this->server->getProperty("auto-updater.on-update.warn-console", true)){ $this->showConsoleUpdate(); } - }elseif($this->server->getProperty("auto-updater.preferred-channel", true)){ + }else{ if(!\pocketmine\IS_DEVELOPMENT_BUILD and $this->getChannel() !== "stable"){ $this->showChannelSuggestionStable(); }elseif(\pocketmine\IS_DEVELOPMENT_BUILD and $this->getChannel() === "stable"){ diff --git a/src/pocketmine/utils/Utils.php b/src/pocketmine/utils/Utils.php index 46e291c0d..f68eab4a3 100644 --- a/src/pocketmine/utils/Utils.php +++ b/src/pocketmine/utils/Utils.php @@ -478,7 +478,7 @@ class Utils{ $hash = 0; for($i = 0, $len = strlen($string); $i < $len; $i++){ $ord = ord($string[$i]); - if($ord & 0x80){ + if(($ord & 0x80) !== 0){ $ord -= 0x100; } $hash = 31 * $hash + $ord; @@ -671,7 +671,7 @@ class Utils{ * @throws \ErrorException */ public static function errorExceptionHandler(int $severity, string $message, string $file, int $line) : bool{ - if(error_reporting() & $severity){ + if((error_reporting() & $severity) !== 0){ throw new \ErrorException($message, 0, $severity, $file, $line); }