Completed
Push — master ( 922e8a...cfbc00 )
by Akihito
02:15
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 2 patches
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.
Switch Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -50,15 +50,15 @@
 block discarded – undo
50 50
         }
51 51
         $pid = getmypid();
52 52
         switch (true) {
53
-        case $this->ownerPid === $pid:
54
-            $role = 'owner';
55
-            break;
56
-        case $this->masterPid === $pid:
57
-            $role = 'master';
58
-            break;
59
-        default:
60
-            $role = 'worker';
61
-            break;
53
+            case $this->ownerPid === $pid:
54
+                $role = 'owner';
55
+                break;
56
+            case $this->masterPid === $pid:
57
+                $role = 'master';
58
+                break;
59
+            default:
60
+                $role = 'worker';
61
+                break;
62 62
         }
63 63
         fputs(
64 64
             $this->destination,
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   +3 added lines, -3 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,8 +52,8 @@  discard block
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/Snidel.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
         foreach ($this->signals as $sig) {
65 65
             $this->pcntl->signal(
66 66
                 $sig,
67
-                function ($sig) use($log, $self) {
68
-                    $log->info('received signal. signo: ' . $sig);
67
+                function($sig) use($log, $self) {
68
+                    $log->info('received signal. signo: '.$sig);
69 69
                     $self->setReceivedSignal($sig);
70 70
 
71 71
                     $log->info('--> sending a signal to children.');
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
             );
78 78
         }
79 79
 
80
-        $this->log->info('parent pid: ' . $this->ownerPid);
80
+        $this->log->info('parent pid: '.$this->ownerPid);
81 81
     }
82 82
 
83 83
     /**
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
             throw $e;
114 114
         }
115 115
 
116
-        $this->log->info('queued task #' . $this->forkContainer->queuedCount());
116
+        $this->log->info('queued task #'.$this->forkContainer->queuedCount());
117 117
     }
118 118
 
119 119
     /**
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 
141 141
         if (getmypid() === $this->ownerPid) {
142 142
             // parent
143
-            $this->log->info('created child process. pid: ' . $fork->getPid());
143
+            $this->log->info('created child process. pid: '.$fork->getPid());
144 144
         } else {
145 145
             // @codeCoverageIgnoreStart
146 146
             // child
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
              * in php5.3, we can not use $this in anonymous functions
153 153
              */
154 154
             $log = $this->log;
155
-            register_shutdown_function(function () use ($fork, $log, $token) {
155
+            register_shutdown_function(function() use ($fork, $log, $token) {
156 156
                 $dataRepository = new DataRepository();
157 157
                 $data = $dataRepository->load(getmypid());
158 158
                 try {
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
             $this->wait();
219 219
         }
220 220
         if (!$this->forkContainer->hasTag($tag)) {
221
-            throw new \InvalidArgumentException('unknown tag: ' . $tag);
221
+            throw new \InvalidArgumentException('unknown tag: '.$tag);
222 222
         }
223 223
 
224 224
         return $this->forkContainer->getCollection($tag);
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
     public function sendSignalToChildren($sig)
234 234
     {
235 235
         foreach ($this->forkContainer->getChildPids() as $pid) {
236
-            $this->log->info('----> sending a signal to child. pid: ' . $pid);
236
+            $this->log->info('----> sending a signal to child. pid: '.$pid);
237 237
             posix_kill($pid, $sig);
238 238
         }
239 239
     }
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 
338 338
             $childPid = $fork->getPid();
339 339
             if ($fork->hasNotFinishedSuccessfully()) {
340
-                $message = 'an error has occurred in child process. pid: ' . $childPid;
340
+                $message = 'an error has occurred in child process. pid: '.$childPid;
341 341
                 $this->log->error($message);
342 342
                 throw new \RuntimeException($message);
343 343
             }
Please login to merge, or discard this patch.
src/Snidel/ResultQueue.php 1 patch
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -8,6 +8,7 @@
 block discarded – undo
8 8
 {
9 9
     /**
10 10
      * @param   \Ackintosh\Snidel\Fork
11
+     * @param Fork $fork
11 12
      * @throws  \RuntimeException
12 13
      */
13 14
     public function enqueue($fork)
Please login to merge, or discard this patch.
src/Snidel/ForkContainer.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 
135 135
         if ($pid) {
136 136
             // owner
137
-            $this->log->info('pid: ' . getmypid());
137
+            $this->log->info('pid: '.getmypid());
138 138
 
139 139
             return $this->masterPid;
140 140
         } elseif ($pid === -1) {
@@ -142,14 +142,14 @@  discard block
 block discarded – undo
142 142
         } else {
143 143
             // master
144 144
             $taskQueue = new TaskQueue($this->ownerPid);
145
-            $this->log->info('pid: ' . $this->masterPid);
145
+            $this->log->info('pid: '.$this->masterPid);
146 146
 
147 147
             foreach ($this->signals as $sig) {
148 148
                 $this->pcntl->signal($sig, SIG_DFL, true);
149 149
             }
150 150
 
151 151
             while ($task = $taskQueue->dequeue()) {
152
-                $this->log->info('dequeued task #' . $taskQueue->dequeuedCount());
152
+                $this->log->info('dequeued task #'.$taskQueue->dequeuedCount());
153 153
                 if ($this->token->accept()) {
154 154
                     $this->forkWorker($task);
155 155
                 }
@@ -176,10 +176,10 @@  discard block
 block discarded – undo
176 176
 
177 177
         if (getmypid() === $this->masterPid) {
178 178
             // master
179
-            $this->log->info('forked worker. pid: ' . $fork->getPid());
179
+            $this->log->info('forked worker. pid: '.$fork->getPid());
180 180
         } else {
181 181
             // worker
182
-            $this->log->info('has forked. pid: ' . getmypid());
182
+            $this->log->info('has forked. pid: '.getmypid());
183 183
             // @codeCoverageIgnoreStart
184 184
 
185 185
             foreach ($this->signals as $sig) {
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
             }
188 188
 
189 189
             $resultQueue = new ResultQueue($this->ownerPid);
190
-            register_shutdown_function(function () use ($fork, $resultQueue) {
190
+            register_shutdown_function(function() use ($fork, $resultQueue) {
191 191
                 if ($fork->hasNoResult() || !$fork->isQueued()) {
192 192
                     $result = new Result();
193 193
                     $result->setFailure();
Please login to merge, or discard this patch.
src/Snidel/Fork.php 1 patch
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -130,6 +130,7 @@
 block discarded – undo
130 130
     /**
131 131
      *
132 132
      * @param   \Ackintosh\Snidel\Result
133
+     * @param Result $result
133 134
      * @return  void
134 135
      */
135 136
     public function setResult($result)
Please login to merge, or discard this patch.