mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-20 16:00:20 +00:00
Modernize private property declarations in Threaded classes
I previously avoided this due to being unsure of the effects; however, it's clear that we already use typed properties on Threaded things in other places anyway, and the only known issues are with uninit properties, and arrays.
This commit is contained in:
parent
d4b7f66e15
commit
df3a69dcb7
@ -49,8 +49,7 @@ class ChunkRequestTask extends AsyncTask{
|
||||
/** @var Compressor */
|
||||
protected $compressor;
|
||||
|
||||
/** @var string */
|
||||
private $tiles = "";
|
||||
private string $tiles;
|
||||
|
||||
/**
|
||||
* @phpstan-param (\Closure() : void)|null $onError
|
||||
|
@ -42,39 +42,33 @@ class ProcessLoginTask extends AsyncTask{
|
||||
|
||||
private const CLOCK_DRIFT_MAX = 60;
|
||||
|
||||
/** @var string */
|
||||
private $chain;
|
||||
/** @var string */
|
||||
private $clientDataJwt;
|
||||
private string $chain;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
* Whether the keychain signatures were validated correctly. This will be set to an error message if any link in the
|
||||
* keychain is invalid for whatever reason (bad signature, not in nbf-exp window, etc). If this is non-null, the
|
||||
* keychain might have been tampered with. The player will always be disconnected if this is non-null.
|
||||
*/
|
||||
private $error = "Unknown";
|
||||
private ?string $error = "Unknown";
|
||||
/**
|
||||
* @var bool
|
||||
* Whether the player is logged into Xbox Live. This is true if any link in the keychain is signed with the Mojang
|
||||
* root public key.
|
||||
*/
|
||||
private $authenticated = false;
|
||||
/** @var bool */
|
||||
private $authRequired;
|
||||
|
||||
/** @var string|null */
|
||||
private $clientPublicKey = null;
|
||||
private bool $authenticated = false;
|
||||
private ?string $clientPublicKey = null;
|
||||
|
||||
/**
|
||||
* @param string[] $chainJwts
|
||||
* @phpstan-param \Closure(bool $isAuthenticated, bool $authRequired, ?string $error, ?string $clientPublicKey) : void $onCompletion
|
||||
*/
|
||||
public function __construct(array $chainJwts, string $clientDataJwt, bool $authRequired, \Closure $onCompletion){
|
||||
public function __construct(
|
||||
array $chainJwts,
|
||||
private string $clientDataJwt,
|
||||
private bool $authRequired,
|
||||
\Closure $onCompletion
|
||||
){
|
||||
$this->storeLocal(self::TLS_KEY_ON_COMPLETION, $onCompletion);
|
||||
$this->chain = igbinary_serialize($chainJwts);
|
||||
$this->clientDataJwt = $clientDataJwt;
|
||||
$this->authRequired = $authRequired;
|
||||
}
|
||||
|
||||
public function onRun() : void{
|
||||
|
@ -29,14 +29,11 @@ class CompressBatchTask extends AsyncTask{
|
||||
|
||||
private const TLS_KEY_PROMISE = "promise";
|
||||
|
||||
/** @var string */
|
||||
private $data;
|
||||
/** @var Compressor */
|
||||
private $compressor;
|
||||
|
||||
public function __construct(string $data, CompressBatchPromise $promise, Compressor $compressor){
|
||||
$this->data = $data;
|
||||
$this->compressor = $compressor;
|
||||
public function __construct(
|
||||
private string $data,
|
||||
CompressBatchPromise $promise,
|
||||
private Compressor $compressor
|
||||
){
|
||||
$this->storeLocal(self::TLS_KEY_PROMISE, $promise);
|
||||
}
|
||||
|
||||
|
@ -39,20 +39,18 @@ class PrepareEncryptionTask extends AsyncTask{
|
||||
|
||||
private static ?\OpenSSLAsymmetricKey $SERVER_PRIVATE_KEY = null;
|
||||
|
||||
/** @var string */
|
||||
private $serverPrivateKey;
|
||||
private string $serverPrivateKey;
|
||||
|
||||
/** @var string|null */
|
||||
private $aesKey = null;
|
||||
/** @var string|null */
|
||||
private $handshakeJwt = null;
|
||||
/** @var string */
|
||||
private $clientPub;
|
||||
private ?string $aesKey = null;
|
||||
private ?string $handshakeJwt = null;
|
||||
|
||||
/**
|
||||
* @phpstan-param \Closure(string $encryptionKey, string $handshakeJwt) : void $onCompletion
|
||||
*/
|
||||
public function __construct(string $clientPub, \Closure $onCompletion){
|
||||
public function __construct(
|
||||
private string $clientPub,
|
||||
\Closure $onCompletion
|
||||
){
|
||||
if(self::$SERVER_PRIVATE_KEY === null){
|
||||
$serverPrivateKey = openssl_pkey_new(["ec" => ["curve_name" => "secp384r1"]]);
|
||||
if($serverPrivateKey === false){
|
||||
@ -62,7 +60,6 @@ class PrepareEncryptionTask extends AsyncTask{
|
||||
}
|
||||
|
||||
$this->serverPrivateKey = igbinary_serialize(openssl_pkey_get_details(self::$SERVER_PRIVATE_KEY));
|
||||
$this->clientPub = $clientPub;
|
||||
$this->storeLocal(self::TLS_KEY_ON_COMPLETION, $onCompletion);
|
||||
}
|
||||
|
||||
|
@ -40,8 +40,7 @@ use function register_shutdown_function;
|
||||
use const PTHREADS_INHERIT_NONE;
|
||||
|
||||
class RakLibServer extends Thread{
|
||||
/** @var InternetAddress */
|
||||
private $address;
|
||||
private InternetAddress $address;
|
||||
|
||||
/** @var \ThreadedLogger */
|
||||
protected $logger;
|
||||
@ -63,8 +62,8 @@ class RakLibServer extends Thread{
|
||||
protected $serverId;
|
||||
/** @var int */
|
||||
protected $maxMtuSize;
|
||||
/** @var int */
|
||||
private $protocolVersion;
|
||||
|
||||
private int $protocolVersion;
|
||||
|
||||
/** @var SleeperNotifier */
|
||||
protected $mainThreadNotifier;
|
||||
|
@ -62,19 +62,13 @@ abstract class AsyncTask extends \Threaded{
|
||||
/** @var \Threaded */
|
||||
public $progressUpdates;
|
||||
|
||||
/** @var scalar|null */
|
||||
private $result = null;
|
||||
/** @var bool */
|
||||
private $serialized = false;
|
||||
/** @var bool */
|
||||
private $cancelRun = false;
|
||||
/** @var bool */
|
||||
private $submitted = false;
|
||||
private string|int|bool|null|float $result = null;
|
||||
private bool $serialized = false;
|
||||
private bool $cancelRun = false;
|
||||
private bool $submitted = false;
|
||||
|
||||
/** @var bool */
|
||||
private $crashed = false;
|
||||
/** @var bool */
|
||||
private $finished = false;
|
||||
private bool $crashed = false;
|
||||
private bool $finished = false;
|
||||
|
||||
public function run() : void{
|
||||
$this->result = null;
|
||||
|
@ -37,8 +37,7 @@ use function igbinary_unserialize;
|
||||
class BulkCurlTask extends AsyncTask{
|
||||
private const TLS_KEY_COMPLETION_CALLBACK = "completionCallback";
|
||||
|
||||
/** @var string */
|
||||
private $operations;
|
||||
private string $operations;
|
||||
|
||||
/**
|
||||
* BulkCurlTask constructor.
|
||||
|
@ -31,8 +31,7 @@ class ServerKiller extends Thread{
|
||||
/** @var int */
|
||||
public $time;
|
||||
|
||||
/** @var bool */
|
||||
private $stopped = false;
|
||||
private bool $stopped = false;
|
||||
|
||||
/**
|
||||
* @param int $time
|
||||
|
@ -40,12 +40,9 @@ class LightPopulationTask extends AsyncTask{
|
||||
/** @var string */
|
||||
public $chunk;
|
||||
|
||||
/** @var string */
|
||||
private $resultHeightMap;
|
||||
/** @var string */
|
||||
private $resultSkyLightArrays;
|
||||
/** @var string */
|
||||
private $resultBlockLightArrays;
|
||||
private string $resultHeightMap;
|
||||
private string $resultSkyLightArrays;
|
||||
private string $resultBlockLightArrays;
|
||||
|
||||
/**
|
||||
* @phpstan-param \Closure(array<int, LightArray> $blockLight, array<int, LightArray> $skyLight, array<int, int> $heightMap) : void $onCompletion
|
||||
|
Loading…
x
Reference in New Issue
Block a user