| @@ -59,6 +59,7 @@ discard block | ||
| 59 | 59 | |
| 60 | 60 | /** | 
| 61 | 61 | * @param int $ownerPid | 
| 62 | + * @param \Ackintosh\Snidel\Log $log | |
| 62 | 63 | */ | 
| 63 | 64 | public function __construct($ownerPid, $log, $concurrency = 5) | 
| 64 | 65 |      { | 
| @@ -74,6 +75,7 @@ discard block | ||
| 74 | 75 | |
| 75 | 76 | /** | 
| 76 | 77 | * @param \Ackintosh\Snidel\Task | 
| 78 | + * @param \Ackintosh\Snidel\Task\Task $task | |
| 77 | 79 | * @return void | 
| 78 | 80 | * @throws \RuntimeException | 
| 79 | 81 | */ | 
| @@ -95,7 +97,7 @@ discard block | ||
| 95 | 97 | } | 
| 96 | 98 | |
| 97 | 99 | /** | 
| 98 | - * @return \Ackintosh\Snidel\Fork\Fork | |
| 100 | + * @return Result | |
| 99 | 101 | */ | 
| 100 | 102 | private function dequeue() | 
| 101 | 103 |      { | 
| @@ -345,7 +347,7 @@ discard block | ||
| 345 | 347 | } | 
| 346 | 348 | |
| 347 | 349 | /** | 
| 348 | - * @return array | |
| 350 | + * @return Fork[] | |
| 349 | 351 | */ | 
| 350 | 352 | public function getChildren() | 
| 351 | 353 |      { | 
| @@ -356,13 +358,16 @@ discard block | ||
| 356 | 358 | * return fork | 
| 357 | 359 | * | 
| 358 | 360 | * @param int $pid | 
| 359 | - * @return \Ackintosh\Snidel\Fork\Fork | |
| 361 | + * @return Result | |
| 360 | 362 | */ | 
| 361 | 363 | public function get($pid) | 
| 362 | 364 |      { | 
| 363 | 365 | return $this->results[$pid]; | 
| 364 | 366 | } | 
| 365 | 367 | |
| 368 | + /** | |
| 369 | + * @param string $tag | |
| 370 | + */ | |
| 366 | 371 | public function getCollection($tag = null) | 
| 367 | 372 |      { | 
| 368 | 373 |          if ($tag === null) { | 
| @@ -405,7 +410,7 @@ discard block | ||
| 405 | 410 | } | 
| 406 | 411 | |
| 407 | 412 | /** | 
| 408 | - * @return \Ackintosh\Sniden\Error | |
| 413 | + * @return Error | |
| 409 | 414 | */ | 
| 410 | 415 | public function getError() | 
| 411 | 416 |      { | 
| @@ -61,8 +61,8 @@ discard block | ||
| 61 | 61 |          foreach ($this->signals as $sig) { | 
| 62 | 62 | $this->pcntl->signal( | 
| 63 | 63 | $sig, | 
| 64 | -                function ($sig) use($log, $self) { | |
| 65 | -                    $log->info('received signal. signo: ' . $sig); | |
| 64 | +                function($sig) use($log, $self) { | |
| 65 | +                    $log->info('received signal. signo: '.$sig); | |
| 66 | 66 | $self->setReceivedSignal($sig); | 
| 67 | 67 | |
| 68 | 68 |                      $log->info('--> sending a signal " to children.'); | 
| @@ -74,7 +74,7 @@ discard block | ||
| 74 | 74 | ); | 
| 75 | 75 | } | 
| 76 | 76 | |
| 77 | -        $this->log->info('parent pid: ' . $this->ownerPid); | |
| 77 | +        $this->log->info('parent pid: '.$this->ownerPid); | |
| 78 | 78 | } | 
| 79 | 79 | |
| 80 | 80 | /** | 
| @@ -112,7 +112,7 @@ discard block | ||
| 112 | 112 | throw $e; | 
| 113 | 113 | } | 
| 114 | 114 | |
| 115 | -        $this->log->info('queued task #' . $this->container->queuedCount()); | |
| 115 | +        $this->log->info('queued task #'.$this->container->queuedCount()); | |
| 116 | 116 | } | 
| 117 | 117 | |
| 118 | 118 | /** | 
| @@ -139,7 +139,7 @@ discard block | ||
| 139 | 139 | |
| 140 | 140 |          if (getmypid() === $this->ownerPid) { | 
| 141 | 141 | // parent | 
| 142 | -            $this->log->info('created child process. pid: ' . $fork->getPid()); | |
| 142 | +            $this->log->info('created child process. pid: '.$fork->getPid()); | |
| 143 | 143 |          } else { | 
| 144 | 144 | // @codeCoverageIgnoreStart | 
| 145 | 145 | // child | 
| @@ -152,7 +152,7 @@ discard block | ||
| 152 | 152 | */ | 
| 153 | 153 | $log = $this->log; | 
| 154 | 154 | $resultHasWritten = false; | 
| 155 | -            register_shutdown_function(function () use (&$resultHasWritten, $fork, $task, $log, $token) { | |
| 155 | +            register_shutdown_function(function() use (&$resultHasWritten, $fork, $task, $log, $token) { | |
| 156 | 156 |                  if (!$resultHasWritten) { | 
| 157 | 157 | $dataRepository = new DataRepository(); | 
| 158 | 158 | $data = $dataRepository->load(getmypid()); | 
| @@ -234,7 +234,7 @@ discard block | ||
| 234 | 234 | $this->wait(); | 
| 235 | 235 | } | 
| 236 | 236 |          if ($tag !== null && !$this->container->hasTag($tag)) { | 
| 237 | -            throw new \InvalidArgumentException('unknown tag: ' . $tag); | |
| 237 | +            throw new \InvalidArgumentException('unknown tag: '.$tag); | |
| 238 | 238 | } | 
| 239 | 239 | |
| 240 | 240 | return $this->container->getCollection($tag); | 
| @@ -249,7 +249,7 @@ discard block | ||
| 249 | 249 | public function sendSignalToChildren($sig) | 
| 250 | 250 |      { | 
| 251 | 251 |          foreach ($this->container->getChildrend() as $child) { | 
| 252 | -            $this->log->info('----> sending a signal to child. pid: ' . $child->getPid()); | |
| 252 | +            $this->log->info('----> sending a signal to child. pid: '.$child->getPid()); | |
| 253 | 253 | posix_kill($child->getPid(), $sig); | 
| 254 | 254 | } | 
| 255 | 255 | } | 
| @@ -350,7 +350,7 @@ discard block | ||
| 350 | 350 | |
| 351 | 351 | $childPid = $result->getFork()->getPid(); | 
| 352 | 352 |              if ($result->isFailure()) { | 
| 353 | - $message = 'an error has occurred in child process. pid: ' . $childPid; | |
| 353 | + $message = 'an error has occurred in child process. pid: '.$childPid; | |
| 354 | 354 | $this->log->error($message); | 
| 355 | 355 | throw new \RuntimeException($message); | 
| 356 | 356 | } |