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:
Dylan K. Taylor
2022-05-17 22:42:18 +01:00
parent d4b7f66e15
commit df3a69dcb7
9 changed files with 37 additions and 62 deletions

View File

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