@@ -20,7 +20,7 @@ |
||
20 | 20 | public function toArray() |
21 | 21 | { |
22 | 22 | return array_map( |
23 | - function ($fork) { |
|
23 | + function($fork) { |
|
24 | 24 | return $fork->getResult()->getReturn(); |
25 | 25 | }, |
26 | 26 | $this->forks |
@@ -49,7 +49,7 @@ |
||
49 | 49 | $type, |
50 | 50 | $pid, |
51 | 51 | ($this->ownerPid === $pid) ? 'p' : 'c', |
52 | - $message . PHP_EOL |
|
52 | + $message.PHP_EOL |
|
53 | 53 | ) |
54 | 54 | ); |
55 | 55 | } |
@@ -28,7 +28,7 @@ |
||
28 | 28 | { |
29 | 29 | $this->ownerPid = $ownerPid; |
30 | 30 | $this->concurrency = $concurrency; |
31 | - $this->ipcKey = new IpcKey($ownerPid, 'snidel_token_' . uniqid((string) mt_rand(1, 100), true)); |
|
31 | + $this->ipcKey = new IpcKey($ownerPid, 'snidel_token_'.uniqid((string) mt_rand(1, 100), true)); |
|
32 | 32 | $this->id = msg_get_queue($this->ipcKey->generate()); |
33 | 33 | $this->initializeQueue(); |
34 | 34 | } |
@@ -137,6 +137,6 @@ |
||
137 | 137 | return $index; |
138 | 138 | } |
139 | 139 | |
140 | - throw new MapContainerException('childPid not found. pid: ' . $childPid); |
|
140 | + throw new MapContainerException('childPid not found. pid: '.$childPid); |
|
141 | 141 | } |
142 | 142 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | */ |
27 | 27 | public function generate() |
28 | 28 | { |
29 | - $pathname = '/tmp/' . $this->prefix . $this->ownerPid; |
|
29 | + $pathname = '/tmp/'.$this->prefix.$this->ownerPid; |
|
30 | 30 | if (!file_exists($pathname)) { |
31 | 31 | touch($pathname); |
32 | 32 | } |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function delete() |
54 | 54 | { |
55 | - if (file_exists('/tmp/' . $this->prefix . $this->ownerPid)) { |
|
56 | - unlink('/tmp/' . $this->prefix . $this->ownerPid); |
|
55 | + if (file_exists('/tmp/'.$this->prefix.$this->ownerPid)) { |
|
56 | + unlink('/tmp/'.$this->prefix.$this->ownerPid); |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | } |
@@ -70,8 +70,8 @@ discard block |
||
70 | 70 | foreach ($this->signals as $sig) { |
71 | 71 | $this->pcntl->signal( |
72 | 72 | $sig, |
73 | - function ($sig) use($log, $self) { |
|
74 | - $log->info('received signal. signo: ' . $sig); |
|
73 | + function($sig) use($log, $self) { |
|
74 | + $log->info('received signal. signo: '.$sig); |
|
75 | 75 | $self->setReceivedSignal($sig); |
76 | 76 | |
77 | 77 | $log->info('--> sending a signal to children.'); |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | ); |
84 | 84 | } |
85 | 85 | |
86 | - $this->log->info('parent pid: ' . $this->ownerPid); |
|
86 | + $this->log->info('parent pid: '.$this->ownerPid); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | throw $e; |
120 | 120 | } |
121 | 121 | |
122 | - $this->log->info('queued task #' . $this->forkContainer->queuedCount()); |
|
122 | + $this->log->info('queued task #'.$this->forkContainer->queuedCount()); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | |
149 | 149 | if (getmypid() === $this->ownerPid) { |
150 | 150 | // parent |
151 | - $this->log->info('created child process. pid: ' . $fork->getPid()); |
|
151 | + $this->log->info('created child process. pid: '.$fork->getPid()); |
|
152 | 152 | } else { |
153 | 153 | // @codeCoverageIgnoreStart |
154 | 154 | // child |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | */ |
162 | 162 | $dataRepository = $this->dataRepository; |
163 | 163 | $log = $this->log; |
164 | - register_shutdown_function(function () use ($fork, $dataRepository, $log, $token) { |
|
164 | + register_shutdown_function(function() use ($fork, $dataRepository, $log, $token) { |
|
165 | 165 | $data = $dataRepository->load(getmypid()); |
166 | 166 | try { |
167 | 167 | $data->write($fork); |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | $this->wait(); |
227 | 227 | } |
228 | 228 | if (!$this->forkContainer->hasTag($tag)) { |
229 | - throw new \InvalidArgumentException('unknown tag: ' . $tag); |
|
229 | + throw new \InvalidArgumentException('unknown tag: '.$tag); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | return $this->forkContainer->getCollection($tag); |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | public function sendSignalToChildren($sig) |
242 | 242 | { |
243 | 243 | foreach ($this->forkContainer->getChildPids() as $pid) { |
244 | - $this->log->info('----> sending a signal to child. pid: ' . $pid); |
|
244 | + $this->log->info('----> sending a signal to child. pid: '.$pid); |
|
245 | 245 | posix_kill($pid, $sig); |
246 | 246 | } |
247 | 247 | } |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | |
345 | 345 | $childPid = $fork->getPid(); |
346 | 346 | if ($fork->hasNotFinishedSuccessfully()) { |
347 | - $message = 'an error has occurred in child process. pid: ' . $childPid; |
|
347 | + $message = 'an error has occurred in child process. pid: '.$childPid; |
|
348 | 348 | $this->log->error($message); |
349 | 349 | throw new \RuntimeException($message); |
350 | 350 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | |
130 | 130 | if ($pid) { |
131 | 131 | // owner |
132 | - $this->log->info('pid: ' . getmypid()); |
|
132 | + $this->log->info('pid: '.getmypid()); |
|
133 | 133 | |
134 | 134 | return $this->masterPid; |
135 | 135 | } elseif ($pid === -1) { |
@@ -137,14 +137,14 @@ discard block |
||
137 | 137 | } else { |
138 | 138 | // master |
139 | 139 | $taskQueue = new TaskQueue($this->ownerPid); |
140 | - $this->log->info('pid: ' . $this->masterPid); |
|
140 | + $this->log->info('pid: '.$this->masterPid); |
|
141 | 141 | |
142 | 142 | foreach ($this->signals as $sig) { |
143 | 143 | $this->pcntl->signal($sig, SIG_DFL, true); |
144 | 144 | } |
145 | 145 | |
146 | 146 | while ($task = $taskQueue->dequeue()) { |
147 | - $this->log->info('dequeued task #' . $taskQueue->dequeuedCount()); |
|
147 | + $this->log->info('dequeued task #'.$taskQueue->dequeuedCount()); |
|
148 | 148 | if ($this->token->accept()) { |
149 | 149 | $this->forkWorker($task); |
150 | 150 | } |
@@ -171,10 +171,10 @@ discard block |
||
171 | 171 | |
172 | 172 | if (getmypid() === $this->masterPid) { |
173 | 173 | // master |
174 | - $this->log->info('forked worker. pid: ' . $fork->getPid()); |
|
174 | + $this->log->info('forked worker. pid: '.$fork->getPid()); |
|
175 | 175 | } else { |
176 | 176 | // worker |
177 | - $this->log->info('has forked. pid: ' . getmypid()); |
|
177 | + $this->log->info('has forked. pid: '.getmypid()); |
|
178 | 178 | // @codeCoverageIgnoreStart |
179 | 179 | |
180 | 180 | foreach ($this->signals as $sig) { |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | } |
183 | 183 | |
184 | 184 | $resultQueue = new ResultQueue($this->ownerPid); |
185 | - register_shutdown_function(function () use ($fork, $resultQueue) { |
|
185 | + register_shutdown_function(function() use ($fork, $resultQueue) { |
|
186 | 186 | if ($fork->hasNoResult() || !$fork->isQueued()) { |
187 | 187 | $result = new Result(); |
188 | 188 | $result->setFailure(); |
@@ -315,8 +315,8 @@ discard block |
||
315 | 315 | */ |
316 | 316 | private function getCollectionWithTag($tag) |
317 | 317 | { |
318 | - $collection = array_filter($this->forks, function ($fork) use ($tag) { |
|
319 | - return $fork->getTag() === $tag; |
|
318 | + $collection = array_filter($this->forks, function($fork) use ($tag) { |
|
319 | + return $fork->getTag() === $tag; |
|
320 | 320 | }); |
321 | 321 | |
322 | 322 | return new ForkCollection($collection); |