Passed
Push — 0.1.x ( 46203b...52c1e4 )
by f
02:32
created
src/CamApplication.php 1 patch
Braces   +51 added lines, -34 removed lines patch added patch discarded remove patch
@@ -12,12 +12,14 @@  discard block
 block discarded – undo
12 12
      */
13 13
     protected function open($file)
14 14
     {
15
-        if (!UnifiedArchive::canOpenArchive($file))
16
-            throw new Exception('Could not open archive '.$file.'. Try installing suggested packages or run `cam -f` to see formats support.');
15
+        if (!UnifiedArchive::canOpenArchive($file)) {
16
+                    throw new Exception('Could not open archive '.$file.'. Try installing suggested packages or run `cam -f` to see formats support.');
17
+        }
17 18
 
18 19
         $archive = UnifiedArchive::open($file);
19
-        if ($archive === null)
20
-            throw new Exception('Could not open archive '.$file);
20
+        if ($archive === null) {
21
+                    throw new Exception('Could not open archive '.$file);
22
+        }
21 23
 
22 24
         return $archive;
23 25
     }
@@ -135,17 +137,18 @@  discard block
 block discarded – undo
135 137
      */
136 138
     public function formatDate($unixtime)
137 139
     {
138
-        if (strtotime('today') < $unixtime)
139
-            return 'Today, '.date('G:m', $unixtime);
140
-        else if (strtotime('yesterday') < $unixtime)
141
-            return 'Yesterday, '.date('G:m', $unixtime);
142
-        else {
140
+        if (strtotime('today') < $unixtime) {
141
+                    return 'Today, '.date('G:m', $unixtime);
142
+        } else if (strtotime('yesterday') < $unixtime) {
143
+                    return 'Yesterday, '.date('G:m', $unixtime);
144
+        } else {
143 145
             $datetime = new \DateTime();
144 146
             $datetime->setTimestamp($unixtime);
145
-            if ($datetime->format('Y') == date('Y'))
146
-                return $datetime->format('d M, G:m');
147
-            else
148
-                return $datetime->format('d M Y, G:m');
147
+            if ($datetime->format('Y') == date('Y')) {
148
+                            return $datetime->format('d M, G:m');
149
+            } else {
150
+                            return $datetime->format('d M Y, G:m');
151
+            }
149 152
         }
150 153
     }
151 154
 
@@ -175,25 +178,36 @@  discard block
 block discarded – undo
175 178
         $archive = $this->open($args['ARCHIVE']);
176 179
         $output = getcwd();
177 180
         if (isset($args['--output'])) {
178
-            if (!is_dir($args['--output']))
179
-                mkdir($args['--output']);
181
+            if (!is_dir($args['--output'])) {
182
+                            mkdir($args['--output']);
183
+            }
180 184
             $output = realpath($args['--output']);
181 185
         }
182 186
 
183 187
         if (empty($args['FILES_IN_ARCHIVE']) || $args['FILES_IN_ARCHIVE'] == array('/') || $args['FILES_IN_ARCHIVE'] == array('*')) {
184 188
             $result = $archive->extractFiles($output);
185
-            if ($result === false) echo 'Error occured'.PHP_EOL;
186
-            else echo 'Extracted '.$result.' file(s) to '.$output.PHP_EOL;
189
+            if ($result === false) {
190
+             echo 'Error occured'.PHP_EOL;
191
+            } else {
192
+             echo 'Extracted '.$result.' file(s) to '.$output.PHP_EOL;
193
+            }
187 194
         } else {
188 195
             $extracted = 0;
189 196
             $errored = [];
190 197
             foreach ($args['FILES_IN_ARCHIVE'] as $file) {
191 198
                 $result = $archive->extractFiles($output, $file);
192
-                if ($result === false) $errored[] = $file;
193
-                else $extracted += $result;
199
+                if ($result === false) {
200
+                 $errored[] = $file;
201
+                } else {
202
+                 $extracted += $result;
203
+                }
204
+            }
205
+            if (!empty($errored)) {
206
+             echo 'Errored: '.implode(', ', $errored).PHP_EOL;
207
+            }
208
+            if ($extracted > 0) {
209
+             echo 'Exctracted '.$extracted.' file(s) to '.$output.PHP_EOL;
194 210
             }
195
-            if (!empty($errored)) echo 'Errored: '.implode(', ', $errored).PHP_EOL;
196
-            if ($extracted > 0) echo 'Exctracted '.$extracted.' file(s) to '.$output.PHP_EOL;
197 211
         }
198 212
     }
199 213
 
@@ -252,8 +266,9 @@  discard block
 block discarded – undo
252 266
                 echo 'File '.$file.' is NOT in archive'.PHP_EOL;
253 267
                 continue;
254 268
             }
255
-            if ($archive->deleteFiles($file) === false)
256
-                echo 'Error file '.$file.PHP_EOL;
269
+            if ($archive->deleteFiles($file) === false) {
270
+                            echo 'Error file '.$file.PHP_EOL;
271
+            }
257 272
         }
258 273
     }
259 274
 
@@ -266,10 +281,11 @@  discard block
 block discarded – undo
266 281
     {
267 282
         $archive = $this->open($args['ARCHIVE']);
268 283
         $added_files = $archive->addFiles($args['FILES_ON_DISK']);
269
-        if ($added_files === false)
270
-            echo 'Error'.PHP_EOL;
271
-        else
272
-            echo 'Added '.$added_files.' file(s)'.PHP_EOL;
284
+        if ($added_files === false) {
285
+                    echo 'Error'.PHP_EOL;
286
+        } else {
287
+                    echo 'Added '.$added_files.' file(s)'.PHP_EOL;
288
+        }
273 289
     }
274 290
 
