Skip to content

Commit 53b5a3f

Browse files
committed
Discourage libevent on PHP 7
1 parent 626faeb commit 53b5a3f

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/Factory.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ class Factory
77
public static function create()
88
{
99
// @codeCoverageIgnoreStart
10-
if (function_exists('event_base_new')) {
11-
return new LibEventLoop();
12-
} elseif (class_exists('libev\EventLoop', false)) {
10+
if (class_exists('libev\EventLoop', false)) {
1311
return new LibEvLoop;
1412
} elseif (class_exists('EventBase', false)) {
1513
return new ExtEventLoop;
14+
} elseif (function_exists('event_base_new') && version_compare(PHP_VERSION, '7.0.0', '<')) {
15+
return new LibEventLoop();
1616
}
1717

1818
return new StreamSelectLoop();

src/LibEventLoop.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ class LibEventLoop implements LoopInterface
3131

3232
public function __construct()
3333
{
34+
if (version_compare(PHP_VERSION, '7.0.0') >= 0) {
35+
trigger_error('The libevent extension has not yet been updated for PHP 7, it is recommended you use a different loop', E_USER_WARNING);
36+
}
37+
3438
$this->eventBase = event_base_new();
3539
$this->nextTickQueue = new NextTickQueue($this);
3640
$this->futureTickQueue = new FutureTickQueue($this);

0 commit comments

Comments
 (0)