Completed
Push — master ( ac3291...615cf2 )
by Akihito
02:33
created
src/Snidel/ForkCollection.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
src/Snidel/Log.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
src/Snidel/Token.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
src/Snidel/MapContainer.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -137,6 +137,6 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/Snidel/IpcKey.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
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,6 +52,6 @@  discard block
 block discarded – undo
52 52
      */
53 53
     public function delete()
54 54
     {
55
-        unlink('/tmp/' . $this->prefix . $this->ownerPid);
55
+        unlink('/tmp/'.$this->prefix.$this->ownerPid);
56 56
     }
57 57
 }
Please login to merge, or discard this patch.
src/Snidel/ResultQueue.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
     public function __construct($ownerPid)
15 15
     {
16 16
         $this->ownerPid = $ownerPid;
17
-        $this->ipcKey = new IpcKey($ownerPid, 'snidel_result_' . uniqid((string) mt_rand(1, 100), true));
17
+        $this->ipcKey = new IpcKey($ownerPid, 'snidel_result_'.uniqid((string) mt_rand(1, 100), true));
18 18
         $this->id = msg_get_queue($this->ipcKey->generate());
19 19
     }
20 20
 
Please login to merge, or discard this patch.
src/Snidel/TaskQueue.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
     public function __construct($ownerPid)
15 15
     {
16 16
         $this->ownerPid = $ownerPid;
17
-        $this->ipcKey = new IpcKey($ownerPid, 'snidel_task_' . uniqid((string) mt_rand(1, 100), true));
17
+        $this->ipcKey = new IpcKey($ownerPid, 'snidel_task_'.uniqid((string) mt_rand(1, 100), true));
18 18
         $this->id = msg_get_queue($this->ipcKey->generate());
19 19
     }
20 20
 
Please login to merge, or discard this patch.
src/Snidel/ForkContainer.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -98,8 +98,8 @@
 block discarded – undo
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);
Please login to merge, or discard this patch.
src/Snidel.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -95,8 +95,8 @@  discard block
 block discarded – undo