275 291
     /**
@@ -279,17 +295,18 @@  discard block
 block discarded – undo
279 295
     public function create($args)
280 296
     {
281 297
         if (file_exists($args['ARCHIVE'])) {
282
-            if (is_dir($args['ARCHIVE']))
283
-                echo $args['ARCHIVE'].' is a directory!'.PHP_EOL;
284
-            else {
298
+            if (is_dir($args['ARCHIVE'])) {
299
+                            echo $args['ARCHIVE'].' is a directory!'.PHP_EOL;
300
+            } else {
285 301
                 echo 'File '.$args['ARCHIVE'].' already exists!'.PHP_EOL;
286 302
             }
287 303
         } else {
288 304
             $archived_files = UnifiedArchive::archiveFiles($args['FILES_ON_DISK'], $args['ARCHIVE']);
289
-            if ($archived_files === false)
290
-                echo 'Error'.PHP_EOL;
291
-            else
292
-                echo 'Created archive ' . $args['ARCHIVE'] . ' with ' . $archived_files . ' file(s) of total size ' . implode('', $this->formatSize(filesize($args['ARCHIVE']))) . PHP_EOL;
305
+            if ($archived_files === false) {
306
+                            echo 'Error'.PHP_EOL;
307
+            } else {
308
+                            echo 'Created archive ' . $args['ARCHIVE'] . ' with ' . $archived_files . ' file(s) of total size ' . implode('', $this->formatSize(filesize($args['ARCHIVE']))) . PHP_EOL;
309
+            }
293 310
         }
294 311
     }
295 312
 }
Please login to merge, or discard this patch.
src/ArchiveEntry.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -63,8 +63,9 @@
 block discarded – undo
63 63
         $this->compressed_size = $this->compressedSize = $compressedSize;
64 64
         $this->uncompressed_size = $this->uncompressedSize = $uncompressedSize;
65 65
         $this->mtime = $this->modificationTime = $modificationTime;
66
-        if ($isCompressed === null)
67
-            $isCompressed = $uncompressedSize !== $compressedSize;
66
+        if ($isCompressed === null) {
67
+                    $isCompressed = $uncompressedSize !== $compressedSize;
68
+        }
68 69
         $this->is_compressed = $this->isCompressed = $isCompressed;
69 70
     }
70 71
 }
71 72
\ No newline at end of file
Please login to merge, or discard this patch.
src/Formats/OneFileFormat.php 1 patch
Braces   +19 added lines, -10 removed lines patch added patch discarded remove patch
@@ -25,8 +25,9 @@  discard block
 block discarded – undo
25 25
      */
26 26
     public function __construct($archiveFileName)
27 27
     {
28
-        if (static::FORMAT_SUFFIX === null)
29
-            throw new \Exception('Format should be initialized');
28
+        if (static::FORMAT_SUFFIX === null) {
29
+                    throw new \Exception('Format should be initialized');
30
+        }
30 31
         $this->fileName = $archiveFileName;
31 32
         $this->inArchiveFileName = basename($archiveFileName, '.'.self::FORMAT_SUFFIX);
32 33
     }
@@ -93,11 +94,13 @@  discard block
 block discarded – undo
93 94
     public function extractArchive($outputFolder)
94 95
     {
95 96
         $data = $this->getFileContent($this->inArchiveFileName);
96
-        if ($data === false)
97
-            throw new Exception('Could not extract archive');
97
+        if ($data === false) {
98
+                    throw new Exception('Could not extract archive');
99
+        }
98 100
 
99
-        if (file_put_contents($outputFolder.$this->inArchiveFileName, $data) !== false)
100
-            return 1;
101
+        if (file_put_contents($outputFolder.$this->inArchiveFileName, $data) !== false) {
102
+                    return 1;
103
+        }
101 104
     }
102 105
 
103 106
     /**
@@ -130,12 +133,18 @@  discard block
 block discarded – undo
130 133
      * @throws \wapmorgan\UnifiedArchive\UnsupportedOperationException
131 134
      */
132 135
     public static function createArchive(array $files, $archiveFileName){
133
-        if (count($files) > 1) return false;
136
+        if (count($files) > 1) {
137
+         return false;
138
+        }
134 139
         $filename = array_shift($files);
135
-        if (is_null($filename)) return false; // invalid list
140
+        if (is_null($filename)) {
141
+         return false;
142
+        }
143
+        // invalid list
136 144
         if (file_put_contents($archiveFileName,
137
-                static::compressData(file_get_contents($filename))) !== false)
138
-            return 1;
145
+                static::compressData(file_get_contents($filename))) !== false) {
146
+                    return 1;
147
+        }
139 148
     }
140 149
 
