diff --git a/src/block/BaseRail.php b/src/block/BaseRail.php index ffc1cb8df..017a3953b 100644 --- a/src/block/BaseRail.php +++ b/src/block/BaseRail.php @@ -79,7 +79,7 @@ abstract class BaseRail extends Flowable{ } protected function writeStateToMeta() : int{ - if(empty($this->connections)){ + if(count($this->connections) === 0){ return BlockLegacyMetadata::RAIL_STRAIGHT_NORTH_SOUTH; } return $this->getMetaForState($this->connections); diff --git a/src/block/Fence.php b/src/block/Fence.php index 2a9d02d54..2c99279b4 100644 --- a/src/block/Fence.php +++ b/src/block/Fence.php @@ -25,6 +25,7 @@ namespace pocketmine\block; use pocketmine\math\AxisAlignedBB; use pocketmine\math\Facing; +use function count; class Fence extends Transparent{ /** @var bool[] facing => dummy */ @@ -80,7 +81,7 @@ class Fence extends Transparent{ ->trim(Facing::SOUTH, $connectSouth ? 0 : $inset); } - if(empty($bbs)){ + if(count($bbs) === 0){ //centre post AABB (only needed if not connected on any axis - other BBs overlapping will do this if any connections are made) return [ AxisAlignedBB::one() diff --git a/src/block/Thin.php b/src/block/Thin.php index e98cc8465..1df772698 100644 --- a/src/block/Thin.php +++ b/src/block/Thin.php @@ -25,6 +25,7 @@ namespace pocketmine\block; use pocketmine\math\AxisAlignedBB; use pocketmine\math\Facing; +use function count; class Thin extends Transparent{ /** @var bool[] facing => dummy */ @@ -71,7 +72,7 @@ class Thin extends Transparent{ $bbs[] = $bb; } - if(empty($bbs)){ + if(count($bbs) === 0){ //centre post AABB (only needed if not connected on any axis - other BBs overlapping will do this if any connections are made) return [ AxisAlignedBB::one()->contract($inset, 0, $inset) diff --git a/src/block/Vine.php b/src/block/Vine.php index 017e474ae..b590c740d 100644 --- a/src/block/Vine.php +++ b/src/block/Vine.php @@ -30,6 +30,7 @@ use pocketmine\math\Vector3; use pocketmine\player\Player; use pocketmine\world\BlockTransaction; use function array_intersect_key; +use function count; class Vine extends Flowable{ @@ -113,7 +114,7 @@ class Vine extends Flowable{ } if($changed){ - if(empty($this->faces)){ + if(count($this->faces) === 0){ $this->pos->getWorld()->useBreakOn($this->pos); }else{ $this->pos->getWorld()->setBlock($this->pos, $this); diff --git a/src/entity/Entity.php b/src/entity/Entity.php index 3237662f9..188ed7289 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -644,7 +644,7 @@ abstract class Entity{ $this->justCreated = false; $changedProperties = $this->getSyncedNetworkData(true); - if(!empty($changedProperties)){ + if(count($changedProperties) > 0){ $this->sendData($this->hasSpawned, $changedProperties); $this->networkProperties->clearDirtyProperties(); } diff --git a/src/entity/ExperienceManager.php b/src/entity/ExperienceManager.php index 12c4f894d..89e7d26fc 100644 --- a/src/entity/ExperienceManager.php +++ b/src/entity/ExperienceManager.php @@ -31,6 +31,7 @@ use pocketmine\world\sound\XpCollectSound; use pocketmine\world\sound\XpLevelUpSound; use function array_rand; use function ceil; +use function count; use function max; use function min; @@ -251,7 +252,7 @@ class ExperienceManager{ } } - if(!empty($equipment)){ + if(count($equipment) > 0){ $repairItem = $equipment[$k = array_rand($equipment)]; if($repairItem->getDamage() > 0){ $repairAmount = min($repairItem->getDamage(), $xpValue * 2); diff --git a/src/entity/Living.php b/src/entity/Living.php index 3e8d0aaf1..7acba21d9 100644 --- a/src/entity/Living.php +++ b/src/entity/Living.php @@ -186,7 +186,7 @@ abstract class Living extends Entity{ $nbt->setShort("Air", $this->getAirSupplyTicks()); - if(!empty($this->effectManager->all())){ + if(count($this->effectManager->all()) > 0){ $effects = []; foreach($this->effectManager->all() as $effect){ $effects[] = CompoundTag::create() diff --git a/src/entity/effect/EffectManager.php b/src/entity/effect/EffectManager.php index 8545f2232..9f05a4eb1 100644 --- a/src/entity/effect/EffectManager.php +++ b/src/entity/effect/EffectManager.php @@ -29,6 +29,7 @@ use pocketmine\event\entity\EntityEffectRemoveEvent; use pocketmine\utils\Color; use pocketmine\utils\Utils; use function abs; +use function count; use function spl_object_id; class EffectManager{ @@ -188,7 +189,7 @@ class EffectManager{ } } - if(!empty($colors)){ + if(count($colors) > 0){ $this->bubbleColor = Color::mix(...$colors); $this->onlyAmbientEffects = $ambient; }else{ @@ -217,7 +218,7 @@ class EffectManager{ } } - return !empty($this->effects); + return count($this->effects) > 0; } /** diff --git a/src/event/player/PlayerPreLoginEvent.php b/src/event/player/PlayerPreLoginEvent.php index 03a6d2b85..040c82770 100644 --- a/src/event/player/PlayerPreLoginEvent.php +++ b/src/event/player/PlayerPreLoginEvent.php @@ -26,6 +26,7 @@ namespace pocketmine\event\player; use pocketmine\event\Event; use pocketmine\player\PlayerInfo; use function array_keys; +use function count; /** * Called when a player connects to the server, prior to authentication taking place. @@ -139,7 +140,7 @@ class PlayerPreLoginEvent extends Event{ * Returns whether the player is allowed to continue logging in. */ public function isAllowed() : bool{ - return empty($this->kickReasons); + return count($this->kickReasons) === 0; } /** diff --git a/src/item/Item.php b/src/item/Item.php index e4d678b38..c8035873c 100644 --- a/src/item/Item.php +++ b/src/item/Item.php @@ -48,6 +48,7 @@ use pocketmine\utils\Binary; use pocketmine\utils\Utils; use function base64_decode; use function base64_encode; +use function count; use function get_class; use function gettype; use function hex2bin; @@ -326,7 +327,7 @@ class Item implements \JsonSerializable{ $display->setString(self::TAG_DISPLAY_NAME, $this->getCustomName()) : $display->removeTag(self::TAG_DISPLAY); - if(!empty($this->lore)){ + if(count($this->lore) > 0){ $loreTag = new ListTag(); foreach($this->lore as $line){ $loreTag->push(new StringTag($line)); diff --git a/src/item/ItemEnchantmentHandlingTrait.php b/src/item/ItemEnchantmentHandlingTrait.php index 3760e16c6..9ef8c6cee 100644 --- a/src/item/ItemEnchantmentHandlingTrait.php +++ b/src/item/ItemEnchantmentHandlingTrait.php @@ -25,6 +25,7 @@ namespace pocketmine\item; use pocketmine\item\enchantment\Enchantment; use pocketmine\item\enchantment\EnchantmentInstance; +use function count; /** * This trait encapsulates all enchantment handling needed for itemstacks. @@ -35,7 +36,7 @@ trait ItemEnchantmentHandlingTrait{ protected $enchantments = []; public function hasEnchantments() : bool{ - return !empty($this->enchantments); + return count($this->enchantments) > 0; } public function hasEnchantment(Enchantment $enchantment, int $level = -1) : bool{ diff --git a/src/network/mcpe/NetworkSession.php b/src/network/mcpe/NetworkSession.php index 33df65074..5b3725043 100644 --- a/src/network/mcpe/NetworkSession.php +++ b/src/network/mcpe/NetworkSession.php @@ -682,7 +682,7 @@ class NetworkSession{ $lname = strtolower($command->getName()); $aliases = $command->getAliases(); $aliasObj = null; - if(!empty($aliases)){ + if(count($aliases) > 0){ if(!in_array($lname, $aliases, true)){ //work around a client bug which makes the original name not show when aliases are used $aliases[] = $lname; diff --git a/src/network/mcpe/protocol/types/inventory/MismatchTransactionData.php b/src/network/mcpe/protocol/types/inventory/MismatchTransactionData.php index bd69eb244..7d3eedbdb 100644 --- a/src/network/mcpe/protocol/types/inventory/MismatchTransactionData.php +++ b/src/network/mcpe/protocol/types/inventory/MismatchTransactionData.php @@ -35,7 +35,7 @@ class MismatchTransactionData extends TransactionData{ } protected function decodeData(NetworkBinaryStream $stream) : void{ - if(!empty($this->actions)){ + if(count($this->actions) > 0){ throw new BadPacketException("Mismatch transaction type should not have any actions associated with it, but got " . count($this->actions)); } } diff --git a/src/permission/PermissionParser.php b/src/permission/PermissionParser.php index 33f8357ee..1be4ee2a5 100644 --- a/src/permission/PermissionParser.php +++ b/src/permission/PermissionParser.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace pocketmine\permission; +use function count; use function is_array; use function is_bool; use function ksort; @@ -151,7 +152,7 @@ class PermissionParser{ } $children[$name] = self::emitPermission($child); } - if(!empty($children)){ + if(count($children) > 0){ ksort($children); $result["children"] = $children; } diff --git a/src/player/Player.php b/src/player/Player.php index 93743445c..90708a8f6 100644 --- a/src/player/Player.php +++ b/src/player/Player.php @@ -901,7 +901,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener, } $this->loadQueue = $newOrder; - if(!empty($this->loadQueue) or !empty($unloadChunks)){ + if(count($this->loadQueue) > 0 or count($unloadChunks) > 0){ $this->networkSession->syncViewAreaCenterPoint($this->location, $this->viewDistance); } diff --git a/src/plugin/PluginManager.php b/src/plugin/PluginManager.php index b459e2bd8..5e031b741 100644 --- a/src/plugin/PluginManager.php +++ b/src/plugin/PluginManager.php @@ -243,7 +243,7 @@ class PluginManager{ continue; } $ambiguousVersions = ApiVersion::checkAmbiguousVersions($description->getCompatibleApis()); - if(!empty($ambiguousVersions)){ + if(count($ambiguousVersions) > 0){ $this->server->getLogger()->error($this->server->getLanguage()->translateString("pocketmine.plugin.loadError", [ $name, $this->server->getLanguage()->translateString("pocketmine.plugin.ambiguousMinAPI", [implode(", ", $ambiguousVersions)]) diff --git a/src/utils/RegistryTrait.php b/src/utils/RegistryTrait.php index ec6525302..f24a10478 100644 --- a/src/utils/RegistryTrait.php +++ b/src/utils/RegistryTrait.php @@ -88,7 +88,7 @@ trait RegistryTrait{ * @return object */ public static function __callStatic($name, $arguments){ - if(!empty($arguments)){ + if(count($arguments) > 0){ throw new \ArgumentCountError("Expected exactly 0 arguments, " . count($arguments) . " passed"); } try{ diff --git a/src/world/World.php b/src/world/World.php index 8ff05551a..dae02190d 100644 --- a/src/world/World.php +++ b/src/world/World.php @@ -608,7 +608,7 @@ class World implements ChunkManager{ $hash = World::chunkHash($chunkX, $chunkZ); if(isset($this->chunkListeners[$hash])){ unset($this->chunkListeners[$hash][spl_object_id($listener)]); - if(empty($this->chunkListeners[$hash])){ + if(count($this->chunkListeners[$hash]) === 0){ unset($this->chunkListeners[$hash]); } } @@ -622,7 +622,7 @@ class World implements ChunkManager{ foreach($this->chunkListeners as $hash => $listeners){ if(isset($listeners[$id])){ unset($this->chunkListeners[$hash][$id]); - if(empty($this->chunkListeners[$hash])){ + if(count($this->chunkListeners[$hash]) === 0){ unset($this->chunkListeners[$hash]); } } @@ -646,7 +646,7 @@ class World implements ChunkManager{ public function sendTime(Player ...$targets) : void{ $pk = SetTimePacket::create($this->time); - if(empty($targets)){ + if(count($targets) === 0){ $this->broadcastGlobalPacket($pk); }else{ $this->server->broadcastPackets($targets, [$pk]); @@ -2370,7 +2370,7 @@ class World implements ChunkManager{ */ public function sendDifficulty(Player ...$targets) : void{ $pk = SetDifficultyPacket::create($this->getDifficulty()); - if(empty($targets)){ + if(count($targets) === 0){ $this->broadcastGlobalPacket($pk); }else{ $this->server->broadcastPackets($targets, [$pk]); diff --git a/src/world/WorldManager.php b/src/world/WorldManager.php index f4d75910a..dd9853b1f 100644 --- a/src/world/WorldManager.php +++ b/src/world/WorldManager.php @@ -182,7 +182,7 @@ class WorldManager{ if(count($providers) !== 1){ $this->server->getLogger()->error($this->server->getLanguage()->translateString("pocketmine.level.loadError", [ $name, - empty($providers) ? + count($providers) === 0 ? $this->server->getLanguage()->translateString("pocketmine.level.unknownFormat") : $this->server->getLanguage()->translateString("pocketmine.level.ambiguousFormat", [implode(", ", array_keys($providers))]) ])); @@ -302,7 +302,7 @@ class WorldManager{ } $path = $this->server->getDataPath() . "worlds/" . $name . "/"; if(!($this->getWorldByName($name) instanceof World)){ - return !empty(WorldProviderManager::getMatchingProviders($path)); + return count(WorldProviderManager::getMatchingProviders($path)) > 0; } return true; diff --git a/src/world/format/Chunk.php b/src/world/format/Chunk.php index e09a0381f..eb48a5914 100644 --- a/src/world/format/Chunk.php +++ b/src/world/format/Chunk.php @@ -548,7 +548,7 @@ class Chunk{ } public function isDirty() : bool{ - return $this->dirtyFlags !== 0 or !empty($this->tiles) or !empty($this->getSavableEntities()); + return $this->dirtyFlags !== 0 or count($this->tiles) > 0 or count($this->getSavableEntities()) > 0; } public function getDirtyFlag(int $flag) : bool{ diff --git a/src/world/format/SubChunk.php b/src/world/format/SubChunk.php index 74056f62a..d4514403e 100644 --- a/src/world/format/SubChunk.php +++ b/src/world/format/SubChunk.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace pocketmine\world\format; use function array_values; +use function count; class SubChunk implements SubChunkInterface{ /** @var int */ @@ -55,18 +56,18 @@ class SubChunk implements SubChunkInterface{ } public function isEmptyFast() : bool{ - return empty($this->blockLayers); + return count($this->blockLayers) === 0; } public function getFullBlock(int $x, int $y, int $z) : int{ - if(empty($this->blockLayers)){ + if(count($this->blockLayers) === 0){ return $this->defaultBlock; } return $this->blockLayers[0]->get($x, $y, $z); } public function setFullBlock(int $x, int $y, int $z, int $block) : void{ - if(empty($this->blockLayers)){ + if(count($this->blockLayers) === 0){ $this->blockLayers[] = new PalettedBlockArray($this->defaultBlock); } $this->blockLayers[0]->set($x, $y, $z, $block); @@ -80,7 +81,7 @@ class SubChunk implements SubChunkInterface{ } public function getHighestBlockAt(int $x, int $z) : int{ - if(empty($this->blockLayers)){ + if(count($this->blockLayers) === 0){ return -1; } for($y = 15; $y >= 0; --$y){ diff --git a/src/world/format/io/leveldb/LevelDB.php b/src/world/format/io/leveldb/LevelDB.php index 319ac2297..a765dd03f 100644 --- a/src/world/format/io/leveldb/LevelDB.php +++ b/src/world/format/io/leveldb/LevelDB.php @@ -482,7 +482,7 @@ class LevelDB extends BaseWorldProvider implements WritableWorldProvider{ * @param CompoundTag[] $targets */ private function writeTags(array $targets, string $index, \LevelDBWriteBatch $write) : void{ - if(!empty($targets)){ + if(count($targets) > 0){ $nbt = new LittleEndianNbtSerializer(); $write->put($index, $nbt->writeMultiple(array_map(function(CompoundTag $tag) : TreeRoot{ return new TreeRoot($tag); }, $targets))); }else{