Modernize property declarations in src/utils

This commit is contained in:
Dylan K. Taylor 2022-04-28 13:12:12 +01:00
parent de12b701ac
commit 0e7e776862
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
7 changed files with 34 additions and 71 deletions

View File

@ -74,23 +74,19 @@ class Config{
* @var mixed[]
* @phpstan-var array<string, mixed>
*/
private $config = [];
private array $config = [];
/**
* @var mixed[]
* @phpstan-var array<string, mixed>
*/
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 = [

View File

@ -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<string, string>
*/
private static $cleanedPaths = [
private static array $cleanedPaths = [
\pocketmine\PATH => self::CLEAN_PATH_SRC_PREFIX
];

View File

@ -24,26 +24,15 @@ declare(strict_types=1);
namespace pocketmine\utils;
final class InternetRequestResult{
/**
* @var string[][]
* @phpstan-var list<array<string, string>>
*/
private $headers;
/** @var string */
private $body;
/** @var int */
private $code;
/**
* @param string[][] $headers
* @phpstan-param list<array<string, string>> $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[][]

View File

@ -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;

View File

@ -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){

View File

@ -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.

View File

@ -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{