1 | <?php |
||||||
2 | /** |
||||||
3 | * Master process |
||||||
4 | * User: moyo |
||||||
5 | * Date: 28/12/2017 |
||||||
6 | * Time: 12:08 PM |
||||||
7 | */ |
||||||
8 | |||||||
9 | namespace Carno\Process; |
||||||
10 | |||||||
11 | use Swoole\Process as SWProcess; |
||||||
12 | |||||||
13 | class Master |
||||||
14 | { |
||||||
15 | /** |
||||||
16 | * @var bool |
||||||
17 | */ |
||||||
18 | private static $watched = false; |
||||||
19 | |||||||
20 | /** |
||||||
21 | * @var array |
||||||
22 | */ |
||||||
23 | private static $exited = []; |
||||||
24 | |||||||
25 | /** |
||||||
26 | * @param int $pid |
||||||
27 | */ |
||||||
28 | public static function watch(int $pid) : void |
||||||
0 ignored issues
–
show
|
|||||||
29 | { |
||||||
30 | self::$watched || self::$watched = SWProcess::signal(SIGCHLD, function () { |
||||||
31 | while ($ex = SWProcess::wait(false)) { |
||||||
32 | Progress::exited($ex['pid'], $ex['signal'], $ex['code']); |
||||||
33 | } |
||||||
34 | }); |
||||||
35 | } |
||||||
36 | |||||||
37 | /** |
||||||
38 | * @param int $pid |
||||||
39 | */ |
||||||
40 | public static function wait(int $pid) : void |
||||||
41 | { |
||||||
42 | if (isset(self::$exited[$pid])) { |
||||||
43 | Progress::exited(...self::$exited[$pid]); |
||||||
0 ignored issues
–
show
The call to
Carno\Process\Progress::exited() has too few arguments starting with sig .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above. ![]() |
|||||||
44 | } else { |
||||||
45 | if (false !== $ex = SWProcess::wait(true)) { |
||||||
46 | if ($ex['pid'] === $pid) { |
||||||
47 | Progress::exited($ex['pid'], $ex['signal'], $ex['code']); |
||||||
48 | } else { |
||||||
49 | self::$exited[$ex['pid']] = [$ex['pid'], $ex['signal'], $ex['code']]; |
||||||
50 | } |
||||||
51 | } |
||||||
52 | } |
||||||
53 | } |
||||||
54 | } |
||||||
55 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.