141 150
     /**
Please login to merge, or discard this patch.
src/Formats/SevenZip.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -47,8 +47,9 @@
 block discarded – undo
47 47
     public function getFileNames()
48 48
     {
49 49
         $files = [];
50
-        foreach ($this->sevenZip->getEntries() as $entry)
51
-            $files[] = $entry->getPath();
50
+        foreach ($this->sevenZip->getEntries() as $entry) {
51
+                    $files[] = $entry->getPath();
52
+        }
52 53
         return $files;
53 54
     }
54 55
 
Please login to merge, or discard this patch.
src/Formats/Rar.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -101,7 +101,9 @@  discard block
 block discarded – undo
101 101
     public function getFileContent($fileName)
102 102
     {
103 103
         $entry = $this->rar->getEntry($fileName);
104
-        if ($entry->isDirectory()) return false;
104
+        if ($entry->isDirectory()) {
105
+         return false;
106
+        }
105 107
         return stream_get_contents($entry->getStream());
106 108
     }
107 109
 
@@ -113,7 +115,9 @@  discard block
 block discarded – undo
113 115
     public function getFileResource($fileName)
114 116
     {
115 117
         $entry = $this->rar->getEntry($fileName);
116
-        if ($entry->isDirectory()) return false;
118
+        if ($entry->isDirectory()) {
119
+         return false;
120
+        }
117 121
         return $entry->getStream();
118 122
     }
119 123
 
Please login to merge, or discard this patch.
src/Formats/Tar.php 1 patch
Braces   +50 added lines, -34 removed lines patch added patch discarded remove patch
@@ -141,11 +141,13 @@  discard block
 block discarded – undo
141 141
     {
142 142
         static::checkRequirements();
143 143
 
144
-        if (static::$enabledPharData)
145
-            return static::createArchiveForPhar($files, $archiveFileName);
144
+        if (static::$enabledPharData) {
145
+                    return static::createArchiveForPhar($files, $archiveFileName);
146
+        }
146 147
 
147
-        if (static::$enabledPearTar)
148
-            return static::createArchiveForPear($files, $archiveFileName);
148
+        if (static::$enabledPearTar) {
149
+                    return static::createArchiveForPear($files, $archiveFileName);
150
+        }
149 151
 
150 152
         throw new Exception('Archive_Tar nor PharData not available');
151 153
     }
@@ -177,21 +179,24 @@  discard block
 block discarded – undo
177 179
                 break;
178 180
         }
179 181
 
180
-        if (isset($tar_aname))
181
-            $tar = new Archive_Tar($tar_aname, $compression);
182
-        else
183
-            $tar = new Archive_Tar($archiveFileName, $compression);
182
+        if (isset($tar_aname)) {
183
+                    $tar = new Archive_Tar($tar_aname, $compression);
184
+        } else {
185
+                    $tar = new Archive_Tar($archiveFileName, $compression);
186
+        }
184 187
 
185 188
         foreach ($files  as $localName => $filename) {
186 189
             $remove_dir = dirname($filename);
187 190
             $add_dir = dirname($localName);
188 191
 
189 192
             if (is_null($filename)) {
190
-                if ($tar->addString($localName, '') === false)
191
-                    throw new Exception('Error when adding directory '.$localName.' to archive');
193
+                if ($tar->addString($localName, '') === false) {
194
+                                    throw new Exception('Error when adding directory '.$localName.' to archive');
195
+                }
192 196
             } else {
193
-                if ($tar->addModify($filename, $add_dir, $remove_dir) === false)
194
-                    throw new Exception('Error when adding file '.$filename.' to archive');
197
+                if ($tar->addModify($filename, $add_dir, $remove_dir) === false) {
198
+                                    throw new Exception('Error when adding file '.$filename.' to archive');
199
+                }
195 200
             }
196 201
         }
197 202
         $tar = null;
@@ -279,8 +284,9 @@  discard block
 block discarded – undo
279 284
 
280 285
         $this->archiveFileName = realpath($archiveFileName);
281 286
         $this->archiveType = static::detectArchiveType($this->archiveFileName);
282
-        if ($this->archiveType === false)
283
-            throw new \Exception('Could not detect type for archive '.$this->archiveFileName);
287
+        if ($this->archiveType === false) {
288
+                    throw new \Exception('Could not detect type for archive '.$this->archiveFileName);
289
+        }
284 290
         $this->open($this->archiveType);
285 291
     }
286 292
 
@@ -392,8 +398,9 @@  discard block
 block discarded – undo
392 398
      */
393 399
     public function isFileExists($fileName)
