From 77453108700972b96c297645e28a336461ba129d Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 7 Feb 2021 17:54:38 +0000 Subject: [PATCH] Use native property types for login JSON models this significantly reduces the amount of PHPDoc boilerplate, because the remaining doc comments can mostly be reduced to 1 line. --- .../types/login/AuthenticationData.php | 24 +- .../mcpe/protocol/types/login/ClientData.php | 233 +++++------------- .../types/login/ClientDataAnimationFrame.php | 42 +--- .../login/ClientDataPersonaPieceTintColor.php | 11 +- .../login/ClientDataPersonaSkinPiece.php | 37 +-- .../protocol/types/login/JwtBodyRfc7519.php | 20 +- .../mcpe/protocol/types/login/JwtChain.php | 2 +- .../protocol/types/login/JwtChainLinkBody.php | 5 +- .../mcpe/protocol/types/login/JwtHeader.php | 16 +- 9 files changed, 117 insertions(+), 273 deletions(-) diff --git a/src/network/mcpe/protocol/types/login/AuthenticationData.php b/src/network/mcpe/protocol/types/login/AuthenticationData.php index 6e48143d2..535d8ca43 100644 --- a/src/network/mcpe/protocol/types/login/AuthenticationData.php +++ b/src/network/mcpe/protocol/types/login/AuthenticationData.php @@ -28,24 +28,14 @@ namespace pocketmine\network\mcpe\protocol\types\login; */ final class AuthenticationData{ - /** - * @var string - * @required - */ - public $displayName; + /** @required */ + public string $displayName; - /** - * @var string - * @required - */ - public $identity; + /** @required */ + public string $identity; - /** @var string */ - public $titleId = ""; //TODO: find out what this is for + public string $titleId = ""; //TODO: find out what this is for - /** - * @var string - * @required - */ - public $XUID; + /** @required */ + public string $XUID; } diff --git a/src/network/mcpe/protocol/types/login/ClientData.php b/src/network/mcpe/protocol/types/login/ClientData.php index b2d9bbc57..c949ffcda 100644 --- a/src/network/mcpe/protocol/types/login/ClientData.php +++ b/src/network/mcpe/protocol/types/login/ClientData.php @@ -32,212 +32,115 @@ final class ClientData{ * @var ClientDataAnimationFrame[] * @required */ - public $AnimatedImageData; + public array $AnimatedImageData; - /** - * @var string - * @required - */ - public $ArmSize; + /** @required */ + public string $ArmSize; - /** - * @var string - * @required - */ - public $CapeData; + /** @required */ + public string $CapeData; - /** - * @var string - * @required - */ - public $CapeId; + /** @required */ + public string $CapeId; - /** - * @var int - * @required - */ - public $CapeImageHeight; + /** @required */ + public int $CapeImageHeight; - /** - * @var int - * @required - */ - public $CapeImageWidth; + /** @required */ + public int $CapeImageWidth; - /** - * @var bool - * @required - */ - public $CapeOnClassicSkin; + /** @required */ + public bool $CapeOnClassicSkin; - /** - * @var int - * @required - */ - public $ClientRandomId; + /** @required */ + public int $ClientRandomId; - /** - * @var int - * @required - */ - public $CurrentInputMode; + /** @required */ + public int $CurrentInputMode; - /** - * @var int - * @required - */ - public $DefaultInputMode; + /** @required */ + public int $DefaultInputMode; - /** - * @var string - * @required - */ - public $DeviceId; + /** @required */ + public string $DeviceId; - /** - * @var string - * @required - */ - public $DeviceModel; + /** @required */ + public string $DeviceModel; - /** - * @var int - * @required - */ - public $DeviceOS; + /** @required */ + public int $DeviceOS; - /** - * @var string - * @required - */ - public $GameVersion; + /** @required */ + public string $GameVersion; - /** - * @var int - * @required - */ - public $GuiScale; + /** @required */ + public int $GuiScale; - /** - * @var string - * @required - */ - public $LanguageCode; + /** @required */ + public string $LanguageCode; /** * @var ClientDataPersonaSkinPiece[] * @required */ - public $PersonaPieces; + public array $PersonaPieces; - /** - * @var bool - * @required - */ - public $PersonaSkin; + /** @required */ + public bool $PersonaSkin; /** * @var ClientDataPersonaPieceTintColor[] * @required */ - public $PieceTintColors; + public array $PieceTintColors; - /** - * @var string - * @required - */ - public $PlatformOfflineId; + /** @required */ + public string $PlatformOfflineId; - /** - * @var string - * @required - */ - public $PlatformOnlineId; + /** @required */ + public string $PlatformOnlineId; - /** @var string */ - public $PlatformUserId = ""; //xbox-only, apparently + public string $PlatformUserId = ""; //xbox-only, apparently - /** - * @var bool - * @required - */ - public $PremiumSkin = false; + /** @required */ + public bool $PremiumSkin = false; - /** - * @var string - * @required - */ - public $SelfSignedId; + /** @required */ + public string $SelfSignedId; - /** - * @var string - * @required - */ - public $ServerAddress; + /** @required */ + public string $ServerAddress; - /** - * @var string - * @required - */ - public $SkinAnimationData; + /** @required */ + public string $SkinAnimationData; - /** - * @var string - * @required - */ - public $SkinColor; + /** @required */ + public string $SkinColor; - /** - * @var string - * @required - */ - public $SkinData; + /** @required */ + public string $SkinData; - /** - * @var string - * @required - */ - public $SkinGeometryData; + /** @required */ + public string $SkinGeometryData; - /** - * @var string - * @required - */ - public $SkinId; + /** @required */ + public string $SkinId; - /** - * @var int - * @required - */ - public $SkinImageHeight; + /** @required */ + public int $SkinImageHeight; - /** - * @var int - * @required - */ - public $SkinImageWidth; + /** @required */ + public int $SkinImageWidth; - /** - * @var string - * @required - */ - public $SkinResourcePatch; + /** @required */ + public string $SkinResourcePatch; - /** - * @var string - * @required - */ - public $ThirdPartyName; + /** @required */ + public string $ThirdPartyName; - /** - * @var bool - * @required - */ - public $ThirdPartyNameOnly; + /** @required */ + public bool $ThirdPartyNameOnly; - /** - * @var int - * @required - */ - public $UIProfile; + /** @required */ + public int $UIProfile; } diff --git a/src/network/mcpe/protocol/types/login/ClientDataAnimationFrame.php b/src/network/mcpe/protocol/types/login/ClientDataAnimationFrame.php index f1a80f0ca..843b03ce2 100644 --- a/src/network/mcpe/protocol/types/login/ClientDataAnimationFrame.php +++ b/src/network/mcpe/protocol/types/login/ClientDataAnimationFrame.php @@ -28,39 +28,21 @@ namespace pocketmine\network\mcpe\protocol\types\login; */ final class ClientDataAnimationFrame{ - /** - * @var int - * @required - */ - public $ImageHeight; + /** @required */ + public int $ImageHeight; - /** - * @var int - * @required - */ - public $ImageWidth; + /** @required */ + public int $ImageWidth; - /** - * @var float - * @required - */ - public $Frames; + /** @required */ + public float $Frames; - /** - * @var int - * @required - */ - public $Type; + /** @required */ + public int $Type; - /** - * @var string - * @required - */ - public $Image; + /** @required */ + public string $Image; - /** - * @var int - * @required - */ - public $AnimationExpression; + /** @required */ + public int $AnimationExpression; } diff --git a/src/network/mcpe/protocol/types/login/ClientDataPersonaPieceTintColor.php b/src/network/mcpe/protocol/types/login/ClientDataPersonaPieceTintColor.php index 676e480cb..7f4ec4538 100644 --- a/src/network/mcpe/protocol/types/login/ClientDataPersonaPieceTintColor.php +++ b/src/network/mcpe/protocol/types/login/ClientDataPersonaPieceTintColor.php @@ -27,15 +27,12 @@ namespace pocketmine\network\mcpe\protocol\types\login; * Model class for LoginPacket JSON data for JsonMapper */ final class ClientDataPersonaPieceTintColor{ - /** - * @var string - * @required - */ - public $PieceType; + /** @required */ + public string $PieceType; /** * @var string[] * @required */ - public $Colors; -} \ No newline at end of file + public array $Colors; +} diff --git a/src/network/mcpe/protocol/types/login/ClientDataPersonaSkinPiece.php b/src/network/mcpe/protocol/types/login/ClientDataPersonaSkinPiece.php index 6efae7289..6be302662 100644 --- a/src/network/mcpe/protocol/types/login/ClientDataPersonaSkinPiece.php +++ b/src/network/mcpe/protocol/types/login/ClientDataPersonaSkinPiece.php @@ -27,33 +27,18 @@ namespace pocketmine\network\mcpe\protocol\types\login; * Model class for LoginPacket JSON data for JsonMapper */ final class ClientDataPersonaSkinPiece{ - /** - * @var string - * @required - */ - public $PieceId; + /** @required */ + public string $PieceId; - /** - * @var string - * @required - */ - public $PieceType; + /** @required */ + public string $PieceType; - /** - * @var string - * @required - */ - public $PackId; + /** @required */ + public string $PackId; - /** - * @var bool - * @required - */ - public $IsDefault; + /** @required */ + public bool $IsDefault; - /** - * @var string - * @required - */ - public $ProductId; -} \ No newline at end of file + /** @required */ + public string $ProductId; +} diff --git a/src/network/mcpe/protocol/types/login/JwtBodyRfc7519.php b/src/network/mcpe/protocol/types/login/JwtBodyRfc7519.php index 301779401..b048e2d9f 100644 --- a/src/network/mcpe/protocol/types/login/JwtBodyRfc7519.php +++ b/src/network/mcpe/protocol/types/login/JwtBodyRfc7519.php @@ -28,18 +28,12 @@ namespace pocketmine\network\mcpe\protocol\types\login; * provided. */ class JwtBodyRfc7519{ - /** @var string */ - public $iss; - /** @var string */ - public $sub; + public string $iss; + public string $sub; /** @var string|string[] */ public $aud; - /** @var int */ - public $exp; - /** @var int */ - public $nbf; - /** @var int */ - public $iat; - /** @var string */ - public $jti; -} \ No newline at end of file + public int $exp; + public int $nbf; + public int $iat; + public string $jti; +} diff --git a/src/network/mcpe/protocol/types/login/JwtChain.php b/src/network/mcpe/protocol/types/login/JwtChain.php index b8dc21d3b..357558023 100644 --- a/src/network/mcpe/protocol/types/login/JwtChain.php +++ b/src/network/mcpe/protocol/types/login/JwtChain.php @@ -32,5 +32,5 @@ final class JwtChain{ * @var string[] * @required */ - public $chain; + public array $chain; } diff --git a/src/network/mcpe/protocol/types/login/JwtChainLinkBody.php b/src/network/mcpe/protocol/types/login/JwtChainLinkBody.php index e3c0c5f18..d547f9c08 100644 --- a/src/network/mcpe/protocol/types/login/JwtChainLinkBody.php +++ b/src/network/mcpe/protocol/types/login/JwtChainLinkBody.php @@ -28,6 +28,5 @@ namespace pocketmine\network\mcpe\protocol\types\login; * TODO: extend this with more complete models */ final class JwtChainLinkBody extends JwtBodyRfc7519{ - /** @var string */ - public $identityPublicKey; -} \ No newline at end of file + public string $identityPublicKey; +} diff --git a/src/network/mcpe/protocol/types/login/JwtHeader.php b/src/network/mcpe/protocol/types/login/JwtHeader.php index 285f4ca78..f768f17c8 100644 --- a/src/network/mcpe/protocol/types/login/JwtHeader.php +++ b/src/network/mcpe/protocol/types/login/JwtHeader.php @@ -24,14 +24,8 @@ declare(strict_types=1); namespace pocketmine\network\mcpe\protocol\types\login; final class JwtHeader{ - /** - * @var string - * @required - */ - public $alg; - /** - * @var string - * @required - */ - public $x5u; -} \ No newline at end of file + /** @required */ + public string $alg; + /** @required */ + public string $x5u; +}