@@ -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 | } |
@@ -98,8 +98,8 @@ |
||
| 98 | 98 | */ |
| 99 | 99 | private function getCollectionWithTag($tag) |
| 100 | 100 | { |
| 101 | - $collection = array_filter($this->forks, function ($fork) use ($tag) { |
|
| 102 | - return $fork->getTag() === $tag; |
|
| 101 | + $collection = array_filter($this->forks, function($fork) use ($tag) { |
|
| 102 | + return $fork->getTag() === $tag; |
|
| 103 | 103 | }); |
| 104 | 104 | |
| 105 | 105 | return new ForkCollection($collection); |
@@ -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 | } |
@@ -81,8 +81,8 @@ discard block |
||
| 81 | 81 | foreach ($this->signals as $sig) { |
| 82 | 82 | $this->pcntl->signal( |
| 83 | 83 | $sig, |
| 84 | - function ($sig) use($log, $token, $self) { |
|
| 85 | - $log->info('received signal. signo: ' . $sig); |
|
| 84 | + function($sig) use($log, $token, $self) { |
|
| 85 | + $log->info('received signal. signo: '.$sig); |
|
| 86 | 86 | $self->setReceivedSignal($sig); |
| 87 | 87 | |
| 88 | 88 | $log->info('--> sending a signal to children.'); |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | ); |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - $this->log->info('parent pid: ' . $this->ownerPid); |
|
| 101 | + $this->log->info('parent pid: '.$this->ownerPid); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | /** |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | throw $e; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - $this->log->info('queued task #' . $this->forkContainer->queuedCount()); |
|
| 137 | + $this->log->info('queued task #'.$this->forkContainer->queuedCount()); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -150,20 +150,20 @@ discard block |
||
| 150 | 150 | |
| 151 | 151 | if ($pid) { |
| 152 | 152 | // owner |
| 153 | - $this->log->info('pid: ' . getmypid()); |
|
| 153 | + $this->log->info('pid: '.getmypid()); |
|
| 154 | 154 | } elseif ($pid === -1) { |
| 155 | 155 | // error |
| 156 | 156 | } else { |
| 157 | 157 | // master |
| 158 | 158 | $taskQueue = new TaskQueue($this->ownerPid); |
| 159 | - $this->log->info('pid: ' . $this->masterProcessId); |
|
| 159 | + $this->log->info('pid: '.$this->masterProcessId); |
|
| 160 | 160 | |
| 161 | 161 | foreach ($this->signals as $sig) { |
| 162 | 162 | $this->pcntl->signal($sig, SIG_DFL, true); |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | while ($task = $taskQueue->dequeue()) { |
| 166 | - $this->log->info('dequeued task #' . $taskQueue->dequeuedCount()); |
|
| 166 | + $this->log->info('dequeued task #'.$taskQueue->dequeuedCount()); |
|
| 167 | 167 | if ($this->token->accept()) { |
| 168 | 168 | $this->forkWorker($task); |
| 169 | 169 | } |
@@ -192,10 +192,10 @@ discard block |
||
| 192 | 192 | |
| 193 | 193 | if (getmypid() === $this->masterProcessId) { |
| 194 | 194 | // master |
| 195 | - $this->log->info('forked worker. pid: ' . $fork->getPid()); |
|
| 195 | + $this->log->info('forked worker. pid: '.$fork->getPid()); |
|
| 196 | 196 | } else { |
| 197 | 197 | // worker |
| 198 | - $this->log->info('has forked. pid: ' . getmypid()); |
|
| 198 | + $this->log->info('has forked. pid: '.getmypid()); |
|
| 199 | 199 | // @codeCoverageIgnoreStart |
| 200 | 200 | |
| 201 | 201 | foreach ($this->signals as $sig) { |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | $resultQueue = new ResultQueue($this->ownerPid); |
| 206 | - register_shutdown_function(function () use ($fork, $resultQueue) { |
|
| 206 | + register_shutdown_function(function() use ($fork, $resultQueue) { |
|
| 207 | 207 | if ($fork->hasNoResult() || !$fork->isQueued()) { |
| 208 | 208 | $result = new Result(); |
| 209 | 209 | $result->setFailure(); |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | |
| 255 | 255 | if (getmypid() === $this->ownerPid) { |
| 256 | 256 | // parent |
| 257 | - $this->log->info('created child process. pid: ' . $fork->getPid()); |
|
| 257 | + $this->log->info('created child process. pid: '.$fork->getPid()); |
|
| 258 | 258 | $this->childPids[] = $fork->getPid(); |
| 259 | 259 | } else { |
| 260 | 260 | // @codeCoverageIgnoreStart |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | $dataRepository = $this->dataRepository; |
| 270 | 270 | $log = $this->log; |
| 271 | 271 | $processToken = $this->processToken; |
| 272 | - register_shutdown_function(function () use ($fork, $dataRepository, $log, $processToken) { |
|
| 272 | + register_shutdown_function(function() use ($fork, $dataRepository, $log, $processToken) { |
|
| 273 | 273 | $data = $dataRepository->load(getmypid()); |
| 274 | 274 | try { |
| 275 | 275 | $data->write($fork); |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | if ($fork->hasNotFinishedSuccessfully()) { |
| 319 | - $message = 'an error has occurred in child process. pid: ' . $fork->getPid(); |
|
| 319 | + $message = 'an error has occurred in child process. pid: '.$fork->getPid(); |
|
| 320 | 320 | $this->log->error($message); |
| 321 | 321 | } |
| 322 | 322 | unset($this->childPids[array_search($fork->getPid(), $this->childPids)]); |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | } |
| 366 | 366 | |
| 367 | 367 | if (!$this->forkContainer->hasTag($tag)) { |
| 368 | - throw new \InvalidArgumentException('unknown tag: ' . $tag); |
|
| 368 | + throw new \InvalidArgumentException('unknown tag: '.$tag); |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | return $this->forkContainer->getCollection($tag); |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | public function sendSignalToChildren($sig) |
| 381 | 381 | { |
| 382 | 382 | foreach ($this->childPids as $pid) { |
| 383 | - $this->log->info('----> sending a signal to child. pid: ' . $pid); |
|
| 383 | + $this->log->info('----> sending a signal to child. pid: '.$pid); |
|
| 384 | 384 | posix_kill($pid, $sig); |
| 385 | 385 | } |
| 386 | 386 | } |
@@ -482,7 +482,7 @@ discard block |
||
| 482 | 482 | |
| 483 | 483 | $childPid = $fork->getPid(); |
| 484 | 484 | if ($fork->hasNotFinishedSuccessfully()) { |
| 485 | - $message = 'an error has occurred in child process. pid: ' . $childPid; |
|
| 485 | + $message = 'an error has occurred in child process. pid: '.$childPid; |
|
| 486 | 486 | $this->log->error($message); |
| 487 | 487 | throw new \RuntimeException($message); |
| 488 | 488 | } |