From 7fb1669c6d547202bbfa47b206c6929719c930e2 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 14 Dec 2021 23:14:39 +0000 Subject: [PATCH] php-cs-fixer: added binary_operator_spaces and unary_operator_spaces rules --- .php-cs-fixer.php | 4 ++++ src/pocketmine/entity/Entity.php | 8 +++---- src/pocketmine/level/format/io/ChunkUtils.php | 2 +- .../mcpe/protocol/AdventureSettingsPacket.php | 4 ++-- .../mcpe/protocol/AvailableCommandsPacket.php | 22 +++++++++---------- .../mcpe/protocol/LevelChunkPacket.php | 2 +- .../mcpe/protocol/UpdateBlockPacket.php | 6 ++--- src/pocketmine/utils/Config.php | 8 +++---- 8 files changed, 30 insertions(+), 26 deletions(-) diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index aa00fc033..01a6e52c0 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -19,6 +19,9 @@ return (new PhpCsFixer\Config) 'array_syntax' => [ 'syntax' => 'short' ], + 'binary_operator_spaces' => [ + 'default' => 'single_space' + ], 'blank_line_after_namespace' => true, 'blank_line_after_opening_tag' => true, 'blank_line_before_statement' => [ @@ -74,6 +77,7 @@ return (new PhpCsFixer\Config) ], 'single_import_per_statement' => true, 'strict_param' => true, + 'unary_operator_spaces' => true, ]) ->setFinder($finder) ->setIndent("\t") diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index 22cae83dc..927fc64cd 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -1230,10 +1230,10 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ $diffZ = $z - $floorZ; if(BlockFactory::$solid[$this->level->getBlockIdAt($floorX, $floorY, $floorZ)]){ - $westNonSolid = !BlockFactory::$solid[$this->level->getBlockIdAt($floorX - 1, $floorY, $floorZ)]; - $eastNonSolid = !BlockFactory::$solid[$this->level->getBlockIdAt($floorX + 1, $floorY, $floorZ)]; - $downNonSolid = !BlockFactory::$solid[$this->level->getBlockIdAt($floorX, $floorY - 1, $floorZ)]; - $upNonSolid = !BlockFactory::$solid[$this->level->getBlockIdAt($floorX, $floorY + 1, $floorZ)]; + $westNonSolid = !BlockFactory::$solid[$this->level->getBlockIdAt($floorX - 1, $floorY, $floorZ)]; + $eastNonSolid = !BlockFactory::$solid[$this->level->getBlockIdAt($floorX + 1, $floorY, $floorZ)]; + $downNonSolid = !BlockFactory::$solid[$this->level->getBlockIdAt($floorX, $floorY - 1, $floorZ)]; + $upNonSolid = !BlockFactory::$solid[$this->level->getBlockIdAt($floorX, $floorY + 1, $floorZ)]; $northNonSolid = !BlockFactory::$solid[$this->level->getBlockIdAt($floorX, $floorY, $floorZ - 1)]; $southNonSolid = !BlockFactory::$solid[$this->level->getBlockIdAt($floorX, $floorY, $floorZ + 1)]; diff --git a/src/pocketmine/level/format/io/ChunkUtils.php b/src/pocketmine/level/format/io/ChunkUtils.php index 0bfb52fdc..98abf40fa 100644 --- a/src/pocketmine/level/format/io/ChunkUtils.php +++ b/src/pocketmine/level/format/io/ChunkUtils.php @@ -81,7 +81,7 @@ if(!extension_loaded('pocketmine_chunkutils')){ }else{ $i1 = ord($array[$j]); $i2 = ord($array[$j80]); - $result[$i] = chr(($i2 << 4) | ($i1 & 0x0f)); + $result[$i] = chr(($i2 << 4) | ($i1 & 0x0f)); $result[$i | 0x80] = chr(($i1 >> 4) | ($i2 & 0xf0)); } $i++; diff --git a/src/pocketmine/network/mcpe/protocol/AdventureSettingsPacket.php b/src/pocketmine/network/mcpe/protocol/AdventureSettingsPacket.php index 427784d32..49645974c 100644 --- a/src/pocketmine/network/mcpe/protocol/AdventureSettingsPacket.php +++ b/src/pocketmine/network/mcpe/protocol/AdventureSettingsPacket.php @@ -108,9 +108,9 @@ class AdventureSettingsPacket extends DataPacket{ */ public function setFlag(int $flag, bool $value){ if(($flag & self::BITFLAG_SECOND_SET) !== 0){ - $flagSet =& $this->flags2; + $flagSet = &$this->flags2; }else{ - $flagSet =& $this->flags; + $flagSet = &$this->flags; } if($value){ diff --git a/src/pocketmine/network/mcpe/protocol/AvailableCommandsPacket.php b/src/pocketmine/network/mcpe/protocol/AvailableCommandsPacket.php index 5b2d4c3d9..40dad3338 100644 --- a/src/pocketmine/network/mcpe/protocol/AvailableCommandsPacket.php +++ b/src/pocketmine/network/mcpe/protocol/AvailableCommandsPacket.php @@ -48,27 +48,27 @@ class AvailableCommandsPacket extends DataPacket{ * Basic parameter types. These must be combined with the ARG_FLAG_VALID constant. * ARG_FLAG_VALID | (type const) */ - public const ARG_TYPE_INT = 0x01; - public const ARG_TYPE_FLOAT = 0x03; - public const ARG_TYPE_VALUE = 0x04; - public const ARG_TYPE_WILDCARD_INT = 0x05; - public const ARG_TYPE_OPERATOR = 0x06; - public const ARG_TYPE_TARGET = 0x07; + public const ARG_TYPE_INT = 0x01; + public const ARG_TYPE_FLOAT = 0x03; + public const ARG_TYPE_VALUE = 0x04; + public const ARG_TYPE_WILDCARD_INT = 0x05; + public const ARG_TYPE_OPERATOR = 0x06; + public const ARG_TYPE_TARGET = 0x07; public const ARG_TYPE_WILDCARD_TARGET = 0x08; public const ARG_TYPE_FILEPATH = 0x10; - public const ARG_TYPE_STRING = 0x20; + public const ARG_TYPE_STRING = 0x20; public const ARG_TYPE_POSITION = 0x28; - public const ARG_TYPE_MESSAGE = 0x2c; + public const ARG_TYPE_MESSAGE = 0x2c; - public const ARG_TYPE_RAWTEXT = 0x2e; + public const ARG_TYPE_RAWTEXT = 0x2e; - public const ARG_TYPE_JSON = 0x32; + public const ARG_TYPE_JSON = 0x32; - public const ARG_TYPE_COMMAND = 0x3f; + public const ARG_TYPE_COMMAND = 0x3f; /** * Enums are a little different: they are composed as follows: diff --git a/src/pocketmine/network/mcpe/protocol/LevelChunkPacket.php b/src/pocketmine/network/mcpe/protocol/LevelChunkPacket.php index 43c5ee894..e859a76bb 100644 --- a/src/pocketmine/network/mcpe/protocol/LevelChunkPacket.php +++ b/src/pocketmine/network/mcpe/protocol/LevelChunkPacket.php @@ -106,7 +106,7 @@ class LevelChunkPacket extends DataPacket/* implements ClientboundPacket*/{ $this->subChunkCount = $this->getUnsignedVarInt(); $this->cacheEnabled = $this->getBool(); if($this->cacheEnabled){ - for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){ + for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){ $this->usedBlobHashes[] = $this->getLLong(); } } diff --git a/src/pocketmine/network/mcpe/protocol/UpdateBlockPacket.php b/src/pocketmine/network/mcpe/protocol/UpdateBlockPacket.php index 9e7ca6c32..25d24dfdb 100644 --- a/src/pocketmine/network/mcpe/protocol/UpdateBlockPacket.php +++ b/src/pocketmine/network/mcpe/protocol/UpdateBlockPacket.php @@ -30,11 +30,11 @@ use pocketmine\network\mcpe\NetworkSession; class UpdateBlockPacket extends DataPacket{ public const NETWORK_ID = ProtocolInfo::UPDATE_BLOCK_PACKET; - public const FLAG_NONE = 0b0000; + public const FLAG_NONE = 0b0000; public const FLAG_NEIGHBORS = 0b0001; - public const FLAG_NETWORK = 0b0010; + public const FLAG_NETWORK = 0b0010; public const FLAG_NOGRAPHIC = 0b0100; - public const FLAG_PRIORITY = 0b1000; + public const FLAG_PRIORITY = 0b1000; public const FLAG_ALL = self::FLAG_NEIGHBORS | self::FLAG_NETWORK; public const FLAG_ALL_PRIORITY = self::FLAG_ALL | self::FLAG_PRIORITY; diff --git a/src/pocketmine/utils/Config.php b/src/pocketmine/utils/Config.php index cdeafbb9f..f38a0e2a3 100644 --- a/src/pocketmine/utils/Config.php +++ b/src/pocketmine/utils/Config.php @@ -368,14 +368,14 @@ class Config{ $this->config[$base] = []; } - $base =& $this->config[$base]; + $base = &$this->config[$base]; while(count($vars) > 0){ $baseKey = array_shift($vars); if(!isset($base[$baseKey])){ $base[$baseKey] = []; } - $base =& $base[$baseKey]; + $base = &$base[$baseKey]; } $base = $value; @@ -420,14 +420,14 @@ class Config{ $vars = explode(".", $key); - $currentNode =& $this->config; + $currentNode = &$this->config; while(count($vars) > 0){ $nodeName = array_shift($vars); if(isset($currentNode[$nodeName])){ if(count($vars) === 0){ //final node unset($currentNode[$nodeName]); }elseif(is_array($currentNode[$nodeName])){ - $currentNode =& $currentNode[$nodeName]; + $currentNode = &$currentNode[$nodeName]; } }else{ break;