From 88d35a67c1b4cde4cea28643c1f4a6a52697a1c9 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Thu, 14 Jun 2018 03:01:01 +0200 Subject: [PATCH] Replaced constant references with fully qualified constant references --- src/ExtEventLoop.php | 4 ++-- src/ExtLibeventLoop.php | 14 +++++++------- src/Factory.php | 2 +- src/StreamSelectLoop.php | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/ExtEventLoop.php b/src/ExtEventLoop.php index a6153505..fd403d4a 100644 --- a/src/ExtEventLoop.php +++ b/src/ExtEventLoop.php @@ -69,7 +69,7 @@ public function addReadStream($stream, $listener) // ext-event does not increase refcount on stream resources for PHP 7+ // manually keep track of stream resource to prevent premature garbage collection - if (PHP_VERSION_ID >= 70000) { + if (\PHP_VERSION_ID >= 70000) { $this->readRefs[$key] = $stream; } } @@ -88,7 +88,7 @@ public function addWriteStream($stream, $listener) // ext-event does not increase refcount on stream resources for PHP 7+ // manually keep track of stream resource to prevent premature garbage collection - if (PHP_VERSION_ID >= 70000) { + if (\PHP_VERSION_ID >= 70000) { $this->writeRefs[$key] = $stream; } } diff --git a/src/ExtLibeventLoop.php b/src/ExtLibeventLoop.php index ddd66569..55c2fca0 100644 --- a/src/ExtLibeventLoop.php +++ b/src/ExtLibeventLoop.php @@ -74,7 +74,7 @@ public function addReadStream($stream, $listener) } $event = \event_new(); - \event_set($event, $stream, EV_PERSIST | EV_READ, $this->streamCallback); + \event_set($event, $stream, \EV_PERSIST | \EV_READ, $this->streamCallback); \event_base_set($event, $this->eventBase); \event_add($event); @@ -90,7 +90,7 @@ public function addWriteStream($stream, $listener) } $event = \event_new(); - \event_set($event, $stream, EV_PERSIST | EV_WRITE, $this->streamCallback); + \event_set($event, $stream, \EV_PERSIST | \EV_WRITE, $this->streamCallback); \event_base_set($event, $this->eventBase); \event_add($event); @@ -170,7 +170,7 @@ public function addSignal($signal, $listener) if (!isset($this->signalEvents[$signal])) { $this->signalEvents[$signal] = \event_new(); - \event_set($this->signalEvents[$signal], $signal, EV_PERSIST | EV_SIGNAL, array($this->signals, 'call')); + \event_set($this->signalEvents[$signal], $signal, \EV_PERSIST | \EV_SIGNAL, array($this->signals, 'call')); \event_base_set($this->signalEvents[$signal], $this->eventBase); \event_add($this->signalEvents[$signal]); } @@ -194,9 +194,9 @@ public function run() while ($this->running) { $this->futureTickQueue->tick(); - $flags = EVLOOP_ONCE; + $flags = \EVLOOP_ONCE; if (!$this->running || !$this->futureTickQueue->isEmpty()) { - $flags |= EVLOOP_NONBLOCK; + $flags |= \EVLOOP_NONBLOCK; } elseif (!$this->readEvents && !$this->writeEvents && !$this->timerEvents->count() && $this->signals->isEmpty()) { break; } @@ -271,11 +271,11 @@ private function createStreamCallback() $this->streamCallback = function ($stream, $flags) use (&$read, &$write) { $key = (int) $stream; - if (EV_READ === (EV_READ & $flags) && isset($read[$key])) { + if (\EV_READ === (\EV_READ & $flags) && isset($read[$key])) { \call_user_func($read[$key], $stream); } - if (EV_WRITE === (EV_WRITE & $flags) && isset($write[$key])) { + if (\EV_WRITE === (\EV_WRITE & $flags) && isset($write[$key])) { \call_user_func($write[$key], $stream); } }; diff --git a/src/Factory.php b/src/Factory.php index 48801466..763c077b 100644 --- a/src/Factory.php +++ b/src/Factory.php @@ -30,7 +30,7 @@ public static function create() return new ExtEvLoop(); } elseif (\class_exists('EventBase', false)) { return new ExtEventLoop(); - } elseif (\function_exists('event_base_new') && PHP_VERSION_ID < 70000) { + } elseif (\function_exists('event_base_new') && \PHP_VERSION_ID < 70000) { // only use ext-libevent on PHP < 7 for now return new ExtLibeventLoop(); } diff --git a/src/StreamSelectLoop.php b/src/StreamSelectLoop.php index 7b822e01..625b6fb6 100644 --- a/src/StreamSelectLoop.php +++ b/src/StreamSelectLoop.php @@ -163,7 +163,7 @@ public function removeSignal($signal, $listener) $this->signals->remove($signal, $listener); if ($this->signals->count($signal) === 0) { - \pcntl_signal($signal, SIG_DFL); + \pcntl_signal($signal, \SIG_DFL); } } @@ -190,7 +190,7 @@ public function run() // Ensure we do not exceed maximum integer size, which may // cause the loop to tick once every ~35min on 32bit systems. $timeout *= self::MICROSECONDS_PER_SECOND; - $timeout = $timeout > PHP_INT_MAX ? PHP_INT_MAX : (int)$timeout; + $timeout = $timeout > \PHP_INT_MAX ? \PHP_INT_MAX : (int)$timeout; } // The only possible event is stream or signal activity, so wait forever ...