394 400
     {
395
-        if ($this->tar instanceof Archive_Tar)
396
-            return isset($this->pearFilesIndex[$fileName]);
401
+        if ($this->tar instanceof Archive_Tar) {
402
+                    return isset($this->pearFilesIndex[$fileName]);
403
+        }
397 404
 
398 405
         try {
399 406
             $this->tar->offsetGet($fileName);
@@ -411,14 +418,16 @@  discard block
 block discarded – undo
411 418
     public function getFileData($fileName)
412 419
     {
413 420
         if ($this->tar instanceof Archive_Tar) {
414
-            if (!isset($this->pearFilesIndex[$fileName]))
415
-                throw new Exception('File '.$fileName.' is not found in archive files list');
421
+            if (!isset($this->pearFilesIndex[$fileName])) {
422
+                            throw new Exception('File '.$fileName.' is not found in archive files list');
423
+            }
416 424
 
417 425
             $index = $this->pearFilesIndex[$fileName];
418 426
 
419 427
             $files_list = $this->tar->listContent();
420
-            if (!isset($files_list[$index]))
421
-                throw new Exception('File '.$fileName.' is not found in Tar archive');
428
+            if (!isset($files_list[$index])) {
429
+                            throw new Exception('File '.$fileName.' is not found in Tar archive');
430
+            }
422 431
 
423 432
             $data = $files_list[$index];
424 433
             unset($files_list);
@@ -442,8 +451,9 @@  discard block
 block discarded – undo
442 451
     public function getFileContent($fileName)
443 452
     {
444 453
         if ($this->tar instanceof Archive_Tar) {
445
-            if (!isset($this->pearFilesIndex[$fileName]))
446
-                throw new Exception('File '.$fileName.' is not found in archive files list');
454
+            if (!isset($this->pearFilesIndex[$fileName])) {
455
+                            throw new Exception('File '.$fileName.' is not found in archive files list');
456
+            }
447 457
 
448 458
             return $this->tar->extractInString($fileName);
449 459
         }
@@ -460,12 +470,14 @@  discard block
 block discarded – undo
460 470
     {
461 471
         $resource = fopen('php://temp', 'r+');
462 472
         if ($this->tar instanceof Archive_Tar) {
463
-            if (!isset($this->pearFilesIndex[$fileName]))
464
-                throw new Exception('File '.$fileName.' is not found in archive files list');
473
+            if (!isset($this->pearFilesIndex[$fileName])) {
474
+                            throw new Exception('File '.$fileName.' is not found in archive files list');
475
+            }
465 476
 
466 477
             fwrite($resource, $this->tar->extractInString($fileName));
467
-        } else
468
-            fwrite($resource, $this->tar->offsetGet($fileName)->getContent());
478
+        } else {
479
+                    fwrite($resource, $this->tar->offsetGet($fileName)->getContent());
480
+        }
469 481
 
470 482
         rewind($resource);
471 483
         return $resource;
@@ -520,14 +532,16 @@  discard block
 block discarded – undo
520 532
      */
521 533
     public function deleteFiles(array $files)
522 534
     {
523
-        if ($this->tar instanceof Archive_Tar)
524
-            throw new UnsupportedOperationException();
535
+        if ($this->tar instanceof Archive_Tar) {
536
+                    throw new UnsupportedOperationException();
537
+        }
525 538
 
526 539
         $deleted = 0;
527 540
 
528 541
         foreach ($files as $i => $file) {
529
-            if ($this->tar->delete($file))
530
-                $deleted++;
542
+            if ($this->tar->delete($file)) {
543
+                            $deleted++;
544
+            }
531 545
         }
532 546
 
533 547
         $this->tar = null;
@@ -550,11 +564,13 @@  discard block
 block discarded – undo
550 564
                 $remove_dir = dirname($filename);
551 565
                 $add_dir = dirname($localName);
552 566
                 if (is_null($filename)) {
553
-                    if ($this->tar->addString($localName, "") === false)
554
-                        return false;
567
+                    if ($this->tar->addString($localName, "") === false) {
568
+                                            return false;
569
+                    }
555 570
                 } else {
556
-                    if ($this->tar->addModify($filename, $add_dir, $remove_dir) === false)
557
-                        return false;
571
+                    if ($this->tar->addModify($filename, $add_dir, $remove_dir) === false) {
572
+                                            return false;
573
+                    }
558 574
                     $added++;
559 575
                 }
560 576
             }
Please login to merge, or discard this patch.
src/LzwStreamWrapper.php 1 patch
Braces   +24 added lines, -15 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
11 11
      */
12 12
     public static function registerWrapper()
13 13
     {
14
-        if (!self::$registered)
15
-            stream_wrapper_register('compress.lzw', __CLASS__);
14
+        if (!self::$registered) {
15
+                    stream_wrapper_register('compress.lzw', __CLASS__);
16
+        }
16 17
         self::$registered = true;
17 18
     }
18 19
 
@@ -43,12 +44,14 @@  discard block
 block discarded – undo
43 44
     {
44 45
         // check for compress & uncompress utility
45 46
         $this->checkBinary();
46
-        if (self::$installed === false)
47
-            throw new \Exception('compress and uncompress commands are required');
47
+        if (self::$installed === false) {
48
+                    throw new \Exception('compress and uncompress commands are required');
49
+        }
48 50
 
49 51
         $schema = 'compress.lzw://';
50
-        if (strncasecmp($schema, $path, strlen($schema)) == 0)
51
-            $path = substr($path, strlen($schema));
52
+        if (strncasecmp($schema, $path, strlen($schema)) == 0) {
53
+                    $path = substr($path, strlen($schema));
54
+        }
52 55
 
53 56
         if (file_exists($path)) {
54 57
             $this->path = realpath($path);
@@ -62,14 +65,16 @@  discard block
 block discarded – undo
62 65
                 $this->read();
63 66
             } else {
64 67
                 $prefix = basename(__FILE__, '.php');
65
-                if (($tmp = tempnam(sys_get_temp_dir(), $prefix)) === false)
66
-                    throw new \Exception(__CLASS__.', line '.__LINE__.
68
+                if (($tmp = tempnam(sys_get_temp_dir(), $prefix)) === false) {
69
+                                    throw new \Exception(__CLASS__.', line '.__LINE__.
67 70
                         ': Could not create temporary file in '.
68 71
                         sys_get_temp_dir());
69
-                if (($tmp2 = tempnam(sys_get_temp_dir(), $prefix)) === false)
70
-                    throw new \Exception(__CLASS__.', line '.__LINE__.
72
+                }
73
+                if (($tmp2 = tempnam(sys_get_temp_dir(), $prefix)) === false) {
74
+                                    throw new \Exception(__CLASS__.', line '.__LINE__.
71 75
                         ': Could not create temporary file in '.
72 76
                         sys_get_temp_dir());
77
+                }
73 78
                 $this->tmp = $tmp;
74 79
                 $this->tmp2 = $tmp2;
75 80
                 $this->read();
@@ -78,14 +83,16 @@  discard block
 block discarded – undo
78 83
             $this->path = $path;
79 84
             if (self::$forceTmpFile) {
80 85
                 $prefix = basename(__FILE__, '.php');
81
-                if (($tmp = tempnam(sys_get_temp_dir(), $prefix)) === false)
82
-                    throw new \Exception(__CLASS__.', line '.__LINE__.
86
+                if (($tmp = tempnam(sys_get_temp_dir(), $prefix)) === false) {
87
+                                    throw new \Exception(__CLASS__.', line '.__LINE__.
83 88
                         ': Could not create temporary file in '.
84 89
                         sys_get_temp_dir());
85
-                if (($tmp2 = tempnam(sys_get_temp_dir(), $prefix)) === false)
86
-                    throw new \Exception(__CLASS__.', line '.__LINE__.
90
+                }
91
+                if (($tmp2 = tempnam(sys_get_temp_dir(), $prefix)) === false) {
92
+                                    throw new \Exception(__CLASS__.', line '.__LINE__.
87 93
                         ': Could not create temporary file in '.
88 94
                         sys_get_temp_dir());
95
+                }
89 96
                 $this->tmp = $tmp;
90 97
                 $this->tmp2 = $tmp2;
91 98
                 $this->pointer = 0;
@@ -266,7 +273,9 @@  discard block
 block discarded – undo
266 273
         }
267 274
         if ($this->tmp !== null) {
268 275
             unlink($this->tmp);
269
-            if (file_exists($this->tmp2)) unlink($this->tmp2);
276
+            if (file_exists($this->tmp2)) {
277
+             unlink($this->tmp2);
278
+            }
270 279
         } else {
271 280
             $this->data = null;
272 281
         }
Please login to merge, or discard this patch.
src/PclzipZipInterface.php 1 patch
Braces   +173 added lines, -96 removed lines patch added patch discarded remove patch
@@ -132,8 +132,11 @@  discard block
 block discarded – undo
132 132
      */
133 133
     public function create($content)
134 134
     {
135
-        if (is_array($content)) $paths_list = $content;
136
-        else $paths_list = explode(',', $content);
135
+        if (is_array($content)) {
136
+         $paths_list = $content;
137
+        } else {
138
+         $paths_list = explode(',', $content);
139
+        }
137 140
         $report = array();
138 141
 
139 142
         $options = func_get_args();
@@ -155,29 +158,41 @@  discard block
 block discarded – undo
155 158
         // filters initiation
156 159
         $filters = array();
157 160
         if (isset($options[PCLZIP_OPT_REMOVE_PATH])
158
-            && !isset($options[PCLZIP_OPT_REMOVE_ALL_PATH]))
159
-            $filters[] = function (&$key, &$value) use ($options) {
160
-                $key = str_replace($key, null, $key); };
161
-        if (isset($options[PCLZIP_OPT_REMOVE_ALL_PATH]))
162
-            $filters[] = function (&$key, &$value) { $key = basename($key); };
163
-        if (isset($options[PCLZIP_OPT_ADD_PATH]))
164
-            $filters[] = function (&$key, &$value) use ($options) {
161
+            && !isset($options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
162
+                    $filters[] = function (&$key, &$value) use ($options) {
163
+                $key = str_replace($key, null, $key);
164
+        }
165
+        };
166
+        if (isset($options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
167
+                    $filters[] = function (&$key, &$value) { $key = basename($key);
168
+        }
169
+        };
170
+        if (isset($options[PCLZIP_OPT_ADD_PATH])) {
171
+                    $filters[] = function (&$key, &$value) use ($options) {
165 172
                 $key = rtrim($options[PCLZIP_OPT_ADD_PATH], '/').'/'.
166 173
                     ltrim($key, '/');
174
+        }
167 175
             };
168 176
 
169 177
         if (isset($options[PCLZIP_CB_PRE_ADD])
170
-            && is_callable($options[PCLZIP_CB_PRE_ADD]))
171
-            $preAddCallback = $options[PCLZIP_CB_PRE_ADD];
172
-        else $preAddCallback = function () { return 1; };
178
+            && is_callable($options[PCLZIP_CB_PRE_ADD])) {
179
+                    $preAddCallback = $options[PCLZIP_CB_PRE_ADD];
180
+        } else {
181
+         $preAddCallback = function () { return 1;
182
+        }
183
+        };
173 184
 
174 185
         if (isset($options[PCLZIP_CB_POST_ADD])
175
-            && is_callable($options[PCLZIP_CB_POST_ADD]))
176
-            $postAddCallback = $options[PCLZIP_CB_POST_ADD];
177
-        else $postAddCallback = function () { return 1; };
186
+            && is_callable($options[PCLZIP_CB_POST_ADD])) {
187
+                    $postAddCallback = $options[PCLZIP_CB_POST_ADD];
188
+        } else {
189
+         $postAddCallback = function () { return 1;
190
+        }
191
+        };
178 192
 
179
-        if (isset($options[PCLZIP_OPT_COMMENT]))
180
-            $this->archive->setArchiveComment($options[PCLZIP_OPT_COMMENT]);
193
+        if (isset($options[PCLZIP_OPT_COMMENT])) {
194
+                    $this->archive->setArchiveComment($options[PCLZIP_OPT_COMMENT]);
195
+        }
181 196
 
182 197
         // scan filesystem for files list
183 198
         $files_list = array();
@@ -208,20 +223,23 @@  discard block
 block discarded – undo
208 223
             // apply filters to a file
209 224
             $localname = $file_to_add;
210 225
             $filename = $file_to_add;
211
-            foreach ($filters as $filter)
212
-                call_user_func($filter, $localname, $filename);
226
+            foreach ($filters as $filter) {
227
+                            call_user_func($filter, $localname, $filename);
228
+            }
213 229
             $file_header = $this->createFileHeader($localname, $filename);
214 230
             if (call_user_func($preAddCallback, $file_header) == 1) {
215 231
                 //
216 232
                 // Check for max length > 255
217 233
                 //
218
-                if (strlen(basename($file_header->stored_filename)) > 255)
219
-                    $file_header->status = 'filename_too_long';
220
-                if (is_file($filename))
221
-                    $this->archive->addFile($file_header->filename,
234
+                if (strlen(basename($file_header->stored_filename)) > 255) {
235
+                                    $file_header->status = 'filename_too_long';
236
+                }
237
+                if (is_file($filename)) {
238
+                                    $this->archive->addFile($file_header->filename,
222 239
                         $file_header->stored_filename);
223
-                else if (is_dir($filename))
224
-                    $this->archive->addEmptyDir($file_header->stored_filename);
240
+                } else if (is_dir($filename)) {
241
+                                    $this->archive->addEmptyDir($file_header->stored_filename);
242
+                }
225 243
             } else {
226 244
                 //
227 245
                 // File was skipped
@@ -285,40 +303,53 @@  discard block
 block discarded – undo
285 303
         }
286 304
 
287 305
         // filters initiation
288
-        if (isset($options[PCLZIP_OPT_PATH]))
289
-            $extractPath = rtrim($options[PCLZIP_OPT_PATH], '/');
290
-        else $extractPath = rtrim(getcwd(), '/');
306
+        if (isset($options[PCLZIP_OPT_PATH])) {
307
+                    $extractPath = rtrim($options[PCLZIP_OPT_PATH], '/');
308
+        } else {
309
+         $extractPath = rtrim(getcwd(), '/');
310
+        }
291 311
 
292 312
         $filters = array();
293 313
         if (isset($options[PCLZIP_OPT_REMOVE_PATH])
294
-            && !isset($options[PCLZIP_OPT_REMOVE_ALL_PATH]))
295
-            $filters[] = function (&$key, &$value) use ($options) {
314
+            && !isset($options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
315
+                    $filters[] = function (&$key, &$value) use ($options) {
296 316
                 $key = str_replace($key, null, $key);
317
+        }
297 318
             };
298
-        if (isset($options[PCLZIP_OPT_REMOVE_ALL_PATH]))
299
-            $filters[] = function (&$key, &$value) { $key = basename($key); };
300
-        if (isset($options[PCLZIP_OPT_ADD_PATH]))
301
-            $filters[] = function (&$key, &$value) use ($options) {
319
+        if (isset($options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
320
+                    $filters[] = function (&$key, &$value) { $key = basename($key);
321
+        }
322
+        };
323
+        if (isset($options[PCLZIP_OPT_ADD_PATH])) {
324
+                    $filters[] = function (&$key, &$value) use ($options) {
302 325
                 $key = rtrim($options[PCLZIP_OPT_ADD_PATH], '/').'/'.
303 326
                     ltrim($key, '/');
327
+        }
304 328
             };
305 329
 
306 330
         if (isset($options[PCLZIP_CB_PRE_EXTRACT])
307
-            && is_callable($options[PCLZIP_CB_PRE_EXTRACT]))
308
-            $preExtractCallback = $options[PCLZIP_CB_PRE_EXTRACT];
309
-        else $preExtractCallback = function () { return 1; };
331
+            && is_callable($options[PCLZIP_CB_PRE_EXTRACT])) {
332
+                    $preExtractCallback = $options[PCLZIP_CB_PRE_EXTRACT];
333
+        } else {
334
+         $preExtractCallback = function () { return 1;
335
+        }
336
+        };
310 337
 
311 338
         if (isset($options[PCLZIP_CB_POST_EXTRACT])
312
-            && is_callable($options[PCLZIP_CB_POST_EXTRACT]))
313
-            $postExtractCallback = $options[PCLZIP_CB_POST_EXTRACT];
314
-        else $postExtractCallback = function () { return 1; };
339
+            && is_callable($options[PCLZIP_CB_POST_EXTRACT])) {
340
+                    $postExtractCallback = $options[PCLZIP_CB_POST_EXTRACT];
341
+        } else {
342
+         $postExtractCallback = function () { return 1;
343
+        }
344
+        };
315 345
 
316 346
         // exact matching
317
-        if (isset($options[PCLZIP_OPT_BY_NAME]))
318
-            $selectFilter = function ($key, $value) use ($options) {
347
+        if (isset($options[PCLZIP_OPT_BY_NAME])) {
348
+                    $selectFilter = function ($key, $value) use ($options) {
319 349
                 $allowedNames = is_array($options[PCLZIP_OPT_BY_NAME])
320 350
                     ? $options[PCLZIP_OPT_BY_NAME]
321 351
                     : explode(',', $options[PCLZIP_OPT_BY_NAME]);
352
+        }
322 353
                 foreach ($allowedNames as $name) {
323 354
                     // select directory with nested files
324 355
                     if (in_array(substr($name, -1), array('/', '\\'))) {
@@ -339,50 +370,64 @@  discard block
 block discarded – undo
339 370
                 return self::SELECT_FILTER_REFUSE;
340 371
             };
341 372
         // <ereg> rule
342
-        else if (isset($options[PCLZIP_OPT_BY_EREG]) && function_exists('ereg'))
343
-            $selectFilter = function ($key, $value) use ($options) {
373
+        else if (isset($options[PCLZIP_OPT_BY_EREG]) && function_exists('ereg')) {
374
+                    $selectFilter = function ($key, $value) use ($options) {
344 375
                 return (ereg($options[PCLZIP_OPT_BY_EREG], $key) !== false)
345 376
                     ? self::SELECT_FILTER_PASS
346 377
                     : self::SELECT_FILTER_REFUSE;
378
+        }
347 379
             };
348 380
         // <preg_match> rule
349
-        else if (isset($options[PCLZIP_OPT_BY_PREG]))
350
-            $selectFilter = function ($key, $value) use ($options) {
381
+        else if (isset($options[PCLZIP_OPT_BY_PREG])) {
382
+                    $selectFilter = function ($key, $value) use ($options) {
351 383
                 return preg_match($options[PCLZIP_OPT_BY_PREG], $key)
352 384
                     ? self::SELECT_FILTER_PASS
353 385
                     : self::SELECT_FILTER_REFUSE;
386
+        }
354 387
             };
355 388
         // index rule
356
-        else if (isset($options[PCLZIP_OPT_BY_INDEX]))
357
-            $selectFilter = function ($key, $value, $index) use ($options) {
389
+        else if (isset($options[PCLZIP_OPT_BY_INDEX])) {
390
+                    $selectFilter = function ($key, $value, $index) use ($options) {
358 391
                 $allowedIndexes = array();
392
+        }
359 393
                 foreach ($options[PCLZIP_OPT_BY_INDEX] as $rule) {
360 394
                     $parts = explode('-', $rule);
361
-                    if (count($parts) == 1) $allowedIndexes[] = $rule;
362
-                    else $allowedIndexes = array_merge(
395
+                    if (count($parts) == 1) {
396
+                     $allowedIndexes[] = $rule;
397
+                    } else {
398
+                     $allowedIndexes = array_merge(
363 399
                         range($parts[0], $parts[1]), $allowedIndexes);
400
+                    }
364 401
                 }
365 402
 
366 403
                 return in_array($index, $allowedIndexes) ? self::SELECT_FILTER_PASS
367 404
                     : self::SELECT_FILTER_REFUSE;
368 405
             };
369 406
         // no rule
370
-        else
371
-            $selectFilter = function () { return self::SELECT_FILTER_PASS; };
407
+        else {
408
+                    $selectFilter = function () { return self::SELECT_FILTER_PASS;
409
+        }
410
+        };
372 411
 
373
-        if (isset($options[PCLZIP_OPT_EXTRACT_AS_STRING]))
374
-            $anotherOutputFormat = PCLZIP_OPT_EXTRACT_AS_STRING;
375
-        else if (isset($options[PCLZIP_OPT_EXTRACT_IN_OUTPUT]))
376
-            $anotherOutputFormat = PCLZIP_OPT_EXTRACT_IN_OUTPUT;
377
-        else $anotherOutputFormat = false;
412
+        if (isset($options[PCLZIP_OPT_EXTRACT_AS_STRING])) {
413
+                    $anotherOutputFormat = PCLZIP_OPT_EXTRACT_AS_STRING;
414
+        } else if (isset($options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) {
415
+                    $anotherOutputFormat = PCLZIP_OPT_EXTRACT_IN_OUTPUT;
416
+        } else {
417
+         $anotherOutputFormat = false;
418
+        }
378 419
 
379
-        if (isset($options[PCLZIP_OPT_REPLACE_NEWER]))
380
-            $doNotReplaceNewer = false;
381
-        else $doNotReplaceNewer = true;
420
+        if (isset($options[PCLZIP_OPT_REPLACE_NEWER])) {
421
+                    $doNotReplaceNewer = false;
422
+        } else {
423
+         $doNotReplaceNewer = true;
424
+        }
382 425
 
383
-        if (isset($options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION]))
384
-            $restrictExtractDir = $options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION];
385
-        else $restrictExtractDir = false;
426
+        if (isset($options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) {
427
+                    $restrictExtractDir = $options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION];
428
+        } else {
429
+         $restrictExtractDir = false;
430
+        }
386 431
 
387 432
         $report = array();
388 433
         foreach ($this->listContent() as $file_header) {
@@ -452,8 +497,10 @@  discard block
 block discarded – undo
452 497
             // extract content
453 498
             else if ($anotherOutputFormat === false) {
454 499
                 // apply path filters
455
-                foreach ($filters as $filter) call_user_func($filter,
500
+                foreach ($filters as $filter) {
501
+                 call_user_func($filter,
456 502
                     $file_header->stored_filename, $file_header->filename);
503
+                }
457 504
                 // dir extraction process
458 505
                 if ($file_header->folder) {
459 506
                     // if dir doesn't exist
@@ -545,8 +592,11 @@  discard block
 block discarded – undo
545 592
      */
546 593
     public function add($content)
547 594
     {
548
-        if (is_array($content)) $paths_list = $content;
549
-        else $paths_list = array_map(explode(',', $content));
595
+        if (is_array($content)) {
596
+         $paths_list = $content;
597
+        } else {
598
+         $paths_list = array_map(explode(',', $content));
599
+        }
550 600
         $report = array();
551 601
 
552 602
         $options = func_get_args();
@@ -568,30 +618,41 @@  discard block
 block discarded – undo
568 618
         // filters initiation
569 619
         $filters = array();
570 620
         if (isset($options[PCLZIP_OPT_REMOVE_PATH])
571
-            && !isset($options[PCLZIP_OPT_REMOVE_ALL_PATH]))
572
-            $filters[] = function (&$key, &$value) use ($options) {
621
+            && !isset($options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
622
+                    $filters[] = function (&$key, &$value) use ($options) {
573 623
                 $key = str_replace($key, null, $key);
624
+        }
574 625
             };
575
-        if (isset($options[PCLZIP_OPT_REMOVE_ALL_PATH]))
576
-            $filters[] = function (&$key, &$value) { $key = basename($key); };
577
-        if (isset($options[PCLZIP_OPT_ADD_PATH]))
578
-            $filters[] = function (&$key, &$value) use ($options) {
626
+        if (isset($options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
627
+                    $filters[] = function (&$key, &$value) { $key = basename($key);
628
+        }
629
+        };
630
+        if (isset($options[PCLZIP_OPT_ADD_PATH])) {
631
+                    $filters[] = function (&$key, &$value) use ($options) {
579 632
                 $key = rtrim($options[PCLZIP_OPT_ADD_PATH], '/').'/'.
580 633
                     ltrim($key, '/');
634
+        }
581 635
             };
582 636
 
583 637
         if (isset($options[PCLZIP_CB_PRE_ADD])
584
-            && is_callable($options[PCLZIP_CB_PRE_ADD]))
585
-            $preAddCallback = $options[PCLZIP_CB_PRE_ADD];
586
-        else $preAddCallback = function () { return 1; };
638
+            && is_callable($options[PCLZIP_CB_PRE_ADD])) {
639
+                    $preAddCallback = $options[PCLZIP_CB_PRE_ADD];
640
+        } else {
641
+         $preAddCallback = function () { return 1;
642
+        }
643
+        };
587 644
 
588 645
         if (isset($options[PCLZIP_CB_POST_ADD])
589
-            && is_callable($options[PCLZIP_CB_POST_ADD]))
590
-            $postAddCallback = $options[PCLZIP_CB_POST_ADD];
591
-        else $postAddCallback = function () { return 1; };
646
+            && is_callable($options[PCLZIP_CB_POST_ADD])) {
647
+                    $postAddCallback = $options[PCLZIP_CB_POST_ADD];
648
+        } else {
649
+         $postAddCallback = function () { return 1;
650
+        }
651
+        };
592 652
 
593
-        if (isset($options[PCLZIP_OPT_COMMENT]))
594
-            $this->archive->setArchiveComment($options[PCLZIP_OPT_COMMENT]);
653
+        if (isset($options[PCLZIP_OPT_COMMENT])) {
654
+                    $this->archive->setArchiveComment($options[PCLZIP_OPT_COMMENT]);
655
+        }
595 656
         if (isset($options[PCLZIP_OPT_ADD_COMMENT])) {
596 657
             $comment =
597 658
                 ($comment = $this->archive->getArchiveComment() !== false)
@@ -645,11 +706,12 @@  discard block
 block discarded – undo
645 706
         );
646 707
 
647 708
         // exact matching
648
-        if (isset($options[PCLZIP_OPT_BY_NAME]))
649
-            $selectFilter = function ($key, $value) use ($options) {
709
+        if (isset($options[PCLZIP_OPT_BY_NAME])) {
710
+                    $selectFilter = function ($key, $value) use ($options) {
650 711
                 $allowedNames = is_array($options[PCLZIP_OPT_BY_NAME])
651 712
                     ? $options[PCLZIP_OPT_BY_NAME]
652 713
                     : explode(',', $options[PCLZIP_OPT_BY_NAME]);
714
+        }
653 715
                 foreach ($allowedNames as $name) {
654 716
                     // select directory with nested files
655 717
                     if (in_array(substr($name, -1), array('/', '\\'))) {
@@ -670,28 +732,34 @@  discard block
 block discarded – undo
670 732
                 return self::SELECT_FILTER_REFUSE;
671 733
             };
672 734
         // <ereg> rule
673
-        else if (isset($options[PCLZIP_OPT_BY_EREG]) && function_exists('ereg'))
674
-            $selectFilter = function ($key, $value) use ($options) {
735
+        else if (isset($options[PCLZIP_OPT_BY_EREG]) && function_exists('ereg')) {
736
+                    $selectFilter = function ($key, $value) use ($options) {
675 737
                 return (ereg($options[PCLZIP_OPT_BY_EREG], $key) !== false)
676 738
                     ? self::SELECT_FILTER_PASS
677 739
                     : self::SELECT_FILTER_REFUSE;
740
+        }
678 741
             };
679 742
         // <preg_match> rule
680
-        else if (isset($options[PCLZIP_OPT_BY_PREG]))
681
-            $selectFilter = function ($key, $value) use ($options) {
743
+        else if (isset($options[PCLZIP_OPT_BY_PREG])) {
744
+                    $selectFilter = function ($key, $value) use ($options) {
682 745
                 return preg_match($options[PCLZIP_OPT_BY_PREG], $key)
683 746
                     ? self::SELECT_FILTER_PASS
684 747
                     : self::SELECT_FILTER_REFUSE;
748
+        }
685 749
             };
686 750
         // index rule
687
-        else if (isset($options[PCLZIP_OPT_BY_INDEX]))
688
-            $selectFilter = function ($key, $value, $index) use ($options) {
751
+        else if (isset($options[PCLZIP_OPT_BY_INDEX])) {
752
+                    $selectFilter = function ($key, $value, $index) use ($options) {
689 753
                 $allowedIndexes = array();
754
+        }
690 755
                 foreach ($options[PCLZIP_OPT_BY_INDEX] as $rule) {
691 756
                     $parts = explode('-', $rule);
692
-                    if (count($parts) == 1) $allowedIndexes[] = $rule;
693
-                    else $allowedIndexes = array_merge(
757
+                    if (count($parts) == 1) {
758
+                     $allowedIndexes[] = $rule;
759
+                    } else {
760
+                     $allowedIndexes = array_merge(
694 761
                         range($parts[0], $parts[1]), $allowedIndexes);
762
+                    }
695 763
                 }
696 764
 
697 765
                 return in_array($index, $allowedIndexes)
@@ -699,8 +767,10 @@  discard block
 block discarded – undo
699 767
                     : self::SELECT_FILTER_REFUSE;
700 768
             };
701 769
         // no rule
702
-        else
703
-            $selectFilter = function () { return self::SELECT_FILTER_PASS; };
770
+        else {
771
+                    $selectFilter = function () { return self::SELECT_FILTER_PASS;
772
+        }
773
+        };
704 774
 
705 775
         foreach ($this->listContent() as $file_header) {
706 776
             // select by select rule
@@ -752,8 +822,12 @@  discard block
 block discarded – undo
752 822
         }
753 823
 
754 824
         $tempDir = tempnam(PCLZIP_TEMPORARY_DIR, 'merging');
755
-        if (file_exists($tempDir)) unlink($tempDir);
756
-        if (!mkdir($tempDir)) return 0;
825
+        if (file_exists($tempDir)) {
826
+         unlink($tempDir);
827
+        }
828
+        if (!mkdir($tempDir)) {
829
+         return 0;
830
+        }
757 831
 
758 832
         // go through archive content list and copy all files
759 833
         foreach ($a->getFileNames() as $filename) {
@@ -782,8 +856,11 @@  discard block
 block discarded – undo
782 856
 
783 857
         call_user_func(function ($directory) {
784 858
             foreach (glob($directory.'/*') as $f) {
785
-                if (is_dir($f)) call_user_func(__FUNCTION__, $f);
786
-                else unlink($f);
859
+                if (is_dir($f)) {
860
+                 call_user_func(__FUNCTION__, $f);
861
+                } else {
862
+                 unlink($f);
863
+                }
787 864
             }
788 865
         }, $tempDir);
789 866
 
Please login to merge, or discard this patch.
src/Formats/Iso.php 1 patch
Braces   +21 added lines, -12 removed lines patch added patch discarded remove patch
@@ -52,8 +52,9 @@  discard block
 block discarded – undo
52 52
 
53 53
         /** @var \CVolumeDescriptor $usedDesc */
54 54
         $usedDesc = $this->iso->GetDescriptor(SUPPLEMENTARY_VOLUME_DESC);
55
-        if (!$usedDesc)
56
-            $usedDesc = $this->iso->GetDescriptor(PRIMARY_VOLUME_DESC);
55
+        if (!$usedDesc) {
56
+                    $usedDesc = $this->iso->GetDescriptor(PRIMARY_VOLUME_DESC);
57
+        }
57 58
         $this->blockSize = $usedDesc->iBlockSize;
58 59
         $directories = $usedDesc->LoadMPathTable($this->iso);
59 60
         // iterate over all directories
@@ -74,8 +75,9 @@  discard block
 block discarded – undo
74 75
             if ($files) {
75 76
                 /** @var \CFileDirDescriptors $file */
76 77
                 foreach ($files as $file) {
77
-                    if (in_array($file->strd_FileId, ['.', '..']) || $file->IsDirectory())
78
-                        continue;
78
+                    if (in_array($file->strd_FileId, ['.', '..']) || $file->IsDirectory()) {
79
+                                            continue;
80
+                    }
79 81
                     $this->files[$file->Location] = $directory.$file->strd_FileId;
80 82
                     $this->filesSize += $file->DataLen;
81 83
 
@@ -127,8 +129,9 @@  discard block
 block discarded – undo
127 129
      */
128 130
     public function getFileData($fileName)
129 131
     {
130
-        if (!isset($this->filesData[$fileName]))
131
-            return false;
132
+        if (!isset($this->filesData[$fileName])) {
133
+                    return false;
134
+        }
132 135
 
133 136
         return new ArchiveEntry($fileName, $this->filesData[$fileName]['size'],
134 137
             $this->filesData[$fileName]['size'], $this->filesData[$fileName]['mtime'],false);
@@ -142,11 +145,14 @@  discard block
 block discarded – undo
142 145
     public function getFileContent($fileName)
143 146
     {
144 147
         $Location = array_search($fileName, $this->files, true);
145
-        if (!isset($this->filesData[$fileName])) return false;
148
+        if (!isset($this->filesData[$fileName])) {
149
+         return false;
150
+        }
146 151
         $data = $this->filesData[$fileName];
147 152
         $Location_Real = $Location * $this->blockSize;
148
-        if ($this->iso->Seek($Location_Real, SEEK_SET) === false)
149
-            return false;
153
+        if ($this->iso->Seek($Location_Real, SEEK_SET) === false) {
154
+                    return false;
155
+        }
150 156
 
151 157
         return $this->iso->Read($data['size']);
152 158
     }
@@ -159,11 +165,14 @@  discard block
 block discarded – undo
159 165
     public function getFileResource($fileName)
160 166
     {
161 167
         $Location = array_search($fileName, $this->files, true);
162
-        if (!isset($this->filesData[$fileName])) return false;
168
+        if (!isset($this->filesData[$fileName])) {
169
+         return false;
170
+        }
163 171
         $data = $this->filesData[$fileName];
164 172
         $Location_Real = $Location * $this->blockSize;
165
-        if ($this->iso->Seek($Location_Real, SEEK_SET) === false)
166
-            return false;
173
+        if ($this->iso->Seek($Location_Real, SEEK_SET) === false) {
174
+                    return false;
175
+        }
167 176
 
168 177
         $resource = fopen('php://temp', 'r+');
169 178
         fwrite($resource, $this->iso->Read($data['size']));
Please login to merge, or discard this patch.