Skip to content

Commit c2a446c

Browse files
committed
fix "Notice: Use of undefined constant SIGTERM - assumed 'SIGTERM'"
https://github.com/php-enqueue/amqp-tools/issues/1
1 parent 8dec2b7 commit c2a446c

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

pkg/amqp-tools/SignalSocketHelper.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ class SignalSocketHelper
1414
*/
1515
private $wasThereSignal;
1616

17-
/**
18-
* @var int[]
19-
*/
20-
private $signals = [SIGTERM, SIGQUIT, SIGINT];
21-
2217
public function __construct()
2318
{
2419
$this->handlers = [];
@@ -31,6 +26,8 @@ public function beforeSocket()
3126
return;
3227
}
3328

29+
$signals = [SIGTERM, SIGQUIT, SIGINT];
30+
3431
if ($this->handlers) {
3532
throw new \LogicException('The handlers property should be empty but it is not. The afterSocket method might not have been called.');
3633
}
@@ -40,12 +37,11 @@ public function beforeSocket()
4037

4138
$this->wasThereSignal = false;
4239

43-
foreach ($this->signals as $signal) {
40+
foreach ($signals as $signal) {
4441
/** @var callable $handler */
4542
$handler = pcntl_signal_get_handler($signal);
4643

4744
pcntl_signal($signal, function ($signal) use ($handler) {
48-
var_dump('fuckk!');
4945
$this->wasThereSignal = true;
5046

5147
$handler && $handler($signal);
@@ -62,9 +58,11 @@ public function afterSocket()
6258
return;
6359
}
6460

61+
$signals = [SIGTERM, SIGQUIT, SIGINT];
62+
6563
$this->wasThereSignal = null;
6664

67-
foreach ($this->signals as $signal) {
65+
foreach ($signals as $signal) {
6866
$handler = isset($this->handlers[$signal]) ? $this->handlers[$signal] : SIG_DFL;
6967

7068
pcntl_signal($signal, $handler);

0 commit comments

Comments
 (0)