mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 00:07:30 +00:00
phpstan 0.12.63
This commit is contained in:
parent
6afbd1f55c
commit
0604dfc9e5
@ -37,7 +37,7 @@
|
||||
"composer-runtime-api": "^2.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpstan/phpstan": "0.12.59",
|
||||
"phpstan/phpstan": "0.12.63",
|
||||
"phpstan/phpstan-phpunit": "^0.12.6",
|
||||
"phpstan/phpstan-strict-rules": "^0.12.2",
|
||||
"phpunit/phpunit": "^9.2"
|
||||
|
14
composer.lock
generated
14
composer.lock
generated
@ -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": "898e2d529d8aec83866a2bbaa867e23f",
|
||||
"content-hash": "9222894d84889c6d444825b7f175a892",
|
||||
"packages": [
|
||||
{
|
||||
"name": "adhocore/json-comment",
|
||||
@ -1000,16 +1000,16 @@
|
||||
},
|
||||
{
|
||||
"name": "phpstan/phpstan",
|
||||
"version": "0.12.59",
|
||||
"version": "0.12.63",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpstan/phpstan.git",
|
||||
"reference": "cf4107257c8ca2ad967efdd6a00f12b21acbb779"
|
||||
"reference": "c97ec4754bd53099a06c24847bd2870b99966b6a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/cf4107257c8ca2ad967efdd6a00f12b21acbb779",
|
||||
"reference": "cf4107257c8ca2ad967efdd6a00f12b21acbb779",
|
||||
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/c97ec4754bd53099a06c24847bd2870b99966b6a",
|
||||
"reference": "c97ec4754bd53099a06c24847bd2870b99966b6a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1040,7 +1040,7 @@
|
||||
"description": "PHPStan - PHP Static Analysis Tool",
|
||||
"support": {
|
||||
"issues": "https://github.com/phpstan/phpstan/issues",
|
||||
"source": "https://github.com/phpstan/phpstan/tree/0.12.59"
|
||||
"source": "https://github.com/phpstan/phpstan/tree/0.12.63"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@ -1056,7 +1056,7 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2020-12-07T14:46:03+00:00"
|
||||
"time": "2020-12-15T16:37:16+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpstan/phpstan-phpunit",
|
||||
|
@ -28,6 +28,7 @@ use pocketmine\network\mcpe\protocol\ProtocolInfo;
|
||||
use pocketmine\plugin\PluginBase;
|
||||
use pocketmine\plugin\PluginLoadOrder;
|
||||
use pocketmine\plugin\PluginManager;
|
||||
use pocketmine\utils\AssumptionFailedError;
|
||||
use pocketmine\utils\Utils;
|
||||
use pocketmine\utils\VersionString;
|
||||
use function base64_encode;
|
||||
@ -166,7 +167,8 @@ class CrashDump{
|
||||
if($json === false){
|
||||
throw new \RuntimeException("Failed to encode crashdump JSON: " . json_last_error_msg());
|
||||
}
|
||||
$this->encodedData = zlib_encode($json, ZLIB_ENCODING_DEFLATE, 9);
|
||||
$zlibEncoded = zlib_encode($json, ZLIB_ENCODING_DEFLATE, 9);
|
||||
if($zlibEncoded === false) throw new AssumptionFailedError("ZLIB compression failed");
|
||||
foreach(str_split(base64_encode($this->encodedData), 76) as $line){
|
||||
$this->addLine($line);
|
||||
}
|
||||
|
@ -279,7 +279,7 @@ namespace pocketmine {
|
||||
|
||||
if(ThreadManager::getInstance()->stopAll() > 0){
|
||||
$logger->debug("Some threads could not be stopped, performing a force-kill");
|
||||
Process::kill(getmypid());
|
||||
Process::kill(Process::pid());
|
||||
}
|
||||
}while(false);
|
||||
|
||||
|
@ -126,7 +126,6 @@ use function file_put_contents;
|
||||
use function filemtime;
|
||||
use function function_exists;
|
||||
use function get_class;
|
||||
use function getmypid;
|
||||
use function getopt;
|
||||
use function gettype;
|
||||
use function implode;
|
||||
@ -1939,7 +1938,7 @@ class Server{
|
||||
}catch(\Throwable $e){
|
||||
$this->logger->logException($e);
|
||||
$this->logger->emergency("Crashed while crashing, killing process");
|
||||
@Process::kill(getmypid());
|
||||
@Process::kill(Process::pid());
|
||||
}
|
||||
|
||||
}
|
||||
@ -2132,7 +2131,7 @@ class Server{
|
||||
echo "--- Waiting $spacing seconds to throttle automatic restart (you can kill the process safely now) ---" . PHP_EOL;
|
||||
sleep($spacing);
|
||||
}
|
||||
@Process::kill(getmypid());
|
||||
@Process::kill(Process::pid());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -921,7 +921,9 @@ class Chunk{
|
||||
|
||||
$biomeIds = $stream->get(256);
|
||||
if($lightPopulated){
|
||||
$heightMap = array_values(unpack("v*", $stream->get(512)));
|
||||
/** @var int[] $unpackedHeightMap */
|
||||
$unpackedHeightMap = unpack("v*", $stream->get(512)); //unpack() will never fail here
|
||||
$heightMap = array_values($unpackedHeightMap);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -368,7 +368,9 @@ class LevelDB extends BaseLevelProvider{
|
||||
if(($maps2d = $this->db->get($index . self::TAG_DATA_2D)) !== false){
|
||||
$binaryStream->setBuffer($maps2d, 0);
|
||||
|
||||
$heightMap = array_values(unpack("v*", $binaryStream->get(512)));
|
||||
/** @var int[] $unpackedHeightMap */
|
||||
$unpackedHeightMap = unpack("v*", $binaryStream->get(512)); //unpack() will never fail here
|
||||
$heightMap = array_values($unpackedHeightMap);
|
||||
$biomeIds = $binaryStream->get(256);
|
||||
}
|
||||
break;
|
||||
@ -411,8 +413,13 @@ class LevelDB extends BaseLevelProvider{
|
||||
$subChunks[$yy] = new SubChunk($ids, $data, $skyLight, $blockLight);
|
||||
}
|
||||
|
||||
$heightMap = array_values(unpack("C*", $binaryStream->get(256)));
|
||||
$biomeIds = ChunkUtils::convertBiomeColors(array_values(unpack("N*", $binaryStream->get(1024))));
|
||||
/** @var int[] $unpackedHeightMap */
|
||||
$unpackedHeightMap = unpack("C*", $binaryStream->get(256)); //unpack() will never fail here, but static analysers don't know that
|
||||
$heightMap = array_values($unpackedHeightMap);
|
||||
|
||||
/** @var int[] $unpackedBiomeIds */
|
||||
$unpackedBiomeIds = unpack("N*", $binaryStream->get(1024)); //nor here
|
||||
$biomeIds = ChunkUtils::convertBiomeColors(array_values($unpackedBiomeIds));
|
||||
break;
|
||||
default:
|
||||
//TODO: set chunks read-only so the version on disk doesn't get overwritten
|
||||
|
@ -182,7 +182,9 @@ class McRegion extends BaseLevelProvider{
|
||||
|
||||
$heightMap = [];
|
||||
if($chunk->hasTag("HeightMap", ByteArrayTag::class)){
|
||||
$heightMap = array_values(unpack("C*", $chunk->getByteArray("HeightMap")));
|
||||
/** @var int[] $unpackedHeightMap */
|
||||
$unpackedHeightMap = unpack("C*", $chunk->getByteArray("HeightMap")); //unpack() will never fail here
|
||||
$heightMap = array_values($unpackedHeightMap);
|
||||
}elseif($chunk->hasTag("HeightMap", IntArrayTag::class)){
|
||||
$heightMap = $chunk->getIntArray("HeightMap"); #blameshoghicp
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
use pocketmine\network\mcpe\NetworkBinaryStream;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\utils\AssumptionFailedError;
|
||||
use function assert;
|
||||
use function get_class;
|
||||
use function strlen;
|
||||
@ -72,7 +73,9 @@ class BatchPacket extends DataPacket{
|
||||
}
|
||||
|
||||
protected function encodePayload(){
|
||||
$this->put(zlib_encode($this->payload, ZLIB_ENCODING_RAW, $this->compressionLevel));
|
||||
$encoded = zlib_encode($this->payload, ZLIB_ENCODING_RAW, $this->compressionLevel);
|
||||
if($encoded === false) throw new AssumptionFailedError("ZLIB compression failed");
|
||||
$this->put($encoded);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -30,6 +30,8 @@ use function fclose;
|
||||
use function file;
|
||||
use function file_get_contents;
|
||||
use function function_exists;
|
||||
use function getmypid;
|
||||
use function getmyuid;
|
||||
use function hexdec;
|
||||
use function memory_get_usage;
|
||||
use function posix_kill;
|
||||
@ -175,4 +177,20 @@ final class Process{
|
||||
|
||||
return proc_close($process);
|
||||
}
|
||||
|
||||
public static function pid() : int{
|
||||
$result = getmypid();
|
||||
if($result === false){
|
||||
throw new \LogicException("getmypid() doesn't work on this platform");
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function uid() : int{
|
||||
$result = getmyuid();
|
||||
if($result === false){
|
||||
throw new \LogicException("getmyuid() doesn't work on this platform");
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ declare(strict_types=1);
|
||||
namespace pocketmine\utils;
|
||||
|
||||
use pocketmine\Thread;
|
||||
use function getmypid;
|
||||
use function time;
|
||||
|
||||
class ServerKiller extends Thread{
|
||||
@ -55,7 +54,7 @@ class ServerKiller extends Thread{
|
||||
});
|
||||
if(time() - $start >= $this->time){
|
||||
echo "\nTook too long to stop, server was killed forcefully!\n";
|
||||
@Process::kill(getmypid());
|
||||
@Process::kill(Process::pid());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ class UUID{
|
||||
}
|
||||
|
||||
public static function fromRandom() : UUID{
|
||||
return self::fromData(Binary::writeInt(time()), Binary::writeShort(getmypid()), Binary::writeShort(getmyuid()), Binary::writeInt(mt_rand(-0x7fffffff, 0x7fffffff)), Binary::writeInt(mt_rand(-0x7fffffff, 0x7fffffff)));
|
||||
return self::fromData(Binary::writeInt(time()), Binary::writeShort(($pid = getmypid()) !== false ? $pid : 0), Binary::writeShort(($uid = getmyuid()) !== false ? $uid : 0), Binary::writeInt(mt_rand(-0x7fffffff, 0x7fffffff)), Binary::writeInt(mt_rand(-0x7fffffff, 0x7fffffff)));
|
||||
}
|
||||
|
||||
public function toBinary() : string{
|
||||
|
@ -192,7 +192,14 @@ class Utils{
|
||||
}
|
||||
|
||||
$machine = php_uname("a");
|
||||
$machine .= ($cpuinfo = @file("/proc/cpuinfo")) !== false ? implode(preg_grep("/(model name|Processor|Serial)/", $cpuinfo)) : "";
|
||||
$cpuinfo = @file("/proc/cpuinfo");
|
||||
if($cpuinfo !== false){
|
||||
$cpuinfoLines = preg_grep("/(model name|Processor|Serial)/", $cpuinfo);
|
||||
if($cpuinfoLines === false){
|
||||
throw new AssumptionFailedError("Pattern is valid, so this shouldn't fail ...");
|
||||
}
|
||||
$machine .= implode("", $cpuinfoLines);
|
||||
}
|
||||
$machine .= sys_get_temp_dir();
|
||||
$machine .= $extra;
|
||||
$os = Utils::getOS();
|
||||
|
Loading…
x
Reference in New Issue
Block a user