Modernize private property declarations in src/event

This commit is contained in:
Dylan K. Taylor 2022-05-17 20:45:50 +01:00
parent ec6769a6fc
commit eb95e2a97e
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
3 changed files with 14 additions and 34 deletions

View File

@ -28,18 +28,14 @@ use function array_fill_keys;
use function spl_object_id;
class HandlerList{
/** @var string */
private $class;
/** @var RegisteredListener[][] */
private $handlerSlots = [];
/** @var HandlerList|null */
private $parentList;
private array $handlerSlots = [];
public function __construct(string $class, ?HandlerList $parentList){
$this->class = $class;
public function __construct(
private string $class,
private ?HandlerList $parentList
){
$this->handlerSlots = array_fill_keys(EventPriority::ALL, []);
$this->parentList = $parentList;
}
/**

View File

@ -28,15 +28,14 @@ use pocketmine\utils\Utils;
class HandlerListManager{
/** @var HandlerListManager|null */
private static $globalInstance = null;
private static ?self $globalInstance = null;
public static function global() : self{
return self::$globalInstance ?? (self::$globalInstance = new self);
}
/** @var HandlerList[] classname => HandlerList */
private $allLists = [];
private array $allLists = [];
/**
* Unregisters all the listeners

View File

@ -28,31 +28,16 @@ use pocketmine\timings\TimingsHandler;
use function in_array;
class RegisteredListener{
/** @var \Closure */
private $handler;
/** @var int */
private $priority;
/** @var Plugin */
private $plugin;
/** @var bool */
private $handleCancelled;
/** @var TimingsHandler */
private $timings;
public function __construct(\Closure $handler, int $priority, Plugin $plugin, bool $handleCancelled, TimingsHandler $timings){
public function __construct(
private \Closure $handler,
private int $priority,
private Plugin $plugin,
private bool $handleCancelled,
private TimingsHandler $timings
){
if(!in_array($priority, EventPriority::ALL, true)){
throw new \InvalidArgumentException("Invalid priority number $priority");
}
$this->handler = $handler;
$this->priority = $priority;
$this->plugin = $plugin;
$this->handleCancelled = $handleCancelled;
$this->timings = $timings;
}
public function getHandler() : \Closure{