95 95
         foreach ($this->signals as $sig) {
96 96
             $this->pcntl->signal(
97 97
                 $sig,
98
-                function ($sig) use($log, $token, $self) {
99
-                    $log->info('received signal. signo: ' . $sig);
98
+                function($sig) use($log, $token, $self) {
99
+                    $log->info('received signal. signo: '.$sig);
100 100
                     $self->setReceivedSignal($sig);
101 101
 
102 102
                     $log->info('--> sending a signal to children.');
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
             );
113 113
         }
114 114
 
115
-        $this->log->info('parent pid: ' . $this->ownerPid);
115
+        $this->log->info('parent pid: '.$this->ownerPid);
116 116
     }
117 117
 
118 118
     /**
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
             throw $e;
149 149
         }
150 150
 
151
-        $this->log->info('queued task #' . $this->taskQueue->queuedCount());
151
+        $this->log->info('queued task #'.$this->taskQueue->queuedCount());
152 152
     }
153 153
 
154 154
     /**
@@ -164,17 +164,17 @@  discard block
 block discarded – undo
164 164
 
165 165
         if ($pid) {
166 166
             // owner
167
-            $this->log->info('pid: ' . getmypid());
167
+            $this->log->info('pid: '.getmypid());
168 168
         } elseif ($pid === -1) {
169 169
             // error
170 170
         } else {
171 171
             // master
172
-            $this->log->info('pid: ' . $this->masterProcessId);
172
+            $this->log->info('pid: '.$this->masterProcessId);
173 173
             foreach ($this->signals as $sig) {
174 174
                 $this->pcntl->signal($sig, SIG_DFL, true);
175 175
             }
176 176
             while ($task = $this->taskQueue->dequeue()) {
177
-                $this->log->info('dequeued task #' . $this->taskQueue->dequeuedCount());
177
+                $this->log->info('dequeued task #'.$this->taskQueue->dequeuedCount());
178 178
                 if ($this->token->accept()) {
179 179
                     $this->forkWorker($task);
180 180
                 }
@@ -203,10 +203,10 @@  discard block
 block discarded – undo
203 203
 
204 204
         if (getmypid() === $this->masterProcessId) {
205 205
             // master
206
-            $this->log->info('forked worker. pid: ' . $fork->getPid());
206
+            $this->log->info('forked worker. pid: '.$fork->getPid());
207 207
         } else {
208 208
             // worker
209
-            $this->log->info('has forked. pid: ' . getmypid());
209
+            $this->log->info('has forked. pid: '.getmypid());
210 210
             // @codeCoverageIgnoreStart
211 211
             foreach ($this->signals as $sig) {
212 212
                 $this->pcntl->signal($sig, SIG_DFL, true);
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 
215 215
             // in php5.3, $this is not usable directly with closures.
216 216
             $resultQueue = $this->resultQueue;
217
-            register_shutdown_function(function () use ($fork, $resultQueue) {
217
+            register_shutdown_function(function() use ($fork, $resultQueue) {
218 218
                 if ($fork->hasNoResult() || !$fork->isQueued()) {
219 219
                     $result = new Result();
220 220
                     $result->setFailure();
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 
265 265
         if (getmypid() === $this->ownerPid) {
266 266
             // parent
267
-            $this->log->info('created child process. pid: ' . $fork->getPid());
267
+            $this->log->info('created child process. pid: '.$fork->getPid());
268 268
             $this->childPids[] = $fork->getPid();
269 269
         } else {
270 270
             // @codeCoverageIgnoreStart
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
             $dataRepository     = $this->dataRepository;
280 280
             $log                = $this->log;
281 281
             $processToken       = $this->processToken;
282
-            register_shutdown_function(function () use ($fork, $dataRepository, $log, $processToken) {
282
+            register_shutdown_function(function() use ($fork, $dataRepository, $log, $processToken) {
283 283
                 $data = $dataRepository->load(getmypid());
284 284
                 try {
285 285
                     $data->write($fork->getResult());
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
             $childPid   = $fork->getPid();
329 329
             $result     = $fork->getResult();
330 330
             if ($fork->hasNotFinishedSuccessfully()) {
331
-                $message = 'an error has occurred in child process. pid: ' . $childPid;
331
+                $message = 'an error has occurred in child process. pid: '.$childPid;
332 332
                 $this->log->error($message);
333 333
                 $this->error[$childPid] = array(
334 334
                     'status'    => $fork->getStatus(),
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
         }
396 396
 
397 397
         if (!$this->forkContainer->hasTag($tag)) {
398
-            throw new \InvalidArgumentException('unknown tag: ' . $tag);
398
+            throw new \InvalidArgumentException('unknown tag: '.$tag);
399 399
         }
400 400
 
401 401
         return $this->forkContainer->getCollection($tag);
@@ -422,12 +422,12 @@  discard block
 block discarded – undo
422 422
             return new ForkCollection($this->forks);
423 423
         }
424 424
 
425
-        $filtered = array_filter($this->forks, function ($fork) use ($tag) {
425
+        $filtered = array_filter($this->forks, function($fork) use ($tag) {
426 426
             return $fork->getTag() === $tag;
427 427
         });
428 428
 
429 429
         if (count($filtered) === 0) {
430
-            throw new \InvalidArgumentException('unknown tag: ' . $tag);
430
+            throw new \InvalidArgumentException('unknown tag: '.$tag);
431 431
         }
432 432
 
433 433
         return new ForkCollection($filtered);
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
     public function sendSignalToChildren($sig)
443 443
     {
444 444
         foreach ($this->childPids as $pid) {
445
-            $this->log->info('----> sending a signal to child. pid: ' . $pid);
445
+            $this->log->info('----> sending a signal to child. pid: '.$pid);
446 446
             posix_kill($pid, $sig);
447 447
         }
448 448
     }
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
 
545 545
             $childPid = $fork->getPid();
546 546
             if ($fork->hasNotFinishedSuccessfully()) {
547
-                $message = 'an error has occurred in child process. pid: ' . $childPid;
547
+                $message = 'an error has occurred in child process. pid: '.$childPid;
548 548
                 $this->log->error($message);
549 549
                 throw new \RuntimeException($message);
550 550
             }
Please login to merge, or discard this patch.