Completed
Push — master ( d342b9...3a6611 )
by Kamil
03:10
created
src/SSH/Driver/Shell/ShellResource.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -274,9 +274,9 @@  discard block
 block discarded – undo
274 274
         $this->readable = false;
275 275
         $this->writable = false;
276 276
 
277
-        $this->emit('close', [ $this ]);
277
+        $this->emit('close', [$this]);
278 278
         $this->pause();
279
-        $this->emit('done', [ $this ]);
279
+        $this->emit('done', [$this]);
280 280
     }
281 281
 
282 282
     /**
@@ -334,11 +334,11 @@  discard block
 block discarded – undo
334 334
         }
335 335
         else if ($ret !== '')
336 336
         {
337
-            $this->emit('data', [ $this, $ret ]);
337
+            $this->emit('data', [$this, $ret]);
338 338
 
339 339
             if (strlen($ret) < $length)
340 340
             {
341
-                $this->emit('end', [ $this ]);
341
+                $this->emit('end', [$this]);
342 342
             }
343 343
         }
344 344
 
@@ -385,8 +385,8 @@  discard block
 block discarded – undo
385 385
         }
386 386
 
387 387
         $this->writable = false; // this is single-use stream only!
388
-        $this->emit('drain', [ $this ]);
389
-        $this->emit('finish', [ $this ]);
388
+        $this->emit('drain', [$this]);
389
+        $this->emit('finish', [$this]);
390 390
 
391 391
         return true;
392 392
     }
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
      */
401 401
     protected function throwAndEmitException($ex)
402 402
     {
403
-        $this->emit('error', [ $this, $ex ]);
403
+        $this->emit('error', [$this, $ex]);
404 404
         throw $ex;
405 405
     }
406 406
 }
Please login to merge, or discard this patch.
src/SSH/Driver/Sftp/SftpResource.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -194,9 +194,9 @@  discard block
 block discarded – undo
194 194
             $this->writeEnd();
195 195
         }
196 196
 
197
-        $this->emit('close', [ $this ]);
197
+        $this->emit('close', [$this]);
198 198
         $this->handleClose();
199
-        $this->emit('done', [ $this ]);
199
+        $this->emit('done', [$this]);
200 200
     }
201 201
 
