diff --git a/src/utils/Config.php b/src/utils/Config.php index f15bfe1e5..3fa78df80 100644 --- a/src/utils/Config.php +++ b/src/utils/Config.php @@ -74,23 +74,19 @@ class Config{ * @var mixed[] * @phpstan-var array */ - private $config = []; + private array $config = []; /** * @var mixed[] * @phpstan-var array */ - private $nestedCache = []; + private array $nestedCache = []; - /** @var string */ - private $file; - /** @var int */ - private $type = Config::DETECT; - /** @var int */ - private $jsonOptions = JSON_PRETTY_PRINT | JSON_BIGINT_AS_STRING; + private string $file; + private int $type = Config::DETECT; + private int $jsonOptions = JSON_PRETTY_PRINT | JSON_BIGINT_AS_STRING; - /** @var bool */ - private $changed = false; + private bool $changed = false; /** @var int[] */ public static $formats = [ diff --git a/src/utils/Filesystem.php b/src/utils/Filesystem.php index 56d45790e..3a4ef243f 100644 --- a/src/utils/Filesystem.php +++ b/src/utils/Filesystem.php @@ -61,12 +61,12 @@ use const SCANDIR_SORT_NONE; final class Filesystem{ /** @var resource[] */ - private static $lockFileHandles = []; + private static array $lockFileHandles = []; /** * @var string[] * @phpstan-var array */ - private static $cleanedPaths = [ + private static array $cleanedPaths = [ \pocketmine\PATH => self::CLEAN_PATH_SRC_PREFIX ]; diff --git a/src/utils/InternetRequestResult.php b/src/utils/InternetRequestResult.php index 481ceedb3..c952c2d6b 100644 --- a/src/utils/InternetRequestResult.php +++ b/src/utils/InternetRequestResult.php @@ -24,26 +24,15 @@ declare(strict_types=1); namespace pocketmine\utils; final class InternetRequestResult{ - - /** - * @var string[][] - * @phpstan-var list> - */ - private $headers; - /** @var string */ - private $body; - /** @var int */ - private $code; - /** * @param string[][] $headers * @phpstan-param list> $headers */ - public function __construct(array $headers, string $body, int $code){ - $this->headers = $headers; - $this->body = $body; - $this->code = $code; - } + public function __construct( + private array $headers, + private string $body, + private int $code + ){} /** * @return string[][] diff --git a/src/utils/Random.php b/src/utils/Random.php index 3c7f6cb0d..6e932a079 100644 --- a/src/utils/Random.php +++ b/src/utils/Random.php @@ -35,17 +35,10 @@ class Random{ public const Z = 521288629; public const W = 88675123; - /** @var int */ - private $x; - - /** @var int */ - private $y; - - /** @var int */ - private $z; - - /** @var int */ - private $w; + private int $x; + private int $y; + private int $z; + private int $w; /** @var int */ protected $seed; diff --git a/src/utils/Terminal.php b/src/utils/Terminal.php index 955abc660..c89ad7805 100644 --- a/src/utils/Terminal.php +++ b/src/utils/Terminal.php @@ -60,8 +60,7 @@ abstract class Terminal{ public static string $COLOR_WHITE = ""; public static string $COLOR_MINECOIN_GOLD = ""; - /** @var bool|null */ - private static $formattingCodes = null; + private static ?bool $formattingCodes = null; public static function hasFormattingCodes() : bool{ if(self::$formattingCodes === null){ diff --git a/src/utils/Utils.php b/src/utils/Utils.php index adb3187f5..b44eb9bff 100644 --- a/src/utils/Utils.php +++ b/src/utils/Utils.php @@ -105,10 +105,8 @@ final class Utils{ public const OS_BSD = "bsd"; public const OS_UNKNOWN = "other"; - /** @var string|null */ - private static $os; - /** @var UuidInterface|null */ - private static $serverUniqueId = null; + private static ?string $os; + private static ?UuidInterface $serverUniqueId = null; /** * Returns a readable identifier for the given Closure, including file and line. diff --git a/src/utils/VersionString.php b/src/utils/VersionString.php index 0b2aed47a..2d2cb6bca 100644 --- a/src/utils/VersionString.php +++ b/src/utils/VersionString.php @@ -30,28 +30,16 @@ use function preg_match; * Manages PocketMine-MP version strings, and compares them */ class VersionString{ - /** @var string */ - private $baseVersion; - /** @var string */ - private $suffix; - - /** @var int */ - private $major; - /** @var int */ - private $minor; - /** @var int */ - private $patch; - - /** @var int */ - private $build; - /** @var bool */ - private $development = false; - - public function __construct(string $baseVersion, bool $isDevBuild = false, int $buildNumber = 0){ - $this->baseVersion = $baseVersion; - $this->development = $isDevBuild; - $this->build = $buildNumber; + private int $major; + private int $minor; + private int $patch; + private string $suffix; + public function __construct( + private string $baseVersion, + private bool $isDevBuild = false, + private int $buildNumber = 0 + ){ preg_match('/^(\d+)\.(\d+)\.(\d+)(?:-(.*))?$/', $this->baseVersion, $matches); if(count($matches) < 4){ throw new \InvalidArgumentException("Invalid base version \"$baseVersion\", should contain at least 3 version digits"); @@ -77,10 +65,10 @@ class VersionString{ public function getFullVersion(bool $build = false) : string{ $retval = $this->baseVersion; - if($this->development){ + if($this->isDevBuild){ $retval .= "+dev"; - if($build && $this->build > 0){ - $retval .= "." . $this->build; + if($build && $this->buildNumber > 0){ + $retval .= "." . $this->buildNumber; } } @@ -104,11 +92,11 @@ class VersionString{ } public function getBuild() : int{ - return $this->build; + return $this->buildNumber; } public function isDev() : bool{ - return $this->development; + return $this->isDevBuild; } public function __toString() : string{