mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 08:17:34 +00:00
Modernize private property declarations in src/inventory
This commit is contained in:
parent
221c6b8570
commit
a06b9294df
@ -30,31 +30,20 @@ class CallbackInventoryListener implements InventoryListener{
|
||||
|
||||
//TODO: turn the closure signatures into type aliases when PHPStan supports them
|
||||
|
||||
/**
|
||||
* @var \Closure|null
|
||||
* @phpstan-var (\Closure(Inventory, int, Item) : void)|null
|
||||
*/
|
||||
private $onSlotChangeCallback;
|
||||
/**
|
||||
* @var \Closure|null
|
||||
* @phpstan-var (\Closure(Inventory, Item[]) : void)|null
|
||||
*/
|
||||
private $onContentChangeCallback;
|
||||
|
||||
/**
|
||||
* @phpstan-param (\Closure(Inventory, int, Item) : void)|null $onSlotChange
|
||||
* @phpstan-param (\Closure(Inventory, Item[]) : void)|null $onContentChange
|
||||
*/
|
||||
public function __construct(?\Closure $onSlotChange, ?\Closure $onContentChange){
|
||||
public function __construct(
|
||||
private ?\Closure $onSlotChange,
|
||||
private ?\Closure $onContentChange
|
||||
){
|
||||
if($onSlotChange !== null){
|
||||
Utils::validateCallableSignature(function(Inventory $inventory, int $slot, Item $oldItem) : void{}, $onSlotChange);
|
||||
}
|
||||
if($onContentChange !== null){
|
||||
Utils::validateCallableSignature(function(Inventory $inventory, array $oldContents) : void{}, $onContentChange);
|
||||
}
|
||||
|
||||
$this->onSlotChangeCallback = $onSlotChange;
|
||||
$this->onContentChangeCallback = $onContentChange;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -72,8 +61,8 @@ class CallbackInventoryListener implements InventoryListener{
|
||||
}
|
||||
|
||||
public function onSlotChange(Inventory $inventory, int $slot, Item $oldItem) : void{
|
||||
if($this->onSlotChangeCallback !== null){
|
||||
($this->onSlotChangeCallback)($inventory, $slot, $oldItem);
|
||||
if($this->onSlotChange !== null){
|
||||
($this->onSlotChange)($inventory, $slot, $oldItem);
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,8 +70,8 @@ class CallbackInventoryListener implements InventoryListener{
|
||||
* @param Item[] $oldContents
|
||||
*/
|
||||
public function onContentChange(Inventory $inventory, array $oldContents) : void{
|
||||
if($this->onContentChangeCallback !== null){
|
||||
($this->onContentChangeCallback)($inventory, $oldContents);
|
||||
if($this->onContentChange !== null){
|
||||
($this->onContentChange)($inventory, $oldContents);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ final class CreativeInventory{
|
||||
use SingletonTrait;
|
||||
|
||||
/** @var Item[] */
|
||||
private $creative = [];
|
||||
private array $creative = [];
|
||||
|
||||
private function __construct(){
|
||||
$creativeItems = json_decode(file_get_contents(Path::join(\pocketmine\BEDROCK_DATA_PATH, "creativeitems.json")), true);
|
||||
|
@ -26,8 +26,7 @@ namespace pocketmine\inventory;
|
||||
use pocketmine\entity\Human;
|
||||
|
||||
final class PlayerOffHandInventory extends SimpleInventory{
|
||||
/** @var Human */
|
||||
private $holder;
|
||||
private Human $holder;
|
||||
|
||||
public function __construct(Human $player){
|
||||
$this->holder = $player;
|
||||
|
Loading…
x
Reference in New Issue
Block a user