202 202
     /**
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 
227 227
             if ($text !== '' && !$sent)
228 228
             {
229
-                $this->emit('error', [ $this, new WriteException('Error occurred while writing to the stream resource.') ]);
229
+                $this->emit('error', [$this, new WriteException('Error occurred while writing to the stream resource.')]);
230 230
                 return;
231 231
             }
232 232
 
@@ -234,21 +234,21 @@  discard block
 block discarded – undo
234 234
             $lenAfter = $lenBefore - $sent;
235 235
             $this->buffer->remove($sent);
236 236
 
237
-            $this->emit('drain', [ $this ]);
237
+            $this->emit('drain', [$this]);
238 238
 
239 239
             if ($lenAfter === 0 && $this->buffer->isEmpty())
240 240
             {
241 241
                 $this->writing = false;
242
-                $this->emit('finish', [ $this ]);
242
+                $this->emit('finish', [$this]);
243 243
             }
244 244
         }
245 245
         catch (Error $ex)
246 246
         {
247
-            $this->emit('error', [ $this, $ex ]);
247
+            $this->emit('error', [$this, $ex]);
248 248
         }
249 249
         catch (Exception $ex)
250 250
         {
251
-            $this->emit('error', [ $this, $ex ]);
251
+            $this->emit('error', [$this, $ex]);
252 252
         }
253 253
     }
254 254
 
@@ -271,28 +271,28 @@  discard block
 block discarded – undo
271 271
 
272 272
             if ($ret === false)
273 273
             {
274
-                $this->emit('error', [ $this, new ReadException('Error occurred while reading from the stream resource.') ]);
274
+                $this->emit('error', [$this, new ReadException('Error occurred while reading from the stream resource.')]);
275 275
                 return;
276 276
             }
277 277
 
278 278
             if ($ret !== '')
279 279
             {
280
-                $this->emit('data', [ $this, $ret ]);
280
+                $this->emit('data', [$this, $ret]);
281 281
 
282 282
                 if (strlen($ret) < $length)
283 283
                 {
284 284
                     $this->reading = false;
285
-                    $this->emit('end', [ $this ]);
285
+                    $this->emit('end', [$this]);
286 286
                 }
287 287
             }
288 288
         }
289 289
         catch (Error $ex)
290 290
         {
291
-            $this->emit('error', [ $this, $ex ]);
291
+            $this->emit('error', [$this, $ex]);
292 292
         }
293 293
         catch (Exception $ex)
294 294
         {
295
-            $this->emit('error', [ $this, $ex ]);
295
+            $this->emit('error', [$this, $ex]);
296 296
         }
297 297
     }
298 298
 
Please login to merge, or discard this patch.
src/SSH/Driver/Sftp.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -134,13 +134,13 @@  discard block
 block discarded – undo
134 134
 
135 135
         if (!$resource || !is_resource($resource))
136 136
         {
137
-            $this->emit('error', [ $this, new ExecutionException('SSH2:Sftp could not be connected.') ]);
137
+            $this->emit('error', [$this, new ExecutionException('SSH2:Sftp could not be connected.')]);
138 138
             return;
139 139
         }
140 140
 
141 141
         $this->resource = $resource;
142 142
 
143
-        $this->emit('connect', [ $this ]);
143
+        $this->emit('connect', [$this]);
144 144
     }
145 145
 
146 146
     /**
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
         }
163 163
 
164 164
         $this->handleDisconnect();
165
-        $this->emit('disconnect', [ $this ]);
165
+        $this->emit('disconnect', [$this]);
166 166
     }
167 167
 
168 168
     /**
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 
205 205
             if ($this->timer === null)
206 206
             {
207
-                $this->timer = $this->loop->addPeriodicTimer($this->interval, [ $this, 'handleHeartbeat' ]);
207
+                $this->timer = $this->loop->addPeriodicTimer($this->interval, [$this, 'handleHeartbeat']);
208 208
             }
209 209
         }
210 210
     }
@@ -238,11 +238,11 @@  discard block
 block discarded – undo
238 238
 
239 239
         $resource = new SftpResource($this, $stream);
240 240
         $resource->on('open', function(SSH2ResourceInterface $resource) {
241
-            $this->emit('resource:open', [ $this, $resource ]);
241
+            $this->emit('resource:open', [$this, $resource]);
242 242
         });
243 243
         $resource->on('close', function(SSH2ResourceInterface $resource) {
244 244
             $this->removeResource($resource->getId());
245
-            $this->emit('resource:close', [ $this, $resource ]);
245
+            $this->emit('resource:close', [$this, $resource]);
246 246
         });
247 247
 
248 248
         $this->resources[$resource->getId()] = $resource;
Please login to merge, or discard this patch.
src/SSH/Driver/Shell.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -131,13 +131,13 @@  discard block
 block discarded – undo
131 131
 
132 132
         if (!$shell || !is_resource($shell))
133 133
         {
134
-            $this->emit('error', [ $this, new ExecutionException('SSH2:Shell could not be connected.') ]);
134
+            $this->emit('error', [$this, new ExecutionException('SSH2:Shell could not be connected.')]);
135 135
             return;
136 136
         }
137 137
 
138 138
         $this->resource = $shell;
139 139
 
140
-        $this->emit('connect', [ $this ]);
140
+        $this->emit('connect', [$this]);
141 141
     }
142 142
 
143 143
     /**
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
         }
160 160
 
161 161
         $this->handleDisconnect();
162
-        $this->emit('disconnect', [ $this ]);
162
+        $this->emit('disconnect', [$this]);
163 163
     }
164 164
 
165 165
     /**
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 
202 202
             if ($this->timer === null)
203 203
             {
204
-                $this->timer = $this->loop->addPeriodicTimer($this->interval, [ $this, 'handleHeartbeat' ]);
204
+                $this->timer = $this->loop->addPeriodicTimer($this->interval, [$this, 'handleHeartbeat']);
205 205
             }
206 206
         }
207 207
     }
@@ -228,11 +228,11 @@  discard block
 block discarded – undo
228 228
 
229 229
         $resource = new ShellResource($this, $this->resource);
230 230
         $resource->on('open', function(SSH2ResourceInterface $resource) {
231
-            $this->emit('resource:open', [ $this, $resource ]);
231
+            $this->emit('resource:open', [$this, $resource]);
232 232
         });
233 233
         $resource->on('close', function(SSH2ResourceInterface $resource) {
234 234
             $this->removeResource($resource->getId());
235
-            $this->emit('resource:close', [ $this, $resource ]);
235
+            $this->emit('resource:close', [$this, $resource]);
236 236
         });
237 237
 
238 238
         $this->resources[$resource->getId()] = $resource;
@@ -328,19 +328,19 @@  discard block
 block discarded – undo
328 328
 
329 329
             foreach ($parts as &$part)
330 330
             {
331
-                $resource->emit('data', [ $resource, $part ]);
331
+                $resource->emit('data', [$resource, $part]);
332 332
             }
333 333
             unset($parts);
334 334
             unset($part);
335 335
 
336 336
             if ($status === 0)
337 337
             {
338
-                $resource->emit('end', [ $resource ]);
338
+                $resource->emit('end', [$resource]);
339 339
                 $resource->close();
340 340
             }
341 341
             else if ($status > 0)
342 342
             {
343
-                $resource->emit('error', [ $resource, new ReadException($status) ]);
343
+                $resource->emit('error', [$resource, new ReadException($status)]);
344 344
                 $resource->close();
345 345
             }
346 346
         }
Please login to merge, or discard this patch.
src/SSH/SSH2.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -107,17 +107,17 @@  discard block
 block discarded – undo
107 107
 
108 108
         if (!$this->conn || !is_resource($this->conn))
109 109
         {
110
-            $this->emit('error', [ $this, new ExecutionException('SSH2 connection could not be established.') ]);
110
+            $this->emit('error', [$this, new ExecutionException('SSH2 connection could not be established.')]);
111 111
             return;
112 112
         }
113 113
 
114 114
         if (!$this->auth->authenticate($this->conn))
115 115
         {
116
-            $this->emit('error', [ $this, new ExecutionException('SSH2 connection could not be authenticated.') ]);
116
+            $this->emit('error', [$this, new ExecutionException('SSH2 connection could not be authenticated.')]);
117 117
             return;
118 118
         }
119 119
 
120
-        $this->emit('connect', [ $this ]);
120
+        $this->emit('connect', [$this]);
121 121
     }
122 122
 
123 123
     /**
@@ -138,15 +138,15 @@  discard block
 block discarded – undo
138 138
 
139 139
         foreach ($this->drivers as $driver)
140 140
         {
141
-            $driver->removeListener('connect', [ $this, 'handleConnect' ]);
142
-            $driver->removeListener('disconnect', [ $this, 'handleDisconnect' ]);
143
-            $driver->removeListener('error', [ $this, 'handleError' ]);
141
+            $driver->removeListener('connect', [$this, 'handleConnect']);
142
+            $driver->removeListener('disconnect', [$this, 'handleDisconnect']);
143
+            $driver->removeListener('error', [$this, 'handleError']);
144 144
         }
145 145
 
146 146
         $this->conn = null;
147 147
         $this->drivers = [];
148 148
 
149
-        $this->emit('disconnect', [ $this ]);
149
+        $this->emit('disconnect', [$this]);
150 150
     }
151 151
 
152 152
     /**
@@ -188,9 +188,9 @@  discard block
 block discarded – undo
188 188
                 throw new InvalidArgumentException("The driver [$name] is not supported.");
189 189
         }
190 190
 
191
-        $driver->on('connect', [ $this, 'handleConnect' ]);
192
-        $driver->on('disconnect', [ $this, 'handleDisconnect' ]);
193
-        $driver->on('error', [ $this, 'handleError' ]);
191
+        $driver->on('connect', [$this, 'handleConnect']);
192
+        $driver->on('disconnect', [$this, 'handleDisconnect']);
193
+        $driver->on('error', [$this, 'handleError']);
194 194
 
195 195
         $this->drivers[$name] = $driver;
196 196
 
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
      */
