CS: Standardize new with braces

This commit is contained in:
Dylan K. Taylor 2022-08-15 17:16:04 +01:00
parent 8fa81242d6
commit dce8bd6d21
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
11 changed files with 18 additions and 14 deletions

View File

@ -70,6 +70,10 @@ BODY,
'scope' => 'namespaced', 'scope' => 'namespaced',
'include' => ['@all'], 'include' => ['@all'],
], ],
'new_with_braces' => [
'named_class' => true,
'anonymous_class' => false,
],
'no_closing_tag' => true, 'no_closing_tag' => true,
'no_empty_phpdoc' => true, 'no_empty_phpdoc' => true,
'no_extra_blank_lines' => true, 'no_extra_blank_lines' => true,

View File

@ -35,7 +35,7 @@ final class StringToEffectParser extends StringToTParser{
use SingletonTrait; use SingletonTrait;
private static function make() : self{ private static function make() : self{
$result = new self; $result = new self();
$result->register("absorption", fn() => VanillaEffects::ABSORPTION()); $result->register("absorption", fn() => VanillaEffects::ABSORPTION());
$result->register("blindness", fn() => VanillaEffects::BLINDNESS()); $result->register("blindness", fn() => VanillaEffects::BLINDNESS());

View File

@ -31,7 +31,7 @@ class HandlerListManager{
private static ?self $globalInstance = null; private static ?self $globalInstance = null;
public static function global() : self{ public static function global() : self{
return self::$globalInstance ?? (self::$globalInstance = new self); return self::$globalInstance ?? (self::$globalInstance = new self());
} }
/** @var HandlerList[] classname => HandlerList */ /** @var HandlerList[] classname => HandlerList */

View File

@ -41,7 +41,7 @@ final class StringToItemParser extends StringToTParser{
use SingletonTrait; use SingletonTrait;
private static function make() : self{ private static function make() : self{
$result = new self; $result = new self();
foreach(DyeColor::getAll() as $color){ foreach(DyeColor::getAll() as $color){
$prefix = fn(string $name) => $color->name() . "_" . $name; $prefix = fn(string $name) => $color->name() . "_" . $name;

View File

@ -35,7 +35,7 @@ final class StringToEnchantmentParser extends StringToTParser{
use SingletonTrait; use SingletonTrait;
private static function make() : self{ private static function make() : self{
$result = new self; $result = new self();
$result->register("blast_protection", fn() => VanillaEnchantments::BLAST_PROTECTION()); $result->register("blast_protection", fn() => VanillaEnchantments::BLAST_PROTECTION());
$result->register("efficiency", fn() => VanillaEnchantments::EFFICIENCY()); $result->register("efficiency", fn() => VanillaEnchantments::EFFICIENCY());

View File

@ -165,13 +165,13 @@ class LoginPacketHandler extends PacketHandler{
if(!is_array($claims["extraData"])){ if(!is_array($claims["extraData"])){
throw new PacketHandlingException("'extraData' key should be an array"); throw new PacketHandlingException("'extraData' key should be an array");
} }
$mapper = new \JsonMapper; $mapper = new \JsonMapper();
$mapper->bEnforceMapType = false; //TODO: we don't really need this as an array, but right now we don't have enough models $mapper->bEnforceMapType = false; //TODO: we don't really need this as an array, but right now we don't have enough models
$mapper->bExceptionOnMissingData = true; $mapper->bExceptionOnMissingData = true;
$mapper->bExceptionOnUndefinedProperty = true; $mapper->bExceptionOnUndefinedProperty = true;
try{ try{
/** @var AuthenticationData $extraData */ /** @var AuthenticationData $extraData */
$extraData = $mapper->map($claims["extraData"], new AuthenticationData); $extraData = $mapper->map($claims["extraData"], new AuthenticationData());
}catch(\JsonMapper_Exception $e){ }catch(\JsonMapper_Exception $e){
throw PacketHandlingException::wrap($e); throw PacketHandlingException::wrap($e);
} }
@ -193,12 +193,12 @@ class LoginPacketHandler extends PacketHandler{
throw PacketHandlingException::wrap($e); throw PacketHandlingException::wrap($e);
} }
$mapper = new \JsonMapper; $mapper = new \JsonMapper();
$mapper->bEnforceMapType = false; //TODO: we don't really need this as an array, but right now we don't have enough models $mapper->bEnforceMapType = false; //TODO: we don't really need this as an array, but right now we don't have enough models
$mapper->bExceptionOnMissingData = true; $mapper->bExceptionOnMissingData = true;
$mapper->bExceptionOnUndefinedProperty = true; $mapper->bExceptionOnUndefinedProperty = true;
try{ try{
$clientData = $mapper->map($clientDataClaims, new ClientData); $clientData = $mapper->map($clientDataClaims, new ClientData());
}catch(\JsonMapper_Exception $e){ }catch(\JsonMapper_Exception $e){
throw PacketHandlingException::wrap($e); throw PacketHandlingException::wrap($e);
} }

View File

@ -84,8 +84,8 @@ class RakLibInterface implements ServerEventListener, AdvancedNetworkInterface{
$this->sleeper = new SleeperNotifier(); $this->sleeper = new SleeperNotifier();
$mainToThreadBuffer = new \Threaded; $mainToThreadBuffer = new \Threaded();
$threadToMainBuffer = new \Threaded; $threadToMainBuffer = new \Threaded();
$this->rakLib = new RakLibServer( $this->rakLib = new RakLibServer(
$this->server->getLogger(), $this->server->getLogger(),

View File

@ -31,7 +31,7 @@ class PermissionManager{
public static function getInstance() : PermissionManager{ public static function getInstance() : PermissionManager{
if(self::$instance === null){ if(self::$instance === null){
self::$instance = new self; self::$instance = new self();
} }
return self::$instance; return self::$instance;

View File

@ -163,7 +163,7 @@ class AsyncPool{
throw new \InvalidArgumentException("Cannot submit the same AsyncTask instance more than once"); throw new \InvalidArgumentException("Cannot submit the same AsyncTask instance more than once");
} }
$task->progressUpdates = new \Threaded; $task->progressUpdates = new \Threaded();
$task->setSubmitted(); $task->setSubmitted();
$this->getWorker($worker)->stack($task); $this->getWorker($worker)->stack($task);

View File

@ -28,7 +28,7 @@ trait SingletonTrait{
private static $instance = null; private static $instance = null;
private static function make() : self{ private static function make() : self{
return new self; return new self();
} }
public static function getInstance() : self{ public static function getInstance() : self{

View File

@ -48,7 +48,7 @@ final class WorldCreationOptions{
} }
public static function create() : self{ public static function create() : self{
return new self; return new self();
} }
/** @phpstan-return class-string<Generator> */ /** @phpstan-return class-string<Generator> */