mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 18:32:55 +00:00
avoid type juggling in conditions, always use explicit boolean conditions
This commit is contained in:
@ -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<int, string> $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)";
|
||||
|
Reference in New Issue
Block a user