Skip to content

Commit c259157

Browse files
committed
works only on PHP 7.1 and higher
1 parent 3dd8651 commit c259157

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

pkg/amqp-tools/SignalSocketHelper.php

+10
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ public function __construct()
2626

2727
public function beforeSocket()
2828
{
29+
// PHP 7.1 and higher
30+
if (false == function_exists('pcntl_signal_get_handler')) {
31+
return;
32+
}
33+
2934
if ($this->handlers) {
3035
throw new \LogicException('The handlers property should be empty but it is not. The afterSocket method might not have been called.');
3136
}
@@ -52,6 +57,11 @@ public function beforeSocket()
5257

5358
public function afterSocket()
5459
{
60+
// PHP 7.1 and higher
61+
if (false == function_exists('pcntl_signal_get_handler')) {
62+
return;
63+
}
64+
5565
$this->wasThereSignal = null;
5666

5767
foreach ($this->signals as $signal) {

pkg/amqp-tools/Tests/SignalSocketHelperTest.php

+4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ public function setUp()
2020
{
2121
parent::setUp();
2222

23+
if (false == function_exists('pcntl_signal_get_handler')) {
24+
$this->markTestSkipped('PHP 7.1 and higher');
25+
}
26+
2327
$this->backupSigTermHandler = pcntl_signal_get_handler(SIGTERM);
2428
$this->backupSigIntHandler = pcntl_signal_get_handler(SIGINT);
2529

0 commit comments

Comments
 (0)