1 | <?php |
||
12 | class PipeQueue implements QueueInterface |
||
13 | { |
||
14 | /** |
||
15 | * @var Pipe |
||
16 | */ |
||
17 | protected $pipe; |
||
18 | |||
19 | /** |
||
20 | * @var bool |
||
21 | */ |
||
22 | protected $block; |
||
23 | |||
24 | /** |
||
25 | * @param string $filename fifo filename |
||
26 | * @param int $mode |
||
27 | * @param bool $block if blocking |
||
|
|||
28 | */ |
||
29 | 3 | public function __construct($filename = '/tmp/simple-fork.pipe', $mode = 0666) |
|
35 | |||
36 | /** |
||
37 | * put value into the queue of channel |
||
38 | * |
||
39 | * @param $value |
||
40 | * @return bool |
||
41 | */ |
||
42 | 3 | public function put($value) |
|
53 | |||
54 | /** |
||
55 | * get value from the queue of channel |
||
56 | * |
||
57 | * @param bool $block if block when the queue is empty |
||
58 | * @return bool|string |
||
59 | */ |
||
60 | 3 | public function get($block = false) |
|
61 | { |
||
62 | 3 | if ($this->block != $block) { |
|
63 | $this->pipe->setBlock($block); |
||
64 | $this->block = $block; |
||
65 | } |
||
66 | 3 | $len = $this->pipe->read(4); |
|
67 | 3 | if ($len === false) { |
|
68 | throw new \RuntimeException('read pipe failed'); |
||
69 | } |
||
70 | |||
71 | 3 | if (strlen($len) === 0) { |
|
72 | return null; |
||
73 | } |
||
74 | 3 | $len = unpack('N', $len); |
|
75 | 3 | if (empty($len) || !array_key_exists(1, $len) || empty($len[1])) { |
|
76 | throw new \RuntimeException('data protocol error'); |
||
77 | } |
||
78 | 3 | $len = intval($len[1]); |
|
79 | |||
80 | 3 | $value = ''; |
|
81 | 3 | while (true) { |
|
82 | 3 | $temp = $this->pipe->read($len); |
|
83 | 3 | if (strlen($temp) == $len) { |
|
84 | 3 | return $temp; |
|
85 | } |
||
86 | $value .= $temp; |
||
87 | $len -= strlen($temp); |
||
88 | if ($len == 0) { |
||
89 | return $value; |
||
90 | } |
||
91 | } |
||
92 | } |
||
93 | |||
94 | /** |
||
95 | * remove the queue resource |
||
96 | * |
||
97 | * @return bool |
||
98 | */ |
||
99 | public function remove() |
||
104 | } |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.