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

View File

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

View File

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