Passed
Push — master ( ba00c7...bfa3fc )
by Sebastian
08:42
created
src/FileHelper/SerializedFile.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
             )
51 51
         );
52 52
 
53
-        if($result !== false) {
53
+        if ($result !== false) {
54 54
             return $result;
55 55
         }
56 56
 
Please login to merge, or discard this patch.
src/FileHelper/CLICommandChecker.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
     {
60 60
         $os = $this->getOS();
61 61
 
62
-        if(isset(self::$osCommands[$os]))
62
+        if (isset(self::$osCommands[$os]))
63 63
         {
64 64
             return self::$osCommands[$os];
65 65
         }
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
      */
84 84
     public function exists(string $command) : bool
85 85
     {
86
-        if(isset(self::$checked[$command]))
86
+        if (isset(self::$checked[$command]))
87 87
         {
88 88
             return self::$checked[$command];
89 89
         }
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
             $pipes
115 115
         );
116 116
 
117
-        if($process === false)
117
+        if ($process === false)
118 118
         {
119 119
             return '';
120 120
         }
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 
127 127
         proc_close($process);
128 128
 
129
-        if($stdout === false)
129
+        if ($stdout === false)
130 130
         {
131 131
             return '';
132 132
         }
Please login to merge, or discard this patch.
src/FileHelper/FileInfo.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -255,8 +255,7 @@
 block discarded – undo
255 255
         if($this->exists())
256 256
         {
257 257
             $this->requireWritable();
258
-        }
259
-        else
258
+        } else
260 259
         {
261 260
             FolderInfo::factory(dirname($this->path))
262 261
                 ->create()
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
         $pathString = AbstractPathInfo::type2string($path);
67 67
         $endingChar = $pathString[strlen($pathString) - 1];
68 68
 
69
-        if(empty($path)) {
69
+        if (empty($path)) {
70 70
             throw new FileHelper_Exception(
71 71
                 'Invalid',
72 72
                 '',
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
             );
75 75
         }
76 76
 
77
-        if($path instanceof FolderInfo || $endingChar === '/' || $endingChar === '\\')
77
+        if ($path instanceof FolderInfo || $endingChar === '/' || $endingChar === '\\')
78 78
         {
79 79
             throw new FileHelper_Exception(
80 80
                 'Cannot use a folder as a file',
@@ -88,12 +88,12 @@  discard block
 block discarded – undo
88 88
 
89 89
         $key = $pathString.';'.static::class;
90 90
 
91
-        if(!isset(self::$infoCache[$key]))
91
+        if (!isset(self::$infoCache[$key]))
92 92
         {
93 93
             $class = static::class;
94 94
             $instance = new $class($pathString);
95 95
 
96
-            if(!$instance instanceof self) {
96
+            if (!$instance instanceof self) {
97 97
                 throw new FileHelper_Exception(
98 98
                     'Invalid class created',
99 99
                     sprintf(
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
     {
129 129
         $path = trim($path);
130 130
 
131
-        if(empty($path) || FolderInfo::is_dir($path))
131
+        if (empty($path) || FolderInfo::is_dir($path))
132 132
         {
133 133
             return false;
134 134
         }
@@ -136,9 +136,9 @@  discard block
 block discarded – undo
136 136
         return is_file($path) || pathinfo($path, PATHINFO_EXTENSION) !== '';
137 137
     }
138 138
 
139
-    public function removeExtension(bool $keepPath=false) : string
139
+    public function removeExtension(bool $keepPath = false) : string
140 140
     {
141
-        if(!$keepPath)
141
+        if (!$keepPath)
142 142
         {
143 143
             return (string)pathinfo($this->getName(), PATHINFO_FILENAME);
144 144
         }
@@ -163,11 +163,11 @@  discard block
 block discarded – undo
163 163
         return $this->removeExtension();
164 164
     }
165 165
 
166
-    public function getExtension(bool $lowercase=true) : string
166
+    public function getExtension(bool $lowercase = true) : string
167 167
     {
168 168
         $ext = (string)pathinfo($this->path, PATHINFO_EXTENSION);
169 169
 
170
-        if($lowercase)
170
+        if ($lowercase)
171 171
         {
172 172
             $ext = mb_strtolower($ext);
173 173
         }
@@ -188,12 +188,12 @@  discard block
 block discarded – undo
188 188
      */
189 189
     public function delete() : FileInfo
190 190
     {
191
-        if(!$this->exists())
191
+        if (!$this->exists())
192 192
         {
193 193
             return $this;
194 194
         }
195 195
 
196
-        if(unlink($this->path))
196
+        if (unlink($this->path))
197 197
         {
198 198
             return $this;
199 199
         }
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
     {
221 221
         $target = $this->checkCopyPrerequisites($targetPath);
222 222
 
223
-        if(copy($this->path, (string)$target))
223
+        if (copy($this->path, (string)$target))
224 224
         {
225 225
             return $target;
226 226
         }
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
         $target = FileHelper::getPathInfo($targetPath);
258 258
 
259 259
         // It's a file? Then we can use it as-is.
260
-        if($target instanceof self) {
260
+        if ($target instanceof self) {
261 261
             return $target
262 262
                 ->requireIsFile()
263 263
                 ->createFolder();
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
         // but is not a folder: very likely a file without extension.
268 268
         // In this case we create an empty file to be able to return
269 269
         // a FileInfo instance.
270
-        if($target instanceof IndeterminatePath)
270
+        if ($target instanceof IndeterminatePath)
271 271
         {
272 272
             return $target->convertToFile();
273 273
         }
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
      */
297 297
     public function getLineReader() : LineReader
298 298
     {
299
-        if($this->lineReader === null)
299
+        if ($this->lineReader === null)
300 300
         {
301 301
             $this->lineReader = new LineReader($this);
302 302
         }
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 
316 316
         $result = file_get_contents($this->getPath());
317 317
 
318
-        if($result !== false) {
318
+        if ($result !== false) {
319 319
             return $result;
320 320
         }
321 321
 
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
      */
338 338
     public function putContents(string $content) : FileInfo
339 339
     {
340
-        if($this->exists())
340
+        if ($this->exists())
341 341
         {
342 342
             $this->requireWritable();
343 343
         }
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
                 ->requireWritable();
349 349
         }
350 350
 
351
-        if(file_put_contents($this->path, $content) !== false)
351
+        if (file_put_contents($this->path, $content) !== false)
352 352
         {
353 353
             return $this;
354 354
         }
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
      */
379 379
     private function createFolder() : FileInfo
380 380
     {
381
-        if(!$this->exists())
381
+        if (!$this->exists())
382 382
         {
383 383
             FolderInfo::factory($this->getFolderPath())
384 384
                 ->create()
Please login to merge, or discard this patch.
src/FileHelper/UnicodeHandling.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -27,12 +27,12 @@  discard block
 block discarded – undo
27 27
     /**
28 28
      * @var array<string,string>|NULL
29 29
      */
30
-    protected static ?array $utfBoms = null;
30
+    protected static ? array $utfBoms = null;
31 31
 
32 32
     /**
33 33
      * @var string[]|NULL
34 34
      */
35
-    protected static ?array $encodings = null;
35
+    protected static ? array $encodings = null;
36 36
 
37 37
     public function __construct()
38 38
     {
@@ -70,9 +70,9 @@  discard block
 block discarded – undo
70 70
 
71 71
         fclose($fp);
72 72
 
73
-        foreach(self::$utfBoms as $bom => $value)
73
+        foreach (self::$utfBoms as $bom => $value)
74 74
         {
75
-            if(mb_strpos($text, $value) === 0)
75
+            if (mb_strpos($text, $value) === 0)
76 76
             {
77 77
                 return $bom;
78 78
             }
@@ -83,23 +83,23 @@  discard block
 block discarded – undo
83 83
 
84 84
     private function initBOMs() : void
85 85
     {
86
-        if(isset(self::$utfBoms))
86
+        if (isset(self::$utfBoms))
87 87
         {
88 88
             return;
89 89
         }
90 90
 
91 91
         self::$utfBoms = array(
92
-            'UTF32-BE' => chr(0x00) . chr(0x00) . chr(0xFE) . chr(0xFF),
93
-            'UTF32-LE' => chr(0xFF) . chr(0xFE) . chr(0x00) . chr(0x00),
94
-            'UTF16-BE' => chr(0xFE) . chr(0xFF),
95
-            'UTF16-LE' => chr(0xFF) . chr(0xFE),
96
-            'UTF8' => chr(0xEF) . chr(0xBB) . chr(0xBF)
92
+            'UTF32-BE' => chr(0x00).chr(0x00).chr(0xFE).chr(0xFF),
93
+            'UTF32-LE' => chr(0xFF).chr(0xFE).chr(0x00).chr(0x00),
94
+            'UTF16-BE' => chr(0xFE).chr(0xFF),
95
+            'UTF16-LE' => chr(0xFF).chr(0xFE),
96
+            'UTF8' => chr(0xEF).chr(0xBB).chr(0xBF)
97 97
         );
98 98
     }
99 99
 
100 100
     private function initEncodings() : void
101 101
     {
102
-        if(isset(self::$encodings))
102
+        if (isset(self::$encodings))
103 103
         {
104 104
             return;
105 105
         }
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 
109 109
         self::$encodings = array();
110 110
 
111
-        foreach($encodings as $string)
111
+        foreach ($encodings as $string)
112 112
         {
113 113
             $withHyphen = str_replace('UTF', 'UTF-', $string);
114 114
 
Please login to merge, or discard this patch.
src/FileHelper/FileInfo/FileSender.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
         $this->file = $info;
36 36
     }
37 37
 
38
-    public function send(?string $fileName = null, bool $asAttachment=true) : void
38
+    public function send(?string $fileName = null, bool $asAttachment = true) : void
39 39
     {
40 40
         $this->file
41 41
             ->requireExists()
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
     {
54 54
         header("Cache-Control: public", true);
55 55
         header("Content-Description: File Transfer", true);
56
-        header("Content-Type: " . $this->detectMime(), true);
56
+        header("Content-Type: ".$this->detectMime(), true);
57 57
 
58 58
         header(sprintf(
59 59
             "Content-Disposition: %s; filename=%s",
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 
70 70
     private function resolveDisposition(bool $asAttachment) : string
71 71
     {
72
-        if($asAttachment)
72
+        if ($asAttachment)
73 73
         {
74 74
             return 'attachment';
75 75
         }
Please login to merge, or discard this patch.
src/FileHelper/FileInfo/LineReader.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -47,15 +47,15 @@  discard block
 block discarded – undo
47 47
 
48 48
         $file = new SplFileObject($this->file->getPath());
49 49
 
50
-        if($file->eof()) {
50
+        if ($file->eof()) {
51 51
             return '';
52 52
         }
53 53
 
54
-        $targetLine = $lineNumber-1;
54
+        $targetLine = $lineNumber - 1;
55 55
 
56 56
         $file->seek($targetLine);
57 57
 
58
-        if($file->key() !== $targetLine)
58
+        if ($file->key() !== $targetLine)
59 59
         {
60 60
             return null;
61 61
         }
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
         $number = $spl->key();
77 77
 
78 78
         // if seeking to the end the cursor is still at 0, there are no lines.
79
-        if($number === 0)
79
+        if ($number === 0)
80 80
         {
81 81
             // since it's a very small file, to get reliable results,
82 82
             // we read its contents and use that to determine what
@@ -84,13 +84,13 @@  discard block
 block discarded – undo
84 84
             // that this is not practical to solve with the SplFileObject.
85 85
             $content = file_get_contents($path);
86 86
 
87
-            if(empty($content)) {
87
+            if (empty($content)) {
88 88
                 return 0;
89 89
             }
90 90
         }
91 91
 
92 92
         // return the line number we were able to reach + 1 (key is zero-based)
93
-        return $number+1;
93
+        return $number + 1;
94 94
     }
95 95
 
96 96
     /**
@@ -98,13 +98,13 @@  discard block
 block discarded – undo
98 98
      * @return string[]
99 99
      * @throws FileHelper_Exception
100 100
      */
101
-    public function getLines(int $amount=0) : array
101
+    public function getLines(int $amount = 0) : array
102 102
     {
103 103
         $this->file->requireExists();
104 104
 
105 105
         $fn = fopen($this->file->getPath(), 'rb');
106 106
 
107
-        if($fn === false)
107
+        if ($fn === false)
108 108
         {
109 109
             throw new FileHelper_Exception(
110 110
                 'Could not open file for reading.',
@@ -120,19 +120,19 @@  discard block
 block discarded – undo
120 120
         $counter = 0;
121 121
         $first = true;
122 122
 
123
-        while(!feof($fn))
123
+        while (!feof($fn))
124 124
         {
125 125
             $counter++;
126 126
 
127 127
             $line = fgets($fn);
128 128
 
129 129
             // can happen with zero length files
130
-            if($line === false) {
130
+            if ($line === false) {
131 131
                 continue;
132 132
             }
133 133
 
134 134
             // the first line may contain a unicode BOM marker.
135
-            if($first)
135
+            if ($first)
136 136
             {
137 137
                 $line = ConvertHelper::stripUTFBom($line);
138 138
                 $first = false;
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 
141 141
             $result[] = $line;
142 142
 
143
-            if($amount > 0 && $counter === $amount) {
143
+            if ($amount > 0 && $counter === $amount) {
144 144
                 break;
145 145
             }
146 146
         }
Please login to merge, or discard this patch.
src/FileHelper/FileInfo/NameFixer.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -49,13 +49,13 @@
 block discarded – undo
49 49
 
50 50
         $name = str_replace(array_keys($replaces), array_values($replaces), $name);
51 51
 
52
-        while(strpos($name, '  ') !== false) {
52
+        while (strpos($name, '  ') !== false) {
53 53
             $name = str_replace('  ', ' ', $name);
54 54
         }
55 55
 
56 56
         $name = str_replace(array_keys($replaces), array_values($replaces), $name);
57 57
 
58
-        while(strpos($name, '..') !== false) {
58
+        while (strpos($name, '..') !== false) {
59 59
             $name = str_replace('..', '.', $name);
60 60
         }
61 61
 
Please login to merge, or discard this patch.
src/FileHelper/PathsReducer.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
      * @param string[] $paths
37 37
      * @throws FileHelper_Exception
38 38
      */
39
-    public function __construct(array $paths=array())
39
+    public function __construct(array $paths = array())
40 40
     {
41 41
         $this->addPaths($paths);
42 42
     }
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
      */
50 50
     public function addPaths(array $paths) : PathsReducer
51 51
     {
52
-        foreach($paths as $path) {
52
+        foreach ($paths as $path) {
53 53
             $this->addPath($path);
54 54
         }
55 55
 
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
     {
67 67
         $path = FileHelper::normalizePath($path);
68 68
 
69
-        if(!in_array($path, $this->paths, true)) {
69
+        if (!in_array($path, $this->paths, true)) {
70 70
             $this->paths[] = $path;
71 71
         }
72 72
 
@@ -83,11 +83,11 @@  discard block
 block discarded – undo
83 83
     {
84 84
         $split = $this->splitPaths();
85 85
 
86
-        if(empty($split)) {
86
+        if (empty($split)) {
87 87
             return array();
88 88
         }
89 89
 
90
-        while($this->shiftPart($split) === true) {}
90
+        while ($this->shiftPart($split) === true) {}
91 91
 
92 92
         return $this->joinPaths($split);
93 93
     }
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
         $result = array();
102 102
 
103 103
         foreach ($split as $entry) {
104
-            if(!empty($entry)) {
104
+            if (!empty($entry)) {
105 105
                 $result[] = implode('/', $entry);
106 106
             }
107 107
         }
@@ -118,22 +118,22 @@  discard block
 block discarded – undo
118 118
         $current = null;
119 119
         $result = array();
120 120
 
121
-        foreach($split as $entry)
121
+        foreach ($split as $entry)
122 122
         {
123
-            if(empty($entry)) {
123
+            if (empty($entry)) {
124 124
                 return false;
125 125
             }
126 126
 
127 127
             $part = array_shift($entry);
128
-            if(empty($entry)) {
128
+            if (empty($entry)) {
129 129
                 return false;
130 130
             }
131 131
 
132
-            if($current === null) {
132
+            if ($current === null) {
133 133
                 $current = $part;
134 134
             }
135 135
 
136
-            if($part !== $current) {
136
+            if ($part !== $current) {
137 137
                 return false;
138 138
             }
139 139
 
@@ -152,9 +152,9 @@  discard block
 block discarded – undo
152 152
     {
153 153
         $split = array();
154 154
 
155
-        foreach($this->paths as $path) {
155
+        foreach ($this->paths as $path) {
156 156
             $entry = ConvertHelper::explodeTrim('/', $path);
157
-            if(!empty($entry)) {
157
+            if (!empty($entry)) {
158 158
                 $split[] = $entry;
159 159
             }
160 160
         }
Please login to merge, or discard this patch.
src/FileHelper.php 3 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -516,8 +516,7 @@
 block discarded – undo
516 516
         if(isset($options['relative-path']) && $options['relative-path'] === true) 
517 517
         {
518 518
             $finder->setPathmodeRelative();
519
-        } 
520
-        else if(isset($options['absolute-path']) && $options['absolute-path'] === true)
519
+        } else if(isset($options['absolute-path']) && $options['absolute-path'] === true)
521 520
         {
522 521
             $finder->setPathmodeAbsolute();
523 522
         }
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
     public static function detectMimeType($fileName) : ?string
208 208
     {
209 209
         $ext = self::getExtension($fileName);
210
-        if(empty($ext)) {
210
+        if (empty($ext)) {
211 211
             return null;
212 212
         }
213 213
 
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
      * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
252 252
      * @see FileHelper::ERROR_UNKNOWN_FILE_MIME_TYPE
253 253
      */
254
-    public static function sendFile($filePath, ?string $fileName = null, bool $asAttachment=true) : void
254
+    public static function sendFile($filePath, ?string $fileName = null, bool $asAttachment = true) : void
255 255
     {
256 256
         self::getFileInfo($filePath)->getDownloader()->send($fileName, $asAttachment);
257 257
     }
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
      * @throws FileHelper_Exception
269 269
      * @see FileHelper::ERROR_CANNOT_OPEN_URL
270 270
      */
271
-    public static function downloadFile(string $url, int $timeout=0, bool $SSLEnabled=false) : string
271
+    public static function downloadFile(string $url, int $timeout = 0, bool $SSLEnabled = false) : string
272 272
     {
273 273
         return FileDownloader::factory($url)
274 274
             ->setTimeout($timeout)
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
     {
324 324
         $info = self::getPathInfo($pathOrDirIterator);
325 325
 
326
-        if($extension === true || $info instanceof FolderInfo)
326
+        if ($extension === true || $info instanceof FolderInfo)
327 327
         {
328 328
             return $info->getName();
329 329
         }
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
      * @see FileHelper::ERROR_CANNOT_FIND_JSON_FILE
346 346
      * @see FileHelper::ERROR_CANNOT_DECODE_JSON_FILE
347 347
      */
348
-    public static function parseJSONFile($file, string $targetEncoding='', $sourceEncoding=null) : array
348
+    public static function parseJSONFile($file, string $targetEncoding = '', $sourceEncoding = null) : array
349 349
     {
350 350
         return JSONFile::factory($file)
351 351
             ->setTargetEncoding($targetEncoding)
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
      * @throws FileHelper_Exception
399 399
      * @see FileHelper::createFileFinder()
400 400
      */
401
-    public static function findHTMLFiles($targetFolder, array $options=array()) : array
401
+    public static function findHTMLFiles($targetFolder, array $options = array()) : array
402 402
     {
403 403
         return self::findFiles($targetFolder, array('html'), $options);
404 404
     }
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
      * @throws FileHelper_Exception
418 418
      * @see FileHelper::createFileFinder()
419 419
      */
420
-    public static function findPHPFiles($targetFolder, array $options=array()) : array
420
+    public static function findPHPFiles($targetFolder, array $options = array()) : array
421 421
     {
422 422
         return self::findFiles($targetFolder, array('php'), $options);
423 423
     }
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
     * @see FileHelper::createFileFinder()
440 440
     * @deprecated Use the file finder instead.
441 441
     */
442
-    public static function findFiles($targetFolder, array $extensions=array(), array $options=array()) : array
442
+    public static function findFiles($targetFolder, array $extensions = array(), array $options = array()) : array
443 443
     {
444 444
         $finder = self::createFileFinder($targetFolder);
445 445
 
@@ -449,16 +449,16 @@  discard block
 block discarded – undo
449 449
 
450 450
         $finder->setPathmodeStrip();
451 451
         
452
-        if(isset($options['relative-path']) && $options['relative-path'] === true) 
452
+        if (isset($options['relative-path']) && $options['relative-path'] === true) 
453 453
         {
454 454
             $finder->setPathmodeRelative();
455 455
         } 
456
-        else if(isset($options['absolute-path']) && $options['absolute-path'] === true)
456
+        else if (isset($options['absolute-path']) && $options['absolute-path'] === true)
457 457
         {
458 458
             $finder->setPathmodeAbsolute();
459 459
         }
460 460
         
461
-        if(isset($options['strip-extension'])) 
461
+        if (isset($options['strip-extension'])) 
462 462
         {
463 463
             $finder->stripExtensions();
464 464
         }
@@ -477,16 +477,16 @@  discard block
 block discarded – undo
477 477
      * @return string
478 478
      * @throws FileHelper_Exception
479 479
      */
480
-    public static function removeExtension($filename, bool $keepPath=false) : string
480
+    public static function removeExtension($filename, bool $keepPath = false) : string
481 481
     {
482 482
         $path = self::getPathInfo($filename);
483 483
 
484
-        if($path instanceof FileInfo)
484
+        if ($path instanceof FileInfo)
485 485
         {
486 486
             return $path->removeExtension($keepPath);
487 487
         }
488 488
 
489
-        if($keepPath)
489
+        if ($keepPath)
490 490
         {
491 491
             return $filename;
492 492
         }
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
 
502 502
     public static function createUnicodeHandling() : UnicodeHandling
503 503
     {
504
-        if(!isset(self::$unicodeHandling))
504
+        if (!isset(self::$unicodeHandling))
505 505
         {
506 506
             self::$unicodeHandling = new UnicodeHandling();
507 507
         }
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
      * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE
536 536
      * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED
537 537
      */
538
-    public static function saveAsJSON($data, $file, bool $pretty=false) : JSONFile
538
+    public static function saveAsJSON($data, $file, bool $pretty = false) : JSONFile
539 539
     {
540 540
         return JSONFile::factory($file)->putData($data, $pretty);
541 541
     }
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
      * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE
554 554
      * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED
555 555
      */
556
-    public static function saveFile($filePath, string $content='') : FileInfo
556
+    public static function saveFile($filePath, string $content = '') : FileInfo
557 557
     {
558 558
         return self::getFileInfo($filePath)->putContents($content);
559 559
     }
@@ -665,7 +665,7 @@  discard block
 block discarded – undo
665 665
     * @param int $depth The folder depth to reduce the path to
666 666
     * @return string
667 667
     */
668
-    public static function relativizePathByDepth(string $path, int $depth=2) : string
668
+    public static function relativizePathByDepth(string $path, int $depth = 2) : string
669 669
     {
670 670
         return PathRelativizer::relativizeByDepth($path, $depth);
671 671
     }
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
     * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
705 705
     * @see FileHelper::ERROR_REAL_PATH_NOT_FOUND
706 706
     */
707
-    public static function requireFileExists($path, ?int $errorCode=null) : string
707
+    public static function requireFileExists($path, ?int $errorCode = null) : string
708 708
     {
709 709
         return self::getPathInfo($path)
710 710
             ->requireIsFile()
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
      * @return string
719 719
      * @throws FileHelper_Exception
720 720
      */
721
-    public static function requireFileReadable($path, ?int $errorCode=null) : string
721
+    public static function requireFileReadable($path, ?int $errorCode = null) : string
722 722
     {
723 723
         return self::getPathInfo($path)
724 724
             ->requireIsFile()
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
      * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
797 797
      * @see FileHelper::ERROR_CANNOT_OPEN_FILE_TO_READ_LINES
798 798
      */
799
-    public static function readLines($filePath, int $amount=0) : array
799
+    public static function readLines($filePath, int $amount = 0) : array
800 800
     {
801 801
         return self::getFileInfo($filePath)
802 802
             ->getLineReader()
@@ -846,7 +846,7 @@  discard block
 block discarded – undo
846 846
      *
847 847
      * @throws FileHelper_Exception
848 848
      */
849
-    public static function createPathsReducer(array $paths=array()) : PathsReducer
849
+    public static function createPathsReducer(array $paths = array()) : PathsReducer
850 850
     {
851 851
         return new PathsReducer($paths);
852 852
     }
Please login to merge, or discard this patch.
Indentation   +162 added lines, -162 removed lines patch added patch discarded remove patch
@@ -73,18 +73,18 @@  discard block
 block discarded – undo
73 73
     public const ERROR_PATH_INVALID = 340040;
74 74
     public const ERROR_CANNOT_COPY_FILE_TO_FOLDER = 340041;
75 75
 
76
-   /**
77
-    * Opens a serialized file and returns the unserialized data.
78
-    *
79
-    * @param string|PathInfoInterface|SplFileInfo $file
80
-    * @throws FileHelper_Exception
81
-    * @return array<int|string,mixed>
82
-    * @see SerializedFile::parse()
83
-    * 
84
-    * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
85
-    * @see FileHelper::ERROR_SERIALIZED_FILE_CANNOT_BE_READ
86
-    * @see FileHelper::ERROR_SERIALIZED_FILE_UNSERIALZE_FAILED
87
-    */
76
+    /**
77
+     * Opens a serialized file and returns the unserialized data.
78
+     *
79
+     * @param string|PathInfoInterface|SplFileInfo $file
80
+     * @throws FileHelper_Exception
81
+     * @return array<int|string,mixed>
82
+     * @see SerializedFile::parse()
83
+     * 
84
+     * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
85
+     * @see FileHelper::ERROR_SERIALIZED_FILE_CANNOT_BE_READ
86
+     * @see FileHelper::ERROR_SERIALIZED_FILE_UNSERIALZE_FAILED
87
+     */
88 88
     public static function parseSerializedFile($file) : array
89 89
     {
90 90
         return SerializedFile::factory($file)->parse();
@@ -103,13 +103,13 @@  discard block
 block discarded – undo
103 103
         return FolderTree::delete($rootFolder);
104 104
     }
105 105
     
106
-   /**
107
-    * Create a folder, if it does not exist yet.
108
-    *  
109
-    * @param string|PathInfoInterface $path
110
-    * @throws FileHelper_Exception
111
-    * @see FileHelper::ERROR_CANNOT_CREATE_FOLDER
112
-    */
106
+    /**
107
+     * Create a folder, if it does not exist yet.
108
+     *  
109
+     * @param string|PathInfoInterface $path
110
+     * @throws FileHelper_Exception
111
+     * @see FileHelper::ERROR_CANNOT_CREATE_FOLDER
112
+     */
113 113
     public static function createFolder($path) : FolderInfo
114 114
     {
115 115
         return self::getFolderInfo($path)->create();
@@ -138,36 +138,36 @@  discard block
 block discarded – undo
138 138
         FolderTree::copy($source, $target);
139 139
     }
140 140
     
141
-   /**
142
-    * Copies a file to the target location. Includes checks
143
-    * for most error sources, like the source file not being
144
-    * readable. Automatically creates the target folder if it
145
-    * does not exist yet.
146
-    * 
147
-    * @param string|PathInfoInterface|SplFileInfo $sourcePath
148
-    * @param string|PathInfoInterface|SplFileInfo $targetPath
149
-    * @throws FileHelper_Exception
150
-    * 
151
-    * @see FileHelper::ERROR_CANNOT_CREATE_FOLDER
152
-    * @see FileHelper::ERROR_SOURCE_FILE_NOT_FOUND
153
-    * @see FileHelper::ERROR_SOURCE_FILE_NOT_READABLE
154
-    * @see FileHelper::ERROR_TARGET_COPY_FOLDER_NOT_WRITABLE
155
-    * @see FileHelper::ERROR_CANNOT_COPY_FILE
156
-    */
141
+    /**
142
+     * Copies a file to the target location. Includes checks
143
+     * for most error sources, like the source file not being
144
+     * readable. Automatically creates the target folder if it
145
+     * does not exist yet.
146
+     * 
147
+     * @param string|PathInfoInterface|SplFileInfo $sourcePath
148
+     * @param string|PathInfoInterface|SplFileInfo $targetPath
149
+     * @throws FileHelper_Exception
150
+     * 
151
+     * @see FileHelper::ERROR_CANNOT_CREATE_FOLDER
152
+     * @see FileHelper::ERROR_SOURCE_FILE_NOT_FOUND
153
+     * @see FileHelper::ERROR_SOURCE_FILE_NOT_READABLE
154
+     * @see FileHelper::ERROR_TARGET_COPY_FOLDER_NOT_WRITABLE
155
+     * @see FileHelper::ERROR_CANNOT_COPY_FILE
156
+     */
157 157
     public static function copyFile($sourcePath, $targetPath) : void
158 158
     {
159 159
         self::getFileInfo($sourcePath)->copyTo($targetPath);
160 160
     }
161 161
     
162
-   /**
163
-    * Deletes the target file. Ignored if it cannot be found,
164
-    * and throws an exception if it fails.
165
-    * 
166
-    * @param string|PathInfoInterface|SplFileInfo $filePath
167
-    * @throws FileHelper_Exception
168
-    * 
169
-    * @see FileHelper::ERROR_CANNOT_DELETE_FILE
170
-    */
162
+    /**
163
+     * Deletes the target file. Ignored if it cannot be found,
164
+     * and throws an exception if it fails.
165
+     * 
166
+     * @param string|PathInfoInterface|SplFileInfo $filePath
167
+     * @throws FileHelper_Exception
168
+     * 
169
+     * @see FileHelper::ERROR_CANNOT_DELETE_FILE
170
+     */
171 171
     public static function deleteFile($filePath) : void
172 172
     {
173 173
         self::getFileInfo($filePath)->delete();
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
      */
289 289
     public static function isPHPFile($filePath) : bool
290 290
     {
291
-    	return self::getExtension($filePath) === 'php';
291
+        return self::getExtension($filePath) === 'php';
292 292
     }
293 293
 
294 294
     /**
@@ -354,16 +354,16 @@  discard block
 block discarded – undo
354 354
             ->parse();
355 355
     }
356 356
     
357
-   /**
358
-    * Corrects common formatting mistakes when users enter
359
-    * file names, like too many spaces, dots and the like.
360
-    * 
361
-    * NOTE: if the file name contains a path, the path is
362
-    * stripped, leaving only the file name.
363
-    * 
364
-    * @param string $name
365
-    * @return string
366
-    */
357
+    /**
358
+     * Corrects common formatting mistakes when users enter
359
+     * file names, like too many spaces, dots and the like.
360
+     * 
361
+     * NOTE: if the file name contains a path, the path is
362
+     * stripped, leaving only the file name.
363
+     * 
364
+     * @param string $name
365
+     * @return string
366
+     */
367 367
     public static function fixFileName(string $name) : string
368 368
     {
369 369
         return NameFixer::fixName($name);
@@ -423,23 +423,23 @@  discard block
 block discarded – undo
423 423
         return self::findFiles($targetFolder, array('php'), $options);
424 424
     }
425 425
     
426
-   /**
427
-    * Finds files according to the specified options.
428
-    * 
429
-    * NOTE: This method only exists for backwards compatibility.
430
-    * Use the {@see FileHelper::createFileFinder()} method instead,
431
-    * which offers an object-oriented interface that is much easier
432
-    * to use.
433
-    *  
434
-    * @param string|PathInfoInterface|SplFileInfo $targetFolder
435
-    * @param string[] $extensions
436
-    * @param array<string,mixed> $options
437
-    * @throws FileHelper_Exception
438
-    * @return string[]
439
-    *
440
-    * @see FileHelper::createFileFinder()
441
-    * @deprecated Use the file finder instead.
442
-    */
426
+    /**
427
+     * Finds files according to the specified options.
428
+     * 
429
+     * NOTE: This method only exists for backwards compatibility.
430
+     * Use the {@see FileHelper::createFileFinder()} method instead,
431
+     * which offers an object-oriented interface that is much easier
432
+     * to use.
433
+     *  
434
+     * @param string|PathInfoInterface|SplFileInfo $targetFolder
435
+     * @param string[] $extensions
436
+     * @param array<string,mixed> $options
437
+     * @throws FileHelper_Exception
438
+     * @return string[]
439
+     *
440
+     * @see FileHelper::createFileFinder()
441
+     * @deprecated Use the file finder instead.
442
+     */
443 443
     public static function findFiles($targetFolder, array $extensions=array(), array $options=array()) : array
444 444
     {
445 445
         $finder = self::createFileFinder($targetFolder);
@@ -510,13 +510,13 @@  discard block
 block discarded – undo
510 510
         return self::$unicodeHandling;
511 511
     }
512 512
     
513
-   /**
514
-    * Normalizes the slash style in a file or folder path,
515
-    * by replacing any anti-slashes with forward slashes.
516
-    * 
517
-    * @param string $path
518
-    * @return string
519
-    */
513
+    /**
514
+     * Normalizes the slash style in a file or folder path,
515
+     * by replacing any anti-slashes with forward slashes.
516
+     * 
517
+     * @param string $path
518
+     * @return string
519
+     */
520 520
     public static function normalizePath(string $path) : string
521 521
     {
522 522
         return str_replace(array('\\', '//'), array('/', '/'), $path);
@@ -641,70 +641,70 @@  discard block
 block discarded – undo
641 641
             ->getPaths();
642 642
     }
643 643
 
644
-   /**
645
-    * Retrieves the maximum allowed upload file size, in bytes.
646
-    * Takes into account the PHP ini settings <code>post_max_size</code>
647
-    * and <code>upload_max_filesize</code>. Since these cannot
648
-    * be modified at runtime, they are the hard limits for uploads.
649
-    * 
650
-    * NOTE: Based on binary values, where 1KB = 1024 Bytes.
651
-    * 
652
-    * @return int Will return <code>-1</code> if no limit.
653
-    */
644
+    /**
645
+     * Retrieves the maximum allowed upload file size, in bytes.
646
+     * Takes into account the PHP ini settings <code>post_max_size</code>
647
+     * and <code>upload_max_filesize</code>. Since these cannot
648
+     * be modified at runtime, they are the hard limits for uploads.
649
+     * 
650
+     * NOTE: Based on binary values, where 1KB = 1024 Bytes.
651
+     * 
652
+     * @return int Will return <code>-1</code> if no limit.
653
+     */
654 654
     public static function getMaxUploadFilesize() : int
655 655
     {
656 656
         return UploadFileSizeInfo::getFileSize();
657 657
     }
658 658
    
659
-   /**
660
-    * Makes a path relative using a folder depth: will reduce the
661
-    * length of the path so that only the amount of folders defined
662
-    * in the <code>$depth</code> attribute are shown below the actual
663
-    * folder or file in the path.
664
-    *  
665
-    * @param string  $path The absolute or relative path
666
-    * @param int $depth The folder depth to reduce the path to
667
-    * @return string
668
-    */
659
+    /**
660
+     * Makes a path relative using a folder depth: will reduce the
661
+     * length of the path so that only the amount of folders defined
662
+     * in the <code>$depth</code> attribute are shown below the actual
663
+     * folder or file in the path.
664
+     *  
665
+     * @param string  $path The absolute or relative path
666
+     * @param int $depth The folder depth to reduce the path to
667
+     * @return string
668
+     */
669 669
     public static function relativizePathByDepth(string $path, int $depth=2) : string
670 670
     {
671 671
         return PathRelativizer::relativizeByDepth($path, $depth);
672 672
     }
673 673
     
674
-   /**
675
-    * Makes the specified path relative to another path,
676
-    * by removing one from the other if found. Also 
677
-    * normalizes the path to use forward slashes. 
678
-    * 
679
-    * Example:
680
-    * 
681
-    * <pre>
682
-    * relativizePath('c:\some\folder\to\file.txt', 'c:\some\folder');
683
-    * </pre>
684
-    * 
685
-    * Result: <code>to/file.txt</code>
686
-    * 
687
-    * @param string $path
688
-    * @param string $relativeTo
689
-    * @return string
690
-    */
674
+    /**
675
+     * Makes the specified path relative to another path,
676
+     * by removing one from the other if found. Also 
677
+     * normalizes the path to use forward slashes. 
678
+     * 
679
+     * Example:
680
+     * 
681
+     * <pre>
682
+     * relativizePath('c:\some\folder\to\file.txt', 'c:\some\folder');
683
+     * </pre>
684
+     * 
685
+     * Result: <code>to/file.txt</code>
686
+     * 
687
+     * @param string $path
688
+     * @param string $relativeTo
689
+     * @return string
690
+     */
691 691
     public static function relativizePath(string $path, string $relativeTo) : string
692 692
     {
693 693
         return PathRelativizer::relativize($path, $relativeTo);
694 694
     }
695 695
     
696
-   /**
697
-    * Checks that the target file exists, and throws an exception
698
-    * if it does not. 
699
-    * 
700
-    * @param string|SplFileInfo $path
701
-    * @param int|NULL $errorCode Optional custom error code
702
-    * @throws FileHelper_Exception
703
-    * @return string The real path to the file
704
-    * 
705
-    * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
706
-    * @see FileHelper::ERROR_REAL_PATH_NOT_FOUND
707
-    */
696
+    /**
697
+     * Checks that the target file exists, and throws an exception
698
+     * if it does not. 
699
+     * 
700
+     * @param string|SplFileInfo $path
701
+     * @param int|NULL $errorCode Optional custom error code
702
+     * @throws FileHelper_Exception
703
+     * @return string The real path to the file
704
+     * 
705
+     * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
706
+     * @see FileHelper::ERROR_REAL_PATH_NOT_FOUND
707
+     */
708 708
     public static function requireFileExists($path, ?int $errorCode=null) : string
709 709
     {
710 710
         return self::getPathInfo($path)
@@ -727,18 +727,18 @@  discard block
 block discarded – undo
727 727
             ->getPath();
728 728
     }
729 729
     
730
-   /**
731
-    * Reads a specific line number from the target file and returns its
732
-    * contents, if the file has such a line. Does so with little memory
733
-    * usage, as the file is not read entirely into memory.
734
-    * 
735
-    * @param string|PathInfoInterface|SplFileInfo $path
736
-    * @param int $lineNumber Note: 1-based; the first line is number 1.
737
-    * @return string|NULL Will return null if the requested line does not exist.
738
-    * @throws FileHelper_Exception
739
-    * 
740
-    * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
741
-    */
730
+    /**
731
+     * Reads a specific line number from the target file and returns its
732
+     * contents, if the file has such a line. Does so with little memory
733
+     * usage, as the file is not read entirely into memory.
734
+     * 
735
+     * @param string|PathInfoInterface|SplFileInfo $path
736
+     * @param int $lineNumber Note: 1-based; the first line is number 1.
737
+     * @return string|NULL Will return null if the requested line does not exist.
738
+     * @throws FileHelper_Exception
739
+     * 
740
+     * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
741
+     */
742 742
     public static function getLineFromFile($path, int $lineNumber) : ?string
743 743
     {
744 744
         return self::getFileInfo($path)->getLine($lineNumber);
@@ -804,33 +804,33 @@  discard block
 block discarded – undo
804 804
             ->getLines($amount);
805 805
     }
806 806
     
807
-   /**
808
-    * Reads all content from a file.
809
-    * 
810
-    * @param string|PathInfoInterface|SplFileInfo $filePath
811
-    * @throws FileHelper_Exception
812
-    * @return string
813
-    * 
814
-    * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
815
-    * @see FileHelper::ERROR_CANNOT_READ_FILE_CONTENTS
816
-    */
807
+    /**
808
+     * Reads all content from a file.
809
+     * 
810
+     * @param string|PathInfoInterface|SplFileInfo $filePath
811
+     * @throws FileHelper_Exception
812
+     * @return string
813
+     * 
814
+     * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
815
+     * @see FileHelper::ERROR_CANNOT_READ_FILE_CONTENTS
816
+     */
817 817
     public static function readContents($filePath) : string
818 818
     {
819 819
         return self::getFileInfo($filePath)->getContents();
820 820
     }
821 821
 
822
-   /**
823
-    * Ensures that the target path exists on disk, and is a folder.
824
-    * 
825
-    * @param string|PathInfoInterface|SplFileInfo $path
826
-    * @return string The real path, with normalized slashes.
827
-    * @throws FileHelper_Exception
828
-    * 
829
-    * @see FileHelper::normalizePath()
830
-    * 
831
-    * @see FileHelper::ERROR_FOLDER_DOES_NOT_EXIST
832
-    * @see FileHelper::ERROR_PATH_IS_NOT_A_FOLDER
833
-    */
822
+    /**
823
+     * Ensures that the target path exists on disk, and is a folder.
824
+     * 
825
+     * @param string|PathInfoInterface|SplFileInfo $path
826
+     * @return string The real path, with normalized slashes.
827
+     * @throws FileHelper_Exception
828
+     * 
829
+     * @see FileHelper::normalizePath()
830
+     * 
831
+     * @see FileHelper::ERROR_FOLDER_DOES_NOT_EXIST
832
+     * @see FileHelper::ERROR_PATH_IS_NOT_A_FOLDER
833
+     */
834 834
     public static function requireFolderExists($path) : string
835 835
     {
836 836
         return self::getFolderInfo($path)
Please login to merge, or discard this patch.