Modernize property type declarations

This commit is contained in:
Dylan K. Taylor
2022-06-04 18:16:32 +01:00
parent 23695fb900
commit 083a35f970
114 changed files with 431 additions and 863 deletions

View File

@ -48,15 +48,13 @@ use function intdiv;
* results, with no remainder. Any leftovers are expected to be emitted back to the crafting grid.
*/
class CraftingTransaction extends InventoryTransaction{
/** @var CraftingRecipe|null */
protected $recipe;
/** @var int|null */
protected $repetitions;
protected ?CraftingRecipe $recipe;
protected ?int $repetitions;
/** @var Item[] */
protected $inputs = [];
protected array $inputs = [];
/** @var Item[] */
protected $outputs = [];
protected array $outputs = [];
private CraftingManager $craftingManager;

View File

@ -55,22 +55,21 @@ use function spl_object_id;
* @see InventoryAction
*/
class InventoryTransaction{
/** @var bool */
protected $hasExecuted = false;
/** @var Player */
protected $source;
protected bool $hasExecuted = false;
/** @var Inventory[] */
protected $inventories = [];
protected array $inventories = [];
/** @var InventoryAction[] */
protected $actions = [];
protected array $actions = [];
/**
* @param InventoryAction[] $actions
*/
public function __construct(Player $source, array $actions = []){
$this->source = $source;
public function __construct(
protected Player $source,
array $actions = []
){
foreach($actions as $action){
$this->addAction($action);
}

View File

@ -32,15 +32,10 @@ use pocketmine\player\Player;
* Represents an action involving a change that applies in some way to an inventory or other item-source.
*/
abstract class InventoryAction{
/** @var Item */
protected $sourceItem;
/** @var Item */
protected $targetItem;
public function __construct(Item $sourceItem, Item $targetItem){
$this->sourceItem = $sourceItem;
$this->targetItem = $targetItem;
}
public function __construct(
protected Item $sourceItem,
protected Item $targetItem
){}
/**
* Returns the item that was present before the action took place.

View File

@ -33,15 +33,13 @@ use pocketmine\player\Player;
* Represents an action causing a change in an inventory slot.
*/
class SlotChangeAction extends InventoryAction{
/** @var Inventory */
protected $inventory;
private int $inventorySlot;
public function __construct(Inventory $inventory, int $inventorySlot, Item $sourceItem, Item $targetItem){
public function __construct(
protected Inventory $inventory,
private int $inventorySlot,
Item $sourceItem,
Item $targetItem
){
parent::__construct($sourceItem, $targetItem);
$this->inventory = $inventory;
$this->inventorySlot = $inventorySlot;
}
/**