1 | <?php |
||
27 | class Worker |
||
28 | { |
||
29 | // Send as response context to request worker termination |
||
30 | public const STOP = '{"stop":true}'; |
||
31 | |||
32 | /** @var Relay */ |
||
33 | private $relay; |
||
34 | |||
35 | /** |
||
36 | * @param Relay $relay |
||
37 | */ |
||
38 | public function __construct(Relay $relay) |
||
42 | |||
43 | /** |
||
44 | * Receive packet of information to process, returns null when process must be stopped. Might |
||
45 | * return Error to wrap error message from server. |
||
46 | * |
||
47 | * @param mixed $header |
||
48 | * @return \Error|null|string |
||
49 | * |
||
50 | * @throws GoridgeException |
||
51 | */ |
||
52 | public function receive(&$header) |
||
75 | |||
76 | /** |
||
77 | * Respond to the server with result of task execution and execution context. |
||
78 | * |
||
79 | * Example: |
||
80 | * $worker->respond((string)$response->getBody(), json_encode($response->getHeaders())); |
||
81 | * |
||
82 | * @param string|null $payload |
||
83 | * @param string|null $header |
||
84 | */ |
||
85 | public function send(string $payload = null, string $header = null): void |
||
104 | |||
105 | /** |
||
106 | * Respond to the server with an error. Error must be treated as TaskError and might not cause |
||
107 | * worker destruction. |
||
108 | * |
||
109 | * Example: |
||
110 | * |
||
111 | * $worker->error("invalid payload"); |
||
112 | * |
||
113 | * @param string $message |
||
114 | */ |
||
115 | public function error(string $message): void |
||
122 | |||
123 | /** |
||
124 | * Terminate the process. Server must automatically pass task to the next available process. |
||
125 | * Worker will receive StopCommand context after calling this method. |
||
126 | * |
||
127 | * Attention, you MUST use continue; after invoking this method to let rr to properly |
||
128 | * stop worker. |
||
129 | * |
||
130 | * @throws GoridgeException |
||
131 | */ |
||
132 | public function stop(): void |
||
136 | |||
137 | /** |
||
138 | * Handles incoming control command payload and executes it if required. |
||
139 | * |
||
140 | * @param string $body |
||
141 | * @param mixed $header Exported context (if any). |
||
142 | * @param int $flags |
||
143 | * @return bool True when continue processing. |
||
144 | * |
||
145 | * @throws RoadRunnerException |
||
146 | */ |
||
147 | private function handleControl(string $body = null, &$header = null, int $flags = 0): bool |
||
178 | } |
||
179 |
This check compares calls to functions or methods with their respective definitions. If the call has more 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.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.