Merge branch 'next-minor'

This commit is contained in:
Dylan K. Taylor 2019-12-12 13:52:14 +00:00
commit a9c09e4517
12 changed files with 81 additions and 16 deletions

View File

@ -1,11 +1,13 @@
includes: includes:
- tests/phpstan/configs/debug-const-checks.neon
- tests/phpstan/configs/gc-hacks.neon - tests/phpstan/configs/gc-hacks.neon
- tests/phpstan/configs/optional-com-dotnet.neon - tests/phpstan/configs/optional-com-dotnet.neon
- tests/phpstan/configs/phpstan-bugs.neon - tests/phpstan/configs/phpstan-bugs.neon
- tests/phpstan/configs/pthreads-bugs.neon - tests/phpstan/configs/pthreads-bugs.neon
- tests/phpstan/configs/runtime-type-checks.neon
parameters: parameters:
level: 3 level: 4
autoload_files: autoload_files:
- tests/phpstan/bootstrap.php - tests/phpstan/bootstrap.php
- src/PocketMine.php - src/PocketMine.php

View File

@ -36,7 +36,7 @@ abstract class BaseInventory implements Inventory{
/** @var int */ /** @var int */
protected $maxStackSize = Inventory::MAX_STACK; protected $maxStackSize = Inventory::MAX_STACK;
/** @var \SplFixedArray|Item[] */ /** @var \SplFixedArray|(Item|null)[] */
protected $slots; protected $slots;
/** @var Player[] */ /** @var Player[] */
protected $viewers = []; protected $viewers = [];

View File

@ -148,10 +148,10 @@ class BanEntry{
/** /**
* @param string $date * @param string $date
* *
* @return \DateTime|null * @return \DateTime
* @throws \RuntimeException * @throws \RuntimeException
*/ */
private static function parseDate(string $date) : ?\DateTime{ private static function parseDate(string $date) : \DateTime{
$datetime = \DateTime::createFromFormat(self::$format, $date); $datetime = \DateTime::createFromFormat(self::$format, $date);
if(!($datetime instanceof \DateTime)){ if(!($datetime instanceof \DateTime)){
throw new \RuntimeException("Corrupted date/time: " . implode(", ", \DateTime::getLastErrors()["errors"])); throw new \RuntimeException("Corrupted date/time: " . implode(", ", \DateTime::getLastErrors()["errors"]));

View File

@ -32,6 +32,8 @@ use pocketmine\scheduler\TaskHandler;
use function dechex; use function dechex;
abstract class Timings{ abstract class Timings{
/** @var bool */
private static $initialized = false;
/** @var TimingsHandler */ /** @var TimingsHandler */
public static $fullTickTimer; public static $fullTickTimer;
@ -113,9 +115,10 @@ abstract class Timings{
public static $pluginTaskTimingMap = []; public static $pluginTaskTimingMap = [];
public static function init() : void{ public static function init() : void{
if(self::$serverTickTimer instanceof TimingsHandler){ if(self::$initialized){
return; return;
} }
self::$initialized = true;
self::$fullTickTimer = new TimingsHandler("Full Server Tick"); self::$fullTickTimer = new TimingsHandler("Full Server Tick");
self::$serverTickTimer = new TimingsHandler("** Full Server Tick", self::$fullTickTimer); self::$serverTickTimer = new TimingsHandler("** Full Server Tick", self::$fullTickTimer);

View File

@ -168,7 +168,7 @@ class TimingsHandler{
public function stopTiming() : void{ public function stopTiming() : void{
if(self::$enabled){ if(self::$enabled){
if(--$this->timingDepth !== 0 or $this->start === 0){ if(--$this->timingDepth !== 0 or $this->start == 0){
return; return;
} }

View File

@ -2042,7 +2042,7 @@ class World implements ChunkManager{
* @param int $x * @param int $x
* @param int $z * @param int $z
* *
* @return Chunk[] * @return (Chunk|null)[]
*/ */
public function getAdjacentChunks(int $x, int $z) : array{ public function getAdjacentChunks(int $x, int $z) : array{
$result = []; $result = [];

View File

@ -33,7 +33,7 @@ interface WritableWorldProvider extends WorldProvider{
* @param string $name * @param string $name
* @param int $seed * @param int $seed
* @param string $generator * @param string $generator
* @param array[] $options * @param array $options
*/ */
public static function generate(string $path, string $name, int $seed, string $generator, array $options = []) : void; public static function generate(string $path, string $name, int $seed, string $generator, array $options = []) : void;

View File

@ -59,11 +59,9 @@ class PopulationTask extends AsyncTask{
} }
public function onRun() : void{ public function onRun() : void{
/** @var SimpleChunkManager $manager */
$manager = $this->worker->getFromThreadStore("generation.world{$this->worldId}.manager"); $manager = $this->worker->getFromThreadStore("generation.world{$this->worldId}.manager");
/** @var Generator $generator */
$generator = $this->worker->getFromThreadStore("generation.world{$this->worldId}.generator"); $generator = $this->worker->getFromThreadStore("generation.world{$this->worldId}.generator");
if($manager === null or $generator === null){ if(!($manager instanceof SimpleChunkManager) or !($generator instanceof Generator)){
$this->state = false; $this->state = false;
return; return;
} }

View File

@ -0,0 +1,21 @@
parameters:
ignoreErrors:
-
message: "#^If condition is always true\\.$#"
count: 2
path: ../../../src/Server.php
-
message: "#^Ternary operator condition is always true\\.$#"
count: 1
path: ../../../src/Server.php
-
message: "#^If condition is always false\\.$#"
count: 1
path: ../../../src/updater/AutoUpdater.php
-
message: "#^Negated boolean expression is always false\\.$#"
count: 1
path: ../../../src/updater/AutoUpdater.php

View File

@ -26,22 +26,50 @@ parameters:
count: 1 count: 1
path: ../../../src/MemoryManager.php path: ../../../src/MemoryManager.php
-
message: "#^Comparison operation \"\\>\\=\" between 0 and 2 is always false\\.$#"
count: 1
path: ../../../src/block/Liquid.php
-
#adjacentSources comparison FP
message: "#^If condition is always false\\.$#"
count: 1
path: ../../../src/block/Liquid.php
- -
message: "#^Cannot access an offset on Ds\\\\Deque&iterable\\<pocketmine\\\\block\\\\utils\\\\BannerPattern\\>\\.$#" message: "#^Cannot access an offset on Ds\\\\Deque&iterable\\<pocketmine\\\\block\\\\utils\\\\BannerPattern\\>\\.$#"
count: 1 count: 1
path: ../../../src/block/tile/Banner.php path: ../../../src/block/tile/Banner.php
-
message: "#^Call to function assert\\(\\) with false and 'unknown hit type' will always evaluate to false\\.$#"
count: 1
path: ../../../src/entity/projectile/Projectile.php
- -
message: "#^Cannot access offset int on Ds\\\\Deque&iterable\\<pocketmine\\\\item\\\\WritableBookPage\\>\\.$#" message: "#^Cannot access offset int on Ds\\\\Deque&iterable\\<pocketmine\\\\item\\\\WritableBookPage\\>\\.$#"
count: 2 count: 2
path: ../../../src/item/WritableBookBase.php path: ../../../src/item/WritableBookBase.php
- -
message: "#^Array \\(array\\) does not accept key int\\.$#" message: "#^Instanceof between int and PharFileInfo will always evaluate to false\\.$#"
count: 1 count: 1
path: ../../../src/plugin/PluginDescription.php path: ../../../src/plugin/PharPluginLoader.php
- -
message: "#^Array \\(array\\) does not accept key int\\.$#" #ReflectionFunction::getClosureThis() should be nullable
message: "#^Else branch is unreachable because ternary operator condition is always true\\.$#"
count: 1 count: 1
path: ../../../src/world/format/SubChunk.php path: ../../../src/utils/Utils.php
-
#ReflectionFunction::getClosureScopeClass() should be nullable
message: "#^Unreachable statement \\- code above always terminates\\.$#"
count: 1
path: ../../../src/utils/Utils.php
-
message: "#^Strict comparison using \\=\\=\\= between int\\<min, 3\\> and 4 will always evaluate to false\\.$#"
count: 1
path: ../../../src/world/World.php

View File

@ -0,0 +1,13 @@
parameters:
ignoreErrors:
-
#::add() / ::remove() thread parameter
message: "#^If condition is always true\\.$#"
count: 2
path: ../../../src/thread/ThreadManager.php
-
#->sendBlocks() blocks parameter
message: "#^Else branch is unreachable because ternary operator condition is always true\\.$#"
count: 1
path: ../../../src/world/World.php

View File

@ -21,7 +21,7 @@ if [ $? -ne 0 ]; then
exit 1 exit 1
fi fi
[ ! -f phpstan.phar ] && echo "Downloading PHPStan..." && curl -sSLO https://github.com/phpstan/phpstan/releases/download/0.12.0/phpstan.phar [ ! -f phpstan.phar ] && echo "Downloading PHPStan..." && curl -sSLO https://github.com/phpstan/phpstan/releases/download/0.12.2/phpstan.phar
"$PHP_BINARY" phpstan.phar analyze --no-progress --memory-limit=2G || exit 1 "$PHP_BINARY" phpstan.phar analyze --no-progress --memory-limit=2G || exit 1
echo "PHPStan scan succeeded" echo "PHPStan scan succeeded"