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
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
15 changed files with 29 additions and 205 deletions

View File

@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
image: [ubuntu-20.04]
php: [7.4.24, 8.0.11]
php: [8.0.11]
steps:
- uses: actions/checkout@v2 #needed for build.sh
@ -36,13 +36,8 @@ jobs:
strategy:
fail-fast: false
matrix:
include:
- php: 8.0.11
config: phpstan.neon.dist
image: ubuntu-20.04
- php: 7.4.24
config: phpstan.php7.neon
image: ubuntu-20.04
image: [ubuntu-20.04]
php: [8.0.11]
steps:
- uses: actions/checkout@v2
@ -82,7 +77,7 @@ jobs:
run: php composer.phar install --prefer-dist --no-interaction
- name: Run PHPStan
run: ./vendor/bin/phpstan analyze --no-progress --memory-limit=2G -c ${{ matrix.config }}
run: ./vendor/bin/phpstan analyze --no-progress --memory-limit=2G
phpunit:
name: PHPUnit tests
@ -92,7 +87,7 @@ jobs:
fail-fast: false
matrix:
image: [ubuntu-20.04]
php: [7.4.24, 8.0.11]
php: [8.0.11]
steps:
- uses: actions/checkout@v2
@ -142,7 +137,7 @@ jobs:
fail-fast: false
matrix:
image: [ubuntu-20.04]
php: [7.4.24, 8.0.11]
php: [8.0.11]
steps:
- uses: actions/checkout@v2
@ -194,7 +189,7 @@ jobs:
fail-fast: false
matrix:
image: [ubuntu-20.04]
php: [7.4.24, 8.0.11]
php: [8.0.11]
steps:
- uses: actions/checkout@v2

View File

@ -22,8 +22,6 @@
declare(strict_types=1);
const VERSIONS = [
"7.3",
"7.4",
"8.0"
];

View File

@ -2,13 +2,13 @@
## Pre-requisites
- A bash shell (git bash is sufficient for Windows)
- [`git`](https://git-scm.com) available in your shell
- PHP 7.4 or newer available in your shell
- PHP 8.0 or newer available in your shell
- [`composer`](https://getcomposer.org) available in your shell
## Custom PHP binaries
Because PocketMine-MP requires several non-standard PHP extensions and configuration, PMMP provides scripts to build custom binaries for running PocketMine-MP, as well as prebuilt binaries.
- [Prebuilt binaries](https://jenkins.pmmp.io/job/PHP-7.4-Aggregate)
- [Prebuilt binaries](https://jenkins.pmmp.io/job/PHP-8.0-Aggregate)
- [Compile scripts](https://github.com/pmmp/php-build-scripts) are provided as a submodule in the path `build/php`
If you use a custom binary, you'll need to replace `composer` usages in this guide with `path/to/your/php path/to/your/composer.phar`.
@ -38,7 +38,7 @@ There is a bug in PHP that might cause an error which looks like this:
```
Fatal error: Uncaught BadMethodCallException: unable to create temporary file in PocketMine-MP/build/server-phar.php:119
```
You can work around it by setting `ulimit -n` to some bigger number, e.g. `8192`, or by updating your PHP version to at least 7.4.16 or 8.0.3.
You can work around it by setting `ulimit -n` to some bigger number, e.g. `8192`, or by updating your PHP version to at least 8.0.3.
## Running PocketMine-MP from source code
Run `src/pocketmine/PocketMine.php` using your preferred PHP binary.

View File

@ -5,7 +5,7 @@
"homepage": "https://pmmp.io",
"license": "LGPL-3.0",
"require": {
"php": "^7.4 || ^8.0",
"php": "^8.0",
"php-64bit": "*",
"ext-ctype": "*",
"ext-curl": "*",
@ -60,7 +60,7 @@
},
"config": {
"platform": {
"php": "7.4.0"
"php": "8.0.0"
},
"sort-packages": true
},

6
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "f3f0ef9944d96c5b71b7e32aac5118cd",
"content-hash": "cfba71d2ad0dd961ed00520b5d52e4d7",
"packages": [
{
"name": "adhocore/json-comment",
@ -2755,7 +2755,7 @@
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
"php": "^7.4 || ^8.0",
"php": "^8.0",
"php-64bit": "*",
"ext-ctype": "*",
"ext-curl": "*",
@ -2778,7 +2778,7 @@
},
"platform-dev": [],
"platform-overrides": {
"php": "7.4.0"
"php": "8.0.0"
},
"plugin-api-version": "2.1.0"
}

View File

@ -5,7 +5,6 @@ includes:
- tests/phpstan/configs/l7-baseline.neon
- tests/phpstan/configs/l8-baseline.neon
- tests/phpstan/configs/php-bugs.neon
- tests/phpstan/configs/php74-compat.neon
- tests/phpstan/configs/phpstan-bugs.neon
- tests/phpstan/configs/phpunit-wiring-tests.neon
- tests/phpstan/configs/pthreads-bugs.neon
@ -51,5 +50,3 @@ parameters:
#we'll just fill it with 10 - it's very unlikely to encounter a callable with 10 parameters anyway.
anyCallable: 'callable(never, never, never, never, never, never, never, never, never, never) : mixed'
anyClosure: '\Closure(never, never, never, never, never, never, never, never, never, never) : mixed'
PhpSocket: '\Socket'
PhpCurlHandle: '\CurlHandle'

View File

@ -1,9 +0,0 @@
includes:
- phpstan.neon.dist
- tests/phpstan/configs/php7.neon
parameters:
phpVersion: 70400
typeAliases:
PhpSocket: resource
PhpCurlHandle: resource

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

View File

@ -1,112 +0,0 @@
parameters:
ignoreErrors:
-
message: "#^Parameter \\#1 \\$fp of function fclose expects resource, resource\\|false given\\.$#"
count: 1
path: ../../../src/pocketmine/MemoryManager.php
-
message: "#^Parameter \\#1 \\$fp of function fwrite expects resource, resource\\|false given\\.$#"
count: 1
path: ../../../src/pocketmine/MemoryManager.php
-
message: "#^Parameter \\#1 \\$str of function base64_decode expects string, mixed given\\.$#"
count: 6
path: ../../../src/pocketmine/Player.php
-
message: "#^Parameter \\#1 \\$input of function array_filter expects array, array\\<int, string\\>\\|false given\\.$#"
count: 1
path: ../../../src/pocketmine/Server.php
-
message: "#^Parameter \\#1 \\$str of function strtolower expects string, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/Server.php
-
message: "#^Parameter \\#1 \\$number of function round expects float, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/command/defaults/StatusCommand.php
-
message: "#^Parameter \\#1 \\$fp of function fclose expects resource, resource\\|false given\\.$#"
count: 2
path: ../../../src/pocketmine/command/defaults/TimingsCommand.php
-
message: "#^Parameter \\#1 \\$fp of function fseek expects resource, resource\\|false given\\.$#"
count: 1
path: ../../../src/pocketmine/command/defaults/TimingsCommand.php
-
message: "#^Parameter \\#1 \\$source of function stream_get_contents expects resource, resource\\|false given\\.$#"
count: 1
path: ../../../src/pocketmine/command/defaults/TimingsCommand.php
-
message: "#^Parameter \\#1 \\$argument of class ReflectionClass constructor expects class\\-string\\<T of object\\>\\|T of object, string given\\.$#"
count: 1
path: ../../../src/pocketmine/event/HandlerList.php
-
message: "#^Parameter \\#2 \\$input1 of function array_map expects array, array\\|false given\\.$#"
count: 1
path: ../../../src/pocketmine/lang/BaseLang.php
-
message: "#^Parameter \\#2 \\$str of function explode expects string, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/level/format/io/leveldb/LevelDB.php
-
message: "#^Parameter \\#1 \\$input of function array_filter expects array, array\\<int, string\\>\\|false given\\.$#"
count: 1
path: ../../../src/pocketmine/level/format/io/region/McRegion.php
-
message: "#^Parameter \\#1 \\$str of function str_split expects string, string\\|false given\\.$#"
count: 1
path: ../../../src/pocketmine/network/mcpe/VerifyLoginTask.php
-
message: "#^Parameter \\#1 \\$str of function mb_strtoupper expects string, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/plugin/PluginDescription.php
-
message: "#^Parameter \\#1 \\$variable_representation of function unserialize expects string, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/scheduler/AsyncTask.php
-
message: "#^Parameter \\#1 \\$str of function strtolower expects string, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/updater/AutoUpdater.php
-
message: "#^Parameter \\#2 \\$timestamp of function date expects int, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/updater/AutoUpdater.php
-
message: "#^Parameter \\#2 \\$start of function substr expects int, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/utils/Internet.php
-
message: "#^Parameter \\#3 \\$length of function substr expects int, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/utils/Internet.php
-
message: "#^Parameter \\#2 \\$input1 of function array_map expects array, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/utils/Utils.php
-
message: "#^Method ReflectionMethod\\:\\:getClosure\\(\\) invoked with 0 parameters, 1 required\\.$#"
count: 1
path: ../../phpunit/network/mcpe/StupidJsonDecodeTest.php

View File

@ -1,11 +0,0 @@
parameters:
ignoreErrors:
-
message: "#^Strict comparison using \\=\\=\\= between array\\<string, mixed\\> and false will always evaluate to false\\.$#"
count: 1
path: ../../../src/pocketmine/utils/Timezone.php
-
message: "#^Strict comparison using \\=\\=\\= between array and false will always evaluate to false\\.$#"
count: 1
path: ../../../src/pocketmine/utils/Utils.php