event: modernize property declarations where possible

only private fields are modified; protected ones can't be changed in case someone extended the classes
This commit is contained in:
Dylan K. Taylor
2022-04-25 00:06:26 +01:00
parent ded7e24f67
commit c8a7a53d70
58 changed files with 258 additions and 444 deletions

View File

@ -34,28 +34,17 @@ use pocketmine\player\Player;
class CraftItemEvent extends Event implements Cancellable{
use CancellableTrait;
/** @var CraftingTransaction */
private $transaction;
/** @var CraftingRecipe */
private $recipe;
/** @var int */
private $repetitions;
/** @var Item[] */
private $inputs;
/** @var Item[] */
private $outputs;
/**
* @param Item[] $inputs
* @param Item[] $outputs
*/
public function __construct(CraftingTransaction $transaction, CraftingRecipe $recipe, int $repetitions, array $inputs, array $outputs){
$this->transaction = $transaction;
$this->recipe = $recipe;
$this->repetitions = $repetitions;
$this->inputs = $inputs;
$this->outputs = $outputs;
}
public function __construct(
private CraftingTransaction $transaction,
private CraftingRecipe $recipe,
private int $repetitions,
private array $inputs,
private array $outputs
){}
/**
* Returns the inventory transaction involved in this crafting event.

View File

@ -35,20 +35,14 @@ use pocketmine\item\Item;
class FurnaceBurnEvent extends BlockEvent implements Cancellable{
use CancellableTrait;
/** @var Furnace */
private $furnace;
/** @var Item */
private $fuel;
/** @var int */
private $burnTime;
/** @var bool */
private $burning = true;
private bool $burning = true;
public function __construct(Furnace $furnace, Item $fuel, int $burnTime){
public function __construct(
private Furnace $furnace,
private Item $fuel,
private int $burnTime
){
parent::__construct($furnace->getBlock());
$this->fuel = $fuel;
$this->burnTime = $burnTime;
$this->furnace = $furnace;
}
public function getFurnace() : Furnace{

View File

@ -32,19 +32,14 @@ use pocketmine\item\Item;
class FurnaceSmeltEvent extends BlockEvent implements Cancellable{
use CancellableTrait;
/** @var Furnace */
private $furnace;
/** @var Item */
private $source;
/** @var Item */
private $result;
public function __construct(Furnace $furnace, Item $source, Item $result){
public function __construct(
private Furnace $furnace,
private Item $source,
private Item $result
){
parent::__construct($furnace->getBlock());
$this->source = clone $source;
$this->source->setCount(1);
$this->result = $result;
$this->furnace = $furnace;
}
public function getFurnace() : Furnace{

View File

@ -27,11 +27,10 @@ use pocketmine\inventory\Inventory;
use pocketmine\player\Player;
class InventoryCloseEvent extends InventoryEvent{
/** @var Player */
private $who;
public function __construct(Inventory $inventory, Player $who){
$this->who = $who;
public function __construct(
Inventory $inventory,
private Player $who
){
parent::__construct($inventory);
}

View File

@ -31,11 +31,10 @@ use pocketmine\player\Player;
class InventoryOpenEvent extends InventoryEvent implements Cancellable{
use CancellableTrait;
/** @var Player */
private $who;
public function __construct(Inventory $inventory, Player $who){
$this->who = $who;
public function __construct(
Inventory $inventory,
private Player $who
){
parent::__construct($inventory);
}

View File

@ -35,12 +35,7 @@ use pocketmine\inventory\transaction\InventoryTransaction;
class InventoryTransactionEvent extends Event implements Cancellable{
use CancellableTrait;
/** @var InventoryTransaction */
private $transaction;
public function __construct(InventoryTransaction $transaction){
$this->transaction = $transaction;
}
public function __construct(private InventoryTransaction $transaction){}
public function getTransaction() : InventoryTransaction{
return $this->transaction;