Issues (11)

src/Master.php (3 issues)

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;
0 ignored issues
show
The type Swoole\Process was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
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
The parameter $pid is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

28
    public static function watch(/** @scrutinizer ignore-unused */ int $pid) : void

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
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 ignore-call  annotation

43
            Progress::/** @scrutinizer ignore-call */ 
44
                      exited(...self::$exited[$pid]);

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.

Loading history...
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