php-cs-fixer: added binary_operator_spaces and unary_operator_spaces rules

This commit is contained in:
Dylan K. Taylor 2021-12-14 23:14:39 +00:00
parent a09817864b
commit 7fb1669c6d
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
8 changed files with 30 additions and 26 deletions

View File

@ -19,6 +19,9 @@ return (new PhpCsFixer\Config)
'array_syntax' => [ 'array_syntax' => [
'syntax' => 'short' 'syntax' => 'short'
], ],
'binary_operator_spaces' => [
'default' => 'single_space'
],
'blank_line_after_namespace' => true, 'blank_line_after_namespace' => true,
'blank_line_after_opening_tag' => true, 'blank_line_after_opening_tag' => true,
'blank_line_before_statement' => [ 'blank_line_before_statement' => [
@ -74,6 +77,7 @@ return (new PhpCsFixer\Config)
], ],
'single_import_per_statement' => true, 'single_import_per_statement' => true,
'strict_param' => true, 'strict_param' => true,
'unary_operator_spaces' => true,
]) ])
->setFinder($finder) ->setFinder($finder)
->setIndent("\t") ->setIndent("\t")

View File

@ -1230,10 +1230,10 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
$diffZ = $z - $floorZ; $diffZ = $z - $floorZ;
if(BlockFactory::$solid[$this->level->getBlockIdAt($floorX, $floorY, $floorZ)]){ if(BlockFactory::$solid[$this->level->getBlockIdAt($floorX, $floorY, $floorZ)]){
$westNonSolid = !BlockFactory::$solid[$this->level->getBlockIdAt($floorX - 1, $floorY, $floorZ)]; $westNonSolid = !BlockFactory::$solid[$this->level->getBlockIdAt($floorX - 1, $floorY, $floorZ)];
$eastNonSolid = !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)]; $downNonSolid = !BlockFactory::$solid[$this->level->getBlockIdAt($floorX, $floorY - 1, $floorZ)];
$upNonSolid = !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)]; $northNonSolid = !BlockFactory::$solid[$this->level->getBlockIdAt($floorX, $floorY, $floorZ - 1)];
$southNonSolid = !BlockFactory::$solid[$this->level->getBlockIdAt($floorX, $floorY, $floorZ + 1)]; $southNonSolid = !BlockFactory::$solid[$this->level->getBlockIdAt($floorX, $floorY, $floorZ + 1)];

View File

@ -81,7 +81,7 @@ if(!extension_loaded('pocketmine_chunkutils')){
}else{ }else{
$i1 = ord($array[$j]); $i1 = ord($array[$j]);
$i2 = ord($array[$j80]); $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)); $result[$i | 0x80] = chr(($i1 >> 4) | ($i2 & 0xf0));
} }
$i++; $i++;

View File

@ -108,9 +108,9 @@ class AdventureSettingsPacket extends DataPacket{
*/ */
public function setFlag(int $flag, bool $value){ public function setFlag(int $flag, bool $value){
if(($flag & self::BITFLAG_SECOND_SET) !== 0){ if(($flag & self::BITFLAG_SECOND_SET) !== 0){
$flagSet =& $this->flags2; $flagSet = &$this->flags2;
}else{ }else{
$flagSet =& $this->flags; $flagSet = &$this->flags;
} }
if($value){ if($value){

View File

@ -48,27 +48,27 @@ class AvailableCommandsPacket extends DataPacket{
* Basic parameter types. These must be combined with the ARG_FLAG_VALID constant. * Basic parameter types. These must be combined with the ARG_FLAG_VALID constant.
* ARG_FLAG_VALID | (type const) * ARG_FLAG_VALID | (type const)
*/ */
public const ARG_TYPE_INT = 0x01; public const ARG_TYPE_INT = 0x01;
public const ARG_TYPE_FLOAT = 0x03; public const ARG_TYPE_FLOAT = 0x03;
public const ARG_TYPE_VALUE = 0x04; public const ARG_TYPE_VALUE = 0x04;
public const ARG_TYPE_WILDCARD_INT = 0x05; public const ARG_TYPE_WILDCARD_INT = 0x05;
public const ARG_TYPE_OPERATOR = 0x06; public const ARG_TYPE_OPERATOR = 0x06;
public const ARG_TYPE_TARGET = 0x07; public const ARG_TYPE_TARGET = 0x07;
public const ARG_TYPE_WILDCARD_TARGET = 0x08; public const ARG_TYPE_WILDCARD_TARGET = 0x08;
public const ARG_TYPE_FILEPATH = 0x10; 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_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: * Enums are a little different: they are composed as follows:

View File

@ -106,7 +106,7 @@ class LevelChunkPacket extends DataPacket/* implements ClientboundPacket*/{
$this->subChunkCount = $this->getUnsignedVarInt(); $this->subChunkCount = $this->getUnsignedVarInt();
$this->cacheEnabled = $this->getBool(); $this->cacheEnabled = $this->getBool();
if($this->cacheEnabled){ 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(); $this->usedBlobHashes[] = $this->getLLong();
} }
} }

View File

@ -30,11 +30,11 @@ use pocketmine\network\mcpe\NetworkSession;
class UpdateBlockPacket extends DataPacket{ class UpdateBlockPacket extends DataPacket{
public const NETWORK_ID = ProtocolInfo::UPDATE_BLOCK_PACKET; 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_NEIGHBORS = 0b0001;
public const FLAG_NETWORK = 0b0010; public const FLAG_NETWORK = 0b0010;
public const FLAG_NOGRAPHIC = 0b0100; 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 = self::FLAG_NEIGHBORS | self::FLAG_NETWORK;
public const FLAG_ALL_PRIORITY = self::FLAG_ALL | self::FLAG_PRIORITY; public const FLAG_ALL_PRIORITY = self::FLAG_ALL | self::FLAG_PRIORITY;

View File

@ -368,14 +368,14 @@ class Config{
$this->config[$base] = []; $this->config[$base] = [];
} }
$base =& $this->config[$base]; $base = &$this->config[$base];
while(count($vars) > 0){ while(count($vars) > 0){
$baseKey = array_shift($vars); $baseKey = array_shift($vars);
if(!isset($base[$baseKey])){ if(!isset($base[$baseKey])){
$base[$baseKey] = []; $base[$baseKey] = [];
} }
$base =& $base[$baseKey]; $base = &$base[$baseKey];
} }
$base = $value; $base = $value;
@ -420,14 +420,14 @@ class Config{
$vars = explode(".", $key); $vars = explode(".", $key);
$currentNode =& $this->config; $currentNode = &$this->config;
while(count($vars) > 0){ while(count($vars) > 0){
$nodeName = array_shift($vars); $nodeName = array_shift($vars);
if(isset($currentNode[$nodeName])){ if(isset($currentNode[$nodeName])){
if(count($vars) === 0){ //final node if(count($vars) === 0){ //final node
unset($currentNode[$nodeName]); unset($currentNode[$nodeName]);
}elseif(is_array($currentNode[$nodeName])){ }elseif(is_array($currentNode[$nodeName])){
$currentNode =& $currentNode[$nodeName]; $currentNode = &$currentNode[$nodeName];
} }
}else{ }else{
break; break;