Bump PHP minimum requirement to 8.0

PHPStan failed on 7.4 after updating to 0.12.99, and I figured it was less hassle to just do this than fix the build. In any case, we stopped shipping 7.4 months ago, and warned at 3.22 release that 7.4 support would soon be dropped.
This commit is contained in:
Dylan K. Taylor
2021-10-09 20:09:42 +01:00
parent 289553fa46
commit 974d08efd6
15 changed files with 29 additions and 205 deletions

View File

@@ -36,7 +36,7 @@ namespace pocketmine {
require_once __DIR__ . '/VersionInfo.php';
const MIN_PHP_VERSION = "7.4.0";
const MIN_PHP_VERSION = "8.0.0";
/**
* @param string $message

View File

@@ -57,24 +57,15 @@ use const SOL_TCP;
class RCON{
/** @var Server */
private $server;
/**
* @var \Socket|resource
* @phpstan-var PhpSocket
*/
/** @var \Socket */
private $socket;
/** @var RCONInstance */
private $instance;
/**
* @var \Socket|resource
* @phpstan-var PhpSocket
*/
/** @var \Socket */
private $ipcMainSocket;
/**
* @var resource
* @phpstan-var PhpSocket
*/
/** @var \Socket */
private $ipcThreadSocket;
public function __construct(Server $server, string $password, int $port = 19132, string $interface = "0.0.0.0", int $maxClients = 50){

View File

@@ -60,10 +60,7 @@ class RCONInstance extends Thread{
/** @var bool */
private $stop;
/**
* @var \Socket|resource
* @phpstan-var PhpSocket
*/
/** @var \Socket */
private $socket;
/** @var string */
private $password;
@@ -71,21 +68,12 @@ class RCONInstance extends Thread{
private $maxClients;
/** @var \ThreadedLogger */
private $logger;
/**
* @var \Socket|resource
* @phpstan-var PhpSocket
*/
/** @var \Socket */
private $ipcSocket;
/** @var SleeperNotifier|null */
private $notifier;
/**
* @param \Socket|resource $socket
* @param \Socket|resource $ipcSocket
* @phpstan-param PhpSocket $socket
* @phpstan-param PhpSocket $ipcSocket
*/
public function __construct($socket, string $password, int $maxClients, \ThreadedLogger $logger, $ipcSocket, ?SleeperNotifier $notifier){
public function __construct(\Socket $socket, string $password, int $maxClients, \ThreadedLogger $logger, \Socket $ipcSocket, ?SleeperNotifier $notifier){
$this->stop = false;
$this->cmd = "";
$this->response = "";
@@ -100,12 +88,9 @@ class RCONInstance extends Thread{
}
/**
* @param \Socket|resource $client
* @phpstan-param PhpSocket $client
*
* @return int|false
*/
private function writePacket($client, int $requestID, int $packetType, string $payload){
private function writePacket(\Socket $client, int $requestID, int $packetType, string $payload){
$pk = Binary::writeLInt($requestID)
. Binary::writeLInt($packetType)
. $payload
@@ -114,15 +99,13 @@ class RCONInstance extends Thread{
}
/**
* @param \Socket|resource $client
* @param int $requestID reference parameter
* @param int $packetType reference parameter
* @param string $payload reference parameter
* @phpstan-param PhpSocket $client
*
* @return bool
*/
private function readPacket($client, ?int &$requestID, ?int &$packetType, ?string &$payload){
private function readPacket(\Socket $client, ?int &$requestID, ?int &$packetType, ?string &$payload){
$d = @socket_read($client, 4);
socket_getpeername($client, $ip, $port);
@@ -176,8 +159,8 @@ class RCONInstance extends Thread{
$this->registerClassLoader();
/**
* @var \Socket[]|resource[] $clients
* @phpstan-var array<int, PhpSocket> $clients
* @var \Socket[] $clients
* @phpstan-var array<int, \Socket> $clients
*/
$clients = [];
/** @var bool[] $authenticated */
@@ -277,11 +260,7 @@ class RCONInstance extends Thread{
}
}
/**
* @param \Socket|resource $client
* @phpstan-param PhpSocket $client
*/
private function disconnectClient($client) : void{
private function disconnectClient(\Socket $client) : void{
socket_getpeername($client, $ip, $port);
@socket_set_option($client, SOL_SOCKET, SO_LINGER, ["l_onoff" => 1, "l_linger" => 1]);
@socket_shutdown($client, 2);

View File

@@ -197,7 +197,7 @@ class Internet{
* @param callable|null $onSuccess function to be called if there is no error. Accepts a resource argument as the cURL handle.
* @phpstan-param array<int, mixed> $extraOpts
* @phpstan-param list<string> $extraHeaders
* @phpstan-param (callable(PhpCurlHandle) : void)|null $onSuccess
* @phpstan-param (callable(\CurlHandle) : void)|null $onSuccess
*
* @return array a plain array of three [result body : string, headers : string[][], HTTP response code : int]. Headers are grouped by requests with strtolower(header name) as keys and header value as values
* @phpstan-return array{string, list<array<string, string>>, int}

View File

@@ -201,9 +201,6 @@ abstract class Timezone{
}
$parsed = date_parse($offset);
if($parsed === false){
return false;
}
$offset = $parsed['hour'] * 3600 + $parsed['minute'] * 60 + $parsed['second'];
//After date_parse is done, put the sign back

View File

@@ -454,7 +454,7 @@ class Utils{
* @param callable|null $onSuccess function to be called if there is no error. Accepts a resource argument as the cURL handle.
* @phpstan-param array<int, mixed> $extraOpts
* @phpstan-param list<string> $extraHeaders
* @phpstan-param (callable(PhpCurlHandle) : void)|null $onSuccess
* @phpstan-param (callable(\CurlHandle) : void)|null $onSuccess
*
* @return array a plain array of three [result body : string, headers : string[][], HTTP response code : int]. Headers are grouped by requests with strtolower(header name) as keys and header value as values
* @phpstan-return array{string, list<array<string, string>>, int}
@@ -642,7 +642,6 @@ class Utils{
preg_match_all('/(*ANYCRLF)^[\t ]*(?:\* )?@([a-zA-Z]+)(?:[\t ]+(.+?))?[\t ]*$/m', $rawDocComment, $matches);
$result = array_combine($matches[1], $matches[2]);
if($result === false) throw new AssumptionFailedError("array_combine() doesn't return false with two equal-sized arrays");
return $result;
}