mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-06 10:01:53 +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
|
//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, int, Item) : void)|null $onSlotChange
|
||||||
* @phpstan-param (\Closure(Inventory, Item[]) : void)|null $onContentChange
|
* @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){
|
if($onSlotChange !== null){
|
||||||
Utils::validateCallableSignature(function(Inventory $inventory, int $slot, Item $oldItem) : void{}, $onSlotChange);
|
Utils::validateCallableSignature(function(Inventory $inventory, int $slot, Item $oldItem) : void{}, $onSlotChange);
|
||||||
}
|
}
|
||||||
if($onContentChange !== null){
|
if($onContentChange !== null){
|
||||||
Utils::validateCallableSignature(function(Inventory $inventory, array $oldContents) : void{}, $onContentChange);
|
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{
|
public function onSlotChange(Inventory $inventory, int $slot, Item $oldItem) : void{
|
||||||
if($this->onSlotChangeCallback !== null){
|
if($this->onSlotChange !== null){
|
||||||
($this->onSlotChangeCallback)($inventory, $slot, $oldItem);
|
($this->onSlotChange)($inventory, $slot, $oldItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,8 +70,8 @@ class CallbackInventoryListener implements InventoryListener{
|
|||||||
* @param Item[] $oldContents
|
* @param Item[] $oldContents
|
||||||
*/
|
*/
|
||||||
public function onContentChange(Inventory $inventory, array $oldContents) : void{
|
public function onContentChange(Inventory $inventory, array $oldContents) : void{
|
||||||
if($this->onContentChangeCallback !== null){
|
if($this->onContentChange !== null){
|
||||||
($this->onContentChangeCallback)($inventory, $oldContents);
|
($this->onContentChange)($inventory, $oldContents);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ final class CreativeInventory{
|
|||||||
use SingletonTrait;
|
use SingletonTrait;
|
||||||
|
|
||||||
/** @var Item[] */
|
/** @var Item[] */
|
||||||
private $creative = [];
|
private array $creative = [];
|
||||||
|
|
||||||
private function __construct(){
|
private function __construct(){
|
||||||
$creativeItems = json_decode(file_get_contents(Path::join(\pocketmine\BEDROCK_DATA_PATH, "creativeitems.json")), true);
|
$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;
|
use pocketmine\entity\Human;
|
||||||
|
|
||||||
final class PlayerOffHandInventory extends SimpleInventory{
|
final class PlayerOffHandInventory extends SimpleInventory{
|
||||||
/** @var Human */
|
private Human $holder;
|
||||||
private $holder;
|
|
||||||
|
|
||||||
public function __construct(Human $player){
|
public function __construct(Human $player){
|
||||||
$this->holder = $player;
|
$this->holder = $player;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user