mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-06 20:07:09 +00:00
Merge branch 'next-minor'
This commit is contained in:
commit
d3d7709ead
30
phpstan.neon
30
phpstan.neon
@ -1,7 +1,10 @@
|
|||||||
|
includes:
|
||||||
|
- tests/phpstan/configs/optional-com-dotnet.neon
|
||||||
|
- tests/phpstan/configs/phpstan-bugs.neon
|
||||||
|
- tests/phpstan/configs/pthreads-bugs.neon
|
||||||
|
|
||||||
parameters:
|
parameters:
|
||||||
level: 1
|
level: 2
|
||||||
autoload_files:
|
autoload_files:
|
||||||
- tests/phpstan/bootstrap.php
|
- tests/phpstan/bootstrap.php
|
||||||
- src/PocketMine.php
|
- src/PocketMine.php
|
||||||
@ -24,23 +27,6 @@ parameters:
|
|||||||
count: 1
|
count: 1
|
||||||
path: src/network/mcpe/protocol/StartGamePacket.php
|
path: src/network/mcpe/protocol/StartGamePacket.php
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Instantiated class COM not found\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: src/network/upnp/UPnP.php
|
|
||||||
comment: "only available on Windows"
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Caught class com_exception not found\\.$#"
|
|
||||||
count: 2
|
|
||||||
path: src/network/upnp/UPnP.php
|
|
||||||
comment: "only available on Windows"
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Variable \\$GLOBALS in isset\\(\\) always exists and is not nullable\\.$#"
|
|
||||||
path: src/MemoryManager.php
|
|
||||||
comment: "this isn't defined on threads (thanks pthreads)"
|
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Constant pocketmine\\\\COMPOSER_AUTOLOADER_PATH not found\\.$#"
|
message: "#^Constant pocketmine\\\\COMPOSER_AUTOLOADER_PATH not found\\.$#"
|
||||||
path: src
|
path: src
|
||||||
@ -64,3 +50,9 @@ parameters:
|
|||||||
-
|
-
|
||||||
message: "#^Constant pocketmine\\\\VERSION not found\\.$#"
|
message: "#^Constant pocketmine\\\\VERSION not found\\.$#"
|
||||||
path: src
|
path: src
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Call to an undefined method pocketmine\\\\command\\\\CommandSender\\:\\:teleport\\(\\)\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/command/defaults/TeleportCommand.php
|
||||||
|
comment: "not actually possible, but high cost to fix warning"
|
||||||
|
@ -200,7 +200,7 @@ class Server{
|
|||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
private $tickCounter = 0;
|
private $tickCounter = 0;
|
||||||
/** @var int */
|
/** @var float */
|
||||||
private $nextTick = 0;
|
private $nextTick = 0;
|
||||||
/** @var float[] */
|
/** @var float[] */
|
||||||
private $tickAverage = [20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20];
|
private $tickAverage = [20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20];
|
||||||
@ -938,7 +938,7 @@ class Server{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string[]
|
* @return string[][]
|
||||||
*/
|
*/
|
||||||
public function getCommandAliases() : array{
|
public function getCommandAliases() : array{
|
||||||
$section = $this->getProperty("aliases");
|
$section = $this->getProperty("aliases");
|
||||||
@ -1323,7 +1323,7 @@ class Server{
|
|||||||
return $this->broadcast($message, self::BROADCAST_CHANNEL_USERS);
|
return $this->broadcast($message, self::BROADCAST_CHANNEL_USERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var Player[] $recipients */
|
/** @var CommandSender[] $recipients */
|
||||||
foreach($recipients as $recipient){
|
foreach($recipients as $recipient){
|
||||||
$recipient->sendMessage($message);
|
$recipient->sendMessage($message);
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ abstract class Command{
|
|||||||
*/
|
*/
|
||||||
private $activeAliases = [];
|
private $activeAliases = [];
|
||||||
|
|
||||||
/** @var CommandMap */
|
/** @var CommandMap|null */
|
||||||
private $commandMap = null;
|
private $commandMap = null;
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
|
@ -59,7 +59,6 @@ class GamemodeCommand extends VanillaCommand{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$target = $sender;
|
|
||||||
if(isset($args[1])){
|
if(isset($args[1])){
|
||||||
$target = $sender->getServer()->getPlayer($args[1]);
|
$target = $sender->getServer()->getPlayer($args[1]);
|
||||||
if($target === null){
|
if($target === null){
|
||||||
@ -67,7 +66,9 @@ class GamemodeCommand extends VanillaCommand{
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}elseif(!($sender instanceof Player)){
|
}elseif($sender instanceof Player){
|
||||||
|
$target = $sender;
|
||||||
|
}else{
|
||||||
throw new InvalidCommandSyntaxException();
|
throw new InvalidCommandSyntaxException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ class CraftingManager{
|
|||||||
/** @var FurnaceRecipe[] */
|
/** @var FurnaceRecipe[] */
|
||||||
protected $furnaceRecipes = [];
|
protected $furnaceRecipes = [];
|
||||||
|
|
||||||
/** @var CompressBatchPromise */
|
/** @var CompressBatchPromise|null */
|
||||||
private $craftingDataCache;
|
private $craftingDataCache;
|
||||||
|
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
|
@ -99,8 +99,8 @@ abstract class Entity{
|
|||||||
/** @var EntityDamageEvent|null */
|
/** @var EntityDamageEvent|null */
|
||||||
protected $lastDamageCause = null;
|
protected $lastDamageCause = null;
|
||||||
|
|
||||||
/** @var Block[] */
|
/** @var Block[]|null */
|
||||||
protected $blocksAround = [];
|
protected $blocksAround;
|
||||||
|
|
||||||
/** @var Location */
|
/** @var Location */
|
||||||
protected $location;
|
protected $location;
|
||||||
|
@ -41,7 +41,7 @@ class Squid extends WaterAnimal{
|
|||||||
public $width = 0.95;
|
public $width = 0.95;
|
||||||
public $height = 0.95;
|
public $height = 0.95;
|
||||||
|
|
||||||
/** @var Vector3 */
|
/** @var Vector3|null */
|
||||||
public $swimDirection = null;
|
public $swimDirection = null;
|
||||||
public $swimSpeed = 0.1;
|
public $swimSpeed = 0.1;
|
||||||
|
|
||||||
|
@ -23,11 +23,13 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\event\player;
|
namespace pocketmine\event\player;
|
||||||
|
|
||||||
|
use pocketmine\command\CommandSender;
|
||||||
use pocketmine\event\Cancellable;
|
use pocketmine\event\Cancellable;
|
||||||
use pocketmine\event\CancellableTrait;
|
use pocketmine\event\CancellableTrait;
|
||||||
use pocketmine\permission\PermissionManager;
|
use pocketmine\permission\PermissionManager;
|
||||||
use pocketmine\player\Player;
|
use pocketmine\player\Player;
|
||||||
use pocketmine\Server;
|
use pocketmine\Server;
|
||||||
|
use function spl_object_id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a player chats something
|
* Called when a player chats something
|
||||||
@ -42,7 +44,7 @@ class PlayerChatEvent extends PlayerEvent implements Cancellable{
|
|||||||
protected $format;
|
protected $format;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Player[]
|
* @var CommandSender[]
|
||||||
*/
|
*/
|
||||||
protected $recipients = [];
|
protected $recipients = [];
|
||||||
|
|
||||||
@ -50,7 +52,7 @@ class PlayerChatEvent extends PlayerEvent implements Cancellable{
|
|||||||
* @param Player $player
|
* @param Player $player
|
||||||
* @param string $message
|
* @param string $message
|
||||||
* @param string $format
|
* @param string $format
|
||||||
* @param Player[] $recipients
|
* @param CommandSender[] $recipients
|
||||||
*/
|
*/
|
||||||
public function __construct(Player $player, string $message, string $format = "chat.type.text", ?array $recipients = null){
|
public function __construct(Player $player, string $message, string $format = "chat.type.text", ?array $recipients = null){
|
||||||
$this->player = $player;
|
$this->player = $player;
|
||||||
@ -59,7 +61,11 @@ class PlayerChatEvent extends PlayerEvent implements Cancellable{
|
|||||||
$this->format = $format;
|
$this->format = $format;
|
||||||
|
|
||||||
if($recipients === null){
|
if($recipients === null){
|
||||||
$this->recipients = PermissionManager::getInstance()->getPermissionSubscriptions(Server::BROADCAST_CHANNEL_USERS);
|
foreach(PermissionManager::getInstance()->getPermissionSubscriptions(Server::BROADCAST_CHANNEL_USERS) as $permissible){
|
||||||
|
if($permissible instanceof CommandSender){
|
||||||
|
$this->recipients[spl_object_id($permissible)] = $permissible;
|
||||||
|
}
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
$this->recipients = $recipients;
|
$this->recipients = $recipients;
|
||||||
}
|
}
|
||||||
@ -103,14 +109,14 @@ class PlayerChatEvent extends PlayerEvent implements Cancellable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Player[]
|
* @return CommandSender[]
|
||||||
*/
|
*/
|
||||||
public function getRecipients() : array{
|
public function getRecipients() : array{
|
||||||
return $this->recipients;
|
return $this->recipients;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Player[] $recipients
|
* @param CommandSender[] $recipients
|
||||||
*/
|
*/
|
||||||
public function setRecipients(array $recipients) : void{
|
public function setRecipients(array $recipients) : void{
|
||||||
$this->recipients = $recipients;
|
$this->recipients = $recipients;
|
||||||
|
@ -36,9 +36,9 @@ class PlayerCreationEvent extends Event{
|
|||||||
/** @var NetworkSession */
|
/** @var NetworkSession */
|
||||||
private $session;
|
private $session;
|
||||||
|
|
||||||
/** @var Player::class */
|
/** @var string */
|
||||||
private $baseClass = Player::class;
|
private $baseClass = Player::class;
|
||||||
/** @var Player::class */
|
/** @var string */
|
||||||
private $playerClass = Player::class;
|
private $playerClass = Player::class;
|
||||||
|
|
||||||
|
|
||||||
@ -71,14 +71,14 @@ class PlayerCreationEvent extends Event{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Player::class
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getBaseClass(){
|
public function getBaseClass(){
|
||||||
return $this->baseClass;
|
return $this->baseClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Player::class $class
|
* @param string $class
|
||||||
*/
|
*/
|
||||||
public function setBaseClass($class) : void{
|
public function setBaseClass($class) : void{
|
||||||
if(!is_a($class, $this->baseClass, true)){
|
if(!is_a($class, $this->baseClass, true)){
|
||||||
@ -89,14 +89,14 @@ class PlayerCreationEvent extends Event{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Player::class
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getPlayerClass(){
|
public function getPlayerClass(){
|
||||||
return $this->playerClass;
|
return $this->playerClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Player::class $class
|
* @param string $class
|
||||||
*/
|
*/
|
||||||
public function setPlayerClass($class) : void{
|
public function setPlayerClass($class) : void{
|
||||||
if(!is_a($class, $this->baseClass, true)){
|
if(!is_a($class, $this->baseClass, true)){
|
||||||
|
@ -37,7 +37,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[] */
|
||||||
protected $slots = [];
|
protected $slots;
|
||||||
/** @var Player[] */
|
/** @var Player[] */
|
||||||
protected $viewers = [];
|
protected $viewers = [];
|
||||||
/** @var InventoryChangeListener[] */
|
/** @var InventoryChangeListener[] */
|
||||||
|
@ -234,6 +234,7 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{
|
|||||||
$overloads = [];
|
$overloads = [];
|
||||||
|
|
||||||
for($overloadIndex = 0, $overloadCount = $this->getUnsignedVarInt(); $overloadIndex < $overloadCount; ++$overloadIndex){
|
for($overloadIndex = 0, $overloadCount = $this->getUnsignedVarInt(); $overloadIndex < $overloadCount; ++$overloadIndex){
|
||||||
|
$overloads[$overloadIndex] = [];
|
||||||
for($paramIndex = 0, $paramCount = $this->getUnsignedVarInt(); $paramIndex < $paramCount; ++$paramIndex){
|
for($paramIndex = 0, $paramCount = $this->getUnsignedVarInt(); $paramIndex < $paramCount; ++$paramIndex){
|
||||||
$parameter = new CommandParameter();
|
$parameter = new CommandParameter();
|
||||||
$parameter->paramName = $this->getString();
|
$parameter->paramName = $this->getString();
|
||||||
|
@ -139,7 +139,7 @@ class CraftingDataPacket extends DataPacket implements ClientboundPacket{
|
|||||||
}
|
}
|
||||||
$this->decodedEntries[] = $entry;
|
$this->decodedEntries[] = $entry;
|
||||||
}
|
}
|
||||||
$this->getBool(); //cleanRecipes
|
$this->cleanRecipes = $this->getBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function writeEntry($entry, NetworkBinaryStream $stream, int $pos) : int{
|
private static function writeEntry($entry, NetworkBinaryStream $stream, int $pos) : int{
|
||||||
|
@ -236,7 +236,7 @@ class World implements ChunkManager{
|
|||||||
/** @var WorldTimings */
|
/** @var WorldTimings */
|
||||||
public $timings;
|
public $timings;
|
||||||
|
|
||||||
/** @var int */
|
/** @var float */
|
||||||
public $tickRateTime = 0;
|
public $tickRateTime = 0;
|
||||||
|
|
||||||
/** @var bool */
|
/** @var bool */
|
||||||
|
@ -546,7 +546,7 @@ class Chunk{
|
|||||||
* @param World $world
|
* @param World $world
|
||||||
*/
|
*/
|
||||||
public function initChunk(World $world) : void{
|
public function initChunk(World $world) : void{
|
||||||
if($this->NBTentities !== null){
|
if(!empty($this->NBTentities)){
|
||||||
$this->dirtyFlags |= self::DIRTY_FLAG_ENTITIES;
|
$this->dirtyFlags |= self::DIRTY_FLAG_ENTITIES;
|
||||||
$world->timings->syncChunkLoadEntitiesTimer->startTiming();
|
$world->timings->syncChunkLoadEntitiesTimer->startTiming();
|
||||||
foreach($this->NBTentities as $nbt){
|
foreach($this->NBTentities as $nbt){
|
||||||
@ -564,10 +564,10 @@ class Chunk{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->NBTentities = null;
|
$this->NBTentities = [];
|
||||||
$world->timings->syncChunkLoadEntitiesTimer->stopTiming();
|
$world->timings->syncChunkLoadEntitiesTimer->stopTiming();
|
||||||
}
|
}
|
||||||
if($this->NBTtiles !== null){
|
if(!empty($this->NBTtiles)){
|
||||||
$this->dirtyFlags |= self::DIRTY_FLAG_TILES;
|
$this->dirtyFlags |= self::DIRTY_FLAG_TILES;
|
||||||
$world->timings->syncChunkLoadTileEntitiesTimer->startTiming();
|
$world->timings->syncChunkLoadTileEntitiesTimer->startTiming();
|
||||||
foreach($this->NBTtiles as $nbt){
|
foreach($this->NBTtiles as $nbt){
|
||||||
@ -581,7 +581,7 @@ class Chunk{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->NBTtiles = null;
|
$this->NBTtiles = [];
|
||||||
$world->timings->syncChunkLoadTileEntitiesTimer->stopTiming();
|
$world->timings->syncChunkLoadTileEntitiesTimer->stopTiming();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
12
tests/phpstan/configs/optional-com-dotnet.neon
Normal file
12
tests/phpstan/configs/optional-com-dotnet.neon
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
parameters:
|
||||||
|
ignoreErrors:
|
||||||
|
-
|
||||||
|
message: "#^Instantiated class COM not found\\.$#"
|
||||||
|
count: 2
|
||||||
|
path: src/pocketmine/network/upnp/UPnP.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Access to property \\$StaticPortMappingCollection on an unknown class COM\\.$#"
|
||||||
|
count: 4
|
||||||
|
path: src/pocketmine/network/upnp/UPnP.php
|
||||||
|
|
10
tests/phpstan/configs/phpstan-bugs.neon
Normal file
10
tests/phpstan/configs/phpstan-bugs.neon
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
parameters:
|
||||||
|
ignoreErrors:
|
||||||
|
-
|
||||||
|
message: "#^PHPDoc tag @param has invalid value \\(.+\\)\\: Unexpected token \"&\", expected TOKEN_VARIABLE at offset \\d+$#"
|
||||||
|
path: src/pocketmine
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Default value of the parameter \\#\\d+ \\$[A-Za-z\\d_]+ \\(\\-?\\d+\\) of method .+\\(\\) is incompatible with type float\\.$#"
|
||||||
|
path: src/pocketmine
|
||||||
|
|
6
tests/phpstan/configs/pthreads-bugs.neon
Normal file
6
tests/phpstan/configs/pthreads-bugs.neon
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
parameters:
|
||||||
|
ignoreErrors:
|
||||||
|
-
|
||||||
|
message: "#^Variable \\$GLOBALS in isset\\(\\) always exists and is not nullable\\.$#"
|
||||||
|
path: src/MemoryManager.php
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user