204 204
     public function handleConnect(SSH2DriverInterface $driver)
205 205
     {
206
-        $this->emit('connect:' . $driver->getName(), [ $driver ]);
206
+        $this->emit('connect:' . $driver->getName(), [$driver]);
207 207
     }
208 208
 
209 209
     /**
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
      */
213 213
     public function handleDisconnect(SSH2DriverInterface $driver)
214 214
     {
215
-        $this->emit('disconnect:' . $driver->getName(), [ $driver ]);
215
+        $this->emit('disconnect:' . $driver->getName(), [$driver]);
216 216
     }
217 217
 
218 218
     /**
@@ -222,8 +222,8 @@  discard block
 block discarded – undo
222 222
      */
223 223
     public function handleError(SSH2DriverInterface $driver, $ex)
224 224
     {
225
-        $this->emit('error:' . $driver->getName(), [ $driver, $ex ]);
226
-        $this->emit('error', [ $this, $ex ]);
225
+        $this->emit('error:' . $driver->getName(), [$driver, $ex]);
226
+        $this->emit('error', [$this, $ex]);
227 227
     }
228 228
 
229 229
     /**
Please login to merge, or discard this patch.
example/sftp_async_write.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@
 block discarded – undo
59 59
 $ssh2->on('connect', function(SSH2Interface $ssh2) {
60 60
     echo "# CONNECTED\n";
61 61
     $ssh2->createDriver(SSH2::DRIVER_SFTP)
62
-         ->connect();
62
+            ->connect();
63 63
 });
64 64
 
65 65
 $ssh2->on('disconnect', function(SSH2Interface $ssh2) use($loop) {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@
 block discarded – undo
30 30
 $ssh2->on('connect:sftp', function(SSH2DriverInterface $sftp) use($loop, $ssh2) {
31 31
     echo "# CONNECTED SFTP\n";
32 32
 
33
-    $lines = [ "DAZZLE\n", "IS\n", "AWESOME!\n" ];
33
+    $lines = ["DAZZLE\n", "IS\n", "AWESOME!\n"];
34 34
     $linesPointer = 0;
35 35
 
36 36
     $file = $sftp->open(__DIR__ . '/_file_write.txt', 'w+');
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,7 +37,8 @@
 block discarded – undo
37 37
     $file->write();
38 38
     $file->on('drain', function(SSH2ResourceInterface $file) use(&$lines, &$linesPointer) {
39 39
         echo "# PART OF THE DATA HAS BEEN WRITTEN\n";
40
-        if ($linesPointer < count($lines)) {
40
+        if ($linesPointer < count($lines))
41
+        {
41 42
             $file->write($lines[$linesPointer++]);
42 43
         }
43 44
     });
Please login to merge, or discard this patch.
example/ssh_async_multi_command.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@
 block discarded – undo
67 67
 $ssh2->on('connect', function(SSH2Interface $ssh2) {
68 68
     echo "# CONNECTED\n";
69 69
     $ssh2->createDriver(SSH2::DRIVER_SHELL)
70
-         ->connect();
70
+            ->connect();
71 71
 });
72 72
 
73 73
 $ssh2->on('disconnect', function(SSH2Interface $ssh2) use($loop) {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@
 block discarded – undo
45 45
 $ssh2->on('connect:shell', function(SSH2DriverInterface $shell) use($ssh2, $loop) {
46 46
     echo "# CONNECTED SHELL\n";
47 47
 
48
-    $commands = [ 'ls -la', 'pwd' ];
48
+    $commands = ['ls -la', 'pwd'];
49 49
     $commandsRemain = count($commands);
50 50
 
51 51
     $shell->on('resource:close', function(SSH2DriverInterface $shell) use(&$commandsRemain) {
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -19,7 +19,8 @@  discard block
 block discarded – undo
19 19
 use Dazzle\SSH\SSH2Interface;
20 20
 use Dazzle\SSH\SSH2ResourceInterface;
21 21
 
22
-function executeCommand(SSH2DriverInterface $shell, $shellCommand) {
22
+function executeCommand(SSH2DriverInterface $shell, $shellCommand)
23
+{
23 24
 
24 25
     $buffer = '';
25 26
     $command = $shell->open();
@@ -49,12 +50,14 @@  discard block
 block discarded – undo
49 50
     $commandsRemain = count($commands);
50 51
 
51 52
     $shell->on('resource:close', function(SSH2DriverInterface $shell) use(&$commandsRemain) {
52
-        if (--$commandsRemain === 0) {
53
+        if (--$commandsRemain === 0)
54
+        {
53 55
             $shell->disconnect();
54 56
         }
55 57
     });
56 58
 
57
-    foreach ($commands as $command) {
59
+    foreach ($commands as $command)
60
+    {
58 61
         executeCommand($shell, $command);
59 62
     }
60 63
 });
Please login to merge, or discard this patch.
example/ssh_async_single_command.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@
 block discarded – undo
67 67
 $ssh2->on('connect', function(SSH2Interface $ssh2) {
68 68
     echo "# CONNECTED\n";
69 69
     $ssh2->createDriver(SSH2::DRIVER_SHELL)
70
-         ->connect();
70
+            ->connect();
71 71
 });
72 72
 
73 73
 $ssh2->on('disconnect', function(SSH2Interface $ssh2) use($loop) {
Please login to merge, or discard this patch.
example/sftp_async_read.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@
 block discarded – undo
59 59
 $ssh2->on('connect', function(SSH2Interface $ssh2) {
60 60
     echo "# CONNECTED\n";
61 61
     $ssh2->createDriver(SSH2::DRIVER_SFTP)
62
-         ->connect();
62
+            ->connect();
63 63
 });
64 64
 
65 65
 $ssh2->on('disconnect', function(SSH2Interface $ssh2) use($loop) {
Please login to merge, or discard this patch.