Răsfoiți Sursa

Finalize Event classes

Anton 2 ani în urmă
părinte
comite
d9fade8899
6 a modificat fișierele cu 48 adăugiri și 48 ștergeri
  1. 7 7
      src/Events/Ev.php
  2. 9 9
      src/Events/Event.php
  3. 7 7
      src/Events/Revolt.php
  4. 14 14
      src/Events/Select.php
  5. 5 5
      src/Events/Swoole.php
  6. 6 6
      src/Events/Swow.php

+ 7 - 7
src/Events/Ev.php

@@ -18,47 +18,47 @@ namespace Workerman\Events;
 /**
  * Ev eventloop
  */
-class Ev implements EventInterface
+final class Ev implements EventInterface
 {
     /**
      * All listeners for read event.
      *
      * @var array<int, \EvIo>
      */
-    protected array $readEvents = [];
+    private array $readEvents = [];
 
     /**
      * All listeners for write event.
      *
      * @var array<int, \EvIo>
      */
-    protected array $writeEvents = [];
+    private array $writeEvents = [];
 
     /**
      * Event listeners of signal.
      *
      * @var array<int, \EvSignal>
      */
-    protected array $eventSignal = [];
+    private array $eventSignal = [];
 
     /**
      * All timer event listeners.
      *
      * @var array<int, \EvTimer>
      */
-    protected array $eventTimer = [];
+    private array $eventTimer = [];
 
     /**
      * @var ?callable
      */
-    protected $errorHandler = null;
+    private $errorHandler = null;
 
     /**
      * Timer id.
      *
      * @var int
      */
-    protected static int $timerId = 1;
+    private static int $timerId = 1;
 
     /**
      * {@inheritdoc}

+ 9 - 9
src/Events/Event.php

@@ -19,61 +19,61 @@ namespace Workerman\Events;
 /**
  * libevent eventloop
  */
-class Event implements EventInterface
+final class Event implements EventInterface
 {
     /**
      * Event base.
      *
      * @var \EventBase
      */
-    protected \EventBase $eventBase;
+    private \EventBase $eventBase;
 
     /**
      * All listeners for read event.
      *
      * @var array<int, \Event>
      */
-    protected array $readEvents = [];
+    private array $readEvents = [];
 
     /**
      * All listeners for write event.
      *
      * @var array<int, \Event>
      */
-    protected array $writeEvents = [];
+    private array $writeEvents = [];
 
     /**
      * Event listeners of signal.
      *
      * @var array<int, \Event>
      */
-    protected array $eventSignal = [];
+    private array $eventSignal = [];
 
     /**
      * All timer event listeners.
      *
      * @var array<int, \Event>
      */
-    protected array $eventTimer = [];
+    private array $eventTimer = [];
 
     /**
      * Timer id.
      *
      * @var int
      */
-    protected int $timerId = 0;
+    private int $timerId = 0;
 
     /**
      * Event class name.
      *
      * @var string
      */
-    protected string $eventClassName = '';
+    private string $eventClassName = '';
 
     /**
      * @var ?callable
      */
-    protected $errorHandler = null;
+    private $errorHandler = null;
 
     /**
      * Construct.

+ 7 - 7
src/Events/Revolt.php

@@ -25,47 +25,47 @@ use function pcntl_signal;
 /**
  * Revolt eventloop
  */
-class Revolt implements EventInterface
+final class Revolt implements EventInterface
 {
     /**
      * @var Driver
      */
-    protected Driver $driver;
+    private Driver $driver;
 
     /**
      * All listeners for read event.
      *
      * @var array<int, string>
      */
-    protected array $readEvents = [];
+    private array $readEvents = [];
 
     /**
      * All listeners for write event.
      *
      * @var array<int, string>
      */
-    protected array $writeEvents = [];
+    private array $writeEvents = [];
 
     /**
      * Event listeners of signal.
      *
      * @var array<int, string>
      */
-    protected array $eventSignal = [];
+    private array $eventSignal = [];
 
     /**
      * Event listeners of timer.
      *
      * @var array<int, string>
      */
-    protected array $eventTimer = [];
+    private array $eventTimer = [];
 
     /**
      * Timer id.
      *
      * @var int
      */
-    protected int $timerId = 1;
+    private int $timerId = 1;
 
     /**
      * Construct.

+ 14 - 14
src/Events/Select.php

@@ -26,61 +26,61 @@ use const DIRECTORY_SEPARATOR;
 /**
  * select eventloop
  */
-class Select implements EventInterface
+final class Select implements EventInterface
 {
     /**
      * Running.
      *
      * @var bool
      */
-    protected bool $running = true;
+    private bool $running = true;
 
     /**
      * All listeners for read/write event.
      *
      * @var array<int, callable>
      */
-    protected array $readEvents = [];
+    private array $readEvents = [];
 
     /**
      * All listeners for read/write event.
      *
      * @var array<int, callable>
      */
-    protected array $writeEvents = [];
+    private array $writeEvents = [];
 
     /**
      * @var array<int, callable>
      */
-    protected array $exceptEvents = [];
+    private array $exceptEvents = [];
 
     /**
      * Event listeners of signal.
      *
      * @var array<int, callable>
      */
-    protected array $signalEvents = [];
+    private array $signalEvents = [];
 
     /**
      * Fds waiting for read event.
      *
      * @var array<int, resource>
      */
-    protected array $readFds = [];
+    private array $readFds = [];
 
     /**
      * Fds waiting for write event.
      *
      * @var array<int, resource>
      */
-    protected array $writeFds = [];
+    private array $writeFds = [];
 
     /**
      * Fds waiting for except event.
      *
      * @var array<int, resource>
      */
-    protected array $exceptFds = [];
+    private array $exceptFds = [];
 
     /**
      * Timer scheduler.
@@ -88,7 +88,7 @@ class Select implements EventInterface
      *
      * @var \SplPriorityQueue
      */
-    protected \SplPriorityQueue $scheduler;
+    private \SplPriorityQueue $scheduler;
 
     /**
      * All timer event listeners.
@@ -96,26 +96,26 @@ class Select implements EventInterface
      *
      * @var array
      */
-    protected array $eventTimer = [];
+    private array $eventTimer = [];
 
     /**
      * Timer id.
      *
      * @var int
      */
-    protected int $timerId = 1;
+    private int $timerId = 1;
 
     /**
      * Select timeout.
      *
      * @var int
      */
-    protected int $selectTimeout = 100000000;
+    private int $selectTimeout = 100000000;
 
     /**
      * @var ?callable
      */
-    protected $errorHandler = null;
+    private $errorHandler = null;
 
     /**
      * Construct.

+ 5 - 5
src/Events/Swoole.php

@@ -19,33 +19,33 @@ use Swoole\Event;
 use Swoole\Process;
 use Swoole\Timer;
 
-class Swoole implements EventInterface
+final class Swoole implements EventInterface
 {
     /**
      * All listeners for read timer
      *
      * @var array<int, int>
      */
-    protected array $eventTimer = [];
+    private array $eventTimer = [];
 
     /**
      * All listeners for read event.
      *
      * @var array<int, resource>
      */
-    protected array $readEvents = [];
+    private array $readEvents = [];
 
     /**
      * All listeners for write event.
      *
      * @var array<int, resource>
      */
-    protected array $writeEvents = [];
+    private array $writeEvents = [];
 
     /**
      * @var ?callable
      */
-    protected $errorHandler = null;
+    private $errorHandler = null;
 
     /**
      * {@inheritdoc}

+ 6 - 6
src/Events/Swow.php

@@ -9,38 +9,38 @@ use Swow\Signal;
 use Swow\SignalException;
 use function Swow\Sync\waitAll;
 
-class Swow implements EventInterface
+final class Swow implements EventInterface
 {
     /**
      * All listeners for read timer.
      *
      * @var array<int, int>
      */
-    protected array $eventTimer = [];
+    private array $eventTimer = [];
 
     /**
      * All listeners for read event.
      *
      * @var array<int, Coroutine>
      */
-    protected array $readEvents = [];
+    private array $readEvents = [];
 
     /**
      * All listeners for write event.
      * @var array<int, Coroutine>
      */
-    protected array $writeEvents = [];
+    private array $writeEvents = [];
 
     /**
      * All listeners for signal.
      * @var array<int, Coroutine>
      */
-    protected array $signalListener = [];
+    private array $signalListener = [];
 
     /**
      * @var ?callable
      */
-    protected $errorHandler = null;
+    private $errorHandler = null;
 
     /**
      * Get timer count.