Total Complexity | 8 |
Total Lines | 83 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | class FSProcess |
||
12 | { |
||
13 | /** |
||
14 | * Observed files. |
||
15 | * |
||
16 | * @var array |
||
17 | */ |
||
18 | protected $filter; |
||
19 | |||
20 | /** |
||
21 | * Watch recursively. |
||
22 | * |
||
23 | * @var bool |
||
24 | */ |
||
25 | protected $recursively; |
||
26 | |||
27 | /** |
||
28 | * Watch directory. |
||
29 | * |
||
30 | * @var string |
||
31 | */ |
||
32 | protected $directory; |
||
33 | |||
34 | /** |
||
35 | * When locked event cannot do anything. |
||
36 | * |
||
37 | * @var bool |
||
38 | */ |
||
39 | protected $locked; |
||
40 | |||
41 | /** |
||
42 | * FSProcess constructor. |
||
43 | * |
||
44 | * @param string $filter |
||
45 | * @param bool $recursively |
||
46 | * @param string $directory |
||
47 | */ |
||
48 | public function __construct(string $filter, bool $recursively, string $directory) |
||
49 | { |
||
50 | $this->filter = $filter; |
||
|
|||
51 | $this->recursively = $recursively; |
||
52 | $this->directory = $directory; |
||
53 | $this->locked = false; |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * Make swoole process. |
||
58 | * |
||
59 | * @param callable|null $callback |
||
60 | * |
||
61 | * @return \Swoole\Process |
||
62 | */ |
||
63 | public function make(?callable $callback = null) |
||
64 | { |
||
65 | $mcb = function ($type, $buffer) use ($callback) { |
||
66 | if (! $this->locked && AppProcess::OUT === $type && $event = FSEventParser::toEvent($buffer)) { |
||
67 | $this->locked = true; |
||
68 | ($callback) ? $callback($event) : null; |
||
69 | $this->locked = false; |
||
70 | unset($event); |
||
71 | } |
||
72 | }; |
||
73 | |||
74 | return new SwooleProcess(function () use ($mcb) { |
||
75 | (new AppProcess($this->configure()))->setTimeout(0)->run($mcb); |
||
76 | }, false, false); |
||
77 | } |
||
78 | |||
79 | /** |
||
80 | * Configure process. |
||
81 | * |
||
82 | * @return array |
||
83 | */ |
||
84 | protected function configure(): array |
||
94 | ]; |
||
95 | } |
||
96 | } |
||
97 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..