@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | $this->url = $this->helper->getURL().'/'.$this->relativePath; |
| 21 | 21 | |
| 22 | 22 | $path = $this->helper->getPath(); |
| 23 | - if(!empty($relativePath)) { |
|
| 23 | + if (!empty($relativePath)) { |
|
| 24 | 24 | $path .= $this->helper->getSlash().$this->relativePath; |
| 25 | 25 | } |
| 26 | 26 | |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | // this is relevant). |
| 31 | 31 | $this->path = realpath($path); |
| 32 | 32 | |
| 33 | - if(!$this->path || !file_exists($this->path)) { |
|
| 33 | + if (!$this->path || !file_exists($this->path)) { |
|
| 34 | 34 | throw new SVNHelper_Exception( |
| 35 | 35 | 'File not found', |
| 36 | 36 | sprintf( |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | |
| 139 | 139 | public function runAdd() |
| 140 | 140 | { |
| 141 | - if(!$this->isVersioned()) { |
|
| 141 | + if (!$this->isVersioned()) { |
|
| 142 | 142 | $this->createAdd()->execute(); |
| 143 | 143 | $this->clearCache(); |
| 144 | 144 | } |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | */ |
| 169 | 169 | public function getInfo() |
| 170 | 170 | { |
| 171 | - if(!isset($this->cache['info'])) { |
|
| 171 | + if (!isset($this->cache['info'])) { |
|
| 172 | 172 | $this->cache['info'] = $this->helper->createInfo($this); |
| 173 | 173 | } |
| 174 | 174 | |
@@ -186,12 +186,12 @@ discard block |
||
| 186 | 186 | */ |
| 187 | 187 | public function runCommit($message) |
| 188 | 188 | { |
| 189 | - if(!$this->isVersioned()) { |
|
| 189 | + if (!$this->isVersioned()) { |
|
| 190 | 190 | $this->log('Adding the unversioned file.'); |
| 191 | 191 | $this->runAdd(); |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - if(!$this->isCommitted()) { |
|
| 194 | + if (!$this->isCommitted()) { |
|
| 195 | 195 | $this->createCommit($message)->execute(); |
| 196 | 196 | $this->clearCache(); |
| 197 | 197 | } |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | |
| 225 | 225 | public function requireIsFile() : SVNHelper_Target_File |
| 226 | 226 | { |
| 227 | - if($this instanceof SVNHelper_Target_File) |
|
| 227 | + if ($this instanceof SVNHelper_Target_File) |
|
| 228 | 228 | { |
| 229 | 229 | return $this; |
| 230 | 230 | } |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | |
| 239 | 239 | public function requireIsFolder() : SVNHelper_Target_Folder |
| 240 | 240 | { |
| 241 | - if($this instanceof SVNHelper_Target_Folder) |
|
| 241 | + if ($this instanceof SVNHelper_Target_Folder) |
|
| 242 | 242 | { |
| 243 | 243 | return $this; |
| 244 | 244 | } |
@@ -119,7 +119,7 @@ |
||
| 119 | 119 | public function hasAnyErrorCode(array $codes) : bool |
| 120 | 120 | { |
| 121 | 121 | $items = array(); |
| 122 | - foreach($codes as $code) { |
|
| 122 | + foreach ($codes as $code) { |
|
| 123 | 123 | $items[] = $this->filterCode($code); |
| 124 | 124 | } |
| 125 | 125 | |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | { |
| 74 | 74 | $string = (string)$string; |
| 75 | 75 | |
| 76 | - if(!empty($string)) |
|
| 76 | + if (!empty($string)) |
|
| 77 | 77 | { |
| 78 | 78 | $this->strings[] = $string; |
| 79 | 79 | } |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | { |
| 92 | 92 | $flattened = (string)$string; |
| 93 | 93 | |
| 94 | - if($flattened !== "") |
|
| 94 | + if ($flattened !== "") |
|
| 95 | 95 | { |
| 96 | 96 | $this->add($this->noSeparator.$flattened); |
| 97 | 97 | } |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | */ |
| 158 | 158 | public function t(string $format, ...$arguments) : StringBuilder |
| 159 | 159 | { |
| 160 | - if(!class_exists('\AppLocalize\Localization')) |
|
| 160 | + if (!class_exists('\AppLocalize\Localization')) |
|
| 161 | 161 | { |
| 162 | 162 | array_unshift($arguments, $format); |
| 163 | 163 | return $this->sf(...$arguments); |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | { |
| 183 | 183 | unset($context); // Only used by the localization parser. |
| 184 | 184 | |
| 185 | - if(!class_exists('\AppLocalize\Localization')) |
|
| 185 | + if (!class_exists('\AppLocalize\Localization')) |
|
| 186 | 186 | { |
| 187 | 187 | array_unshift($arguments, $format); |
| 188 | 188 | return $this->sf(...$arguments); |
@@ -340,9 +340,9 @@ discard block |
||
| 340 | 340 | * @param StringBuilder_Interface|string|NULL $content |
| 341 | 341 | * @return $this |
| 342 | 342 | */ |
| 343 | - public function para($content=null) : StringBuilder |
|
| 343 | + public function para($content = null) : StringBuilder |
|
| 344 | 344 | { |
| 345 | - if($content !== null) { |
|
| 345 | + if ($content !== null) { |
|
| 346 | 346 | return $this->html('<p>')->nospace($content)->html('</p>'); |
| 347 | 347 | } |
| 348 | 348 | |
@@ -358,21 +358,21 @@ discard block |
||
| 358 | 358 | * @param AttributeCollection|null $attributes |
| 359 | 359 | * @return $this |
| 360 | 360 | */ |
| 361 | - public function link(string $label, string $url, bool $newTab=false, ?AttributeCollection $attributes=null) : StringBuilder |
|
| 361 | + public function link(string $label, string $url, bool $newTab = false, ?AttributeCollection $attributes = null) : StringBuilder |
|
| 362 | 362 | { |
| 363 | 363 | return $this->add($this->createLink($label, $url, $newTab, $attributes)); |
| 364 | 364 | } |
| 365 | 365 | |
| 366 | - private function createLink(string $label, string $url, bool $newTab=false, ?AttributeCollection $attributes=null) : HTMLTag |
|
| 366 | + private function createLink(string $label, string $url, bool $newTab = false, ?AttributeCollection $attributes = null) : HTMLTag |
|
| 367 | 367 | { |
| 368 | - if($attributes === null) |
|
| 368 | + if ($attributes === null) |
|
| 369 | 369 | { |
| 370 | 370 | $attributes = AttributeCollection::create(); |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | $attributes->href($url); |
| 374 | 374 | |
| 375 | - if($newTab) |
|
| 375 | + if ($newTab) |
|
| 376 | 376 | { |
| 377 | 377 | $attributes->target(); |
| 378 | 378 | } |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | ->addText($label); |
| 382 | 382 | } |
| 383 | 383 | |
| 384 | - public function linkOpen(string $url, bool $newTab=false, ?AttributeCollection $attributes=null) : StringBuilder |
|
| 384 | + public function linkOpen(string $url, bool $newTab = false, ?AttributeCollection $attributes = null) : StringBuilder |
|
| 385 | 385 | { |
| 386 | 386 | return $this->html($this->createLink('', $url, $newTab, $attributes)->renderOpen()); |
| 387 | 387 | } |
@@ -425,7 +425,7 @@ discard block |
||
| 425 | 425 | */ |
| 426 | 426 | public function spanned($string, $classes) : StringBuilder |
| 427 | 427 | { |
| 428 | - if(!is_array($classes)) |
|
| 428 | + if (!is_array($classes)) |
|
| 429 | 429 | { |
| 430 | 430 | $classes = array((string)$classes); |
| 431 | 431 | } |
@@ -443,7 +443,7 @@ discard block |
||
| 443 | 443 | * @return $this |
| 444 | 444 | * @throws ConvertHelper_Exception |
| 445 | 445 | */ |
| 446 | - public function bool($value, bool $yesNo=false) : StringBuilder |
|
| 446 | + public function bool($value, bool $yesNo = false) : StringBuilder |
|
| 447 | 447 | { |
| 448 | 448 | return $this->add(ConvertHelper::bool2string($value, $yesNo)); |
| 449 | 449 | } |
@@ -462,7 +462,7 @@ discard block |
||
| 462 | 462 | */ |
| 463 | 463 | public function ifTrue(bool $condition, $content) : StringBuilder |
| 464 | 464 | { |
| 465 | - if($condition === true) |
|
| 465 | + if ($condition === true) |
|
| 466 | 466 | { |
| 467 | 467 | $this->add($this->renderContent($content)); |
| 468 | 468 | } |
@@ -484,7 +484,7 @@ discard block |
||
| 484 | 484 | */ |
| 485 | 485 | public function ifFalse(bool $condition, $string) : StringBuilder |
| 486 | 486 | { |
| 487 | - if($condition === false) |
|
| 487 | + if ($condition === false) |
|
| 488 | 488 | { |
| 489 | 489 | $this->add($this->renderContent($string)); |
| 490 | 490 | } |
@@ -568,7 +568,7 @@ discard block |
||
| 568 | 568 | */ |
| 569 | 569 | public function ifOr(bool $condition, $ifTrue, $ifFalse) : StringBuilder |
| 570 | 570 | { |
| 571 | - if($condition === true) |
|
| 571 | + if ($condition === true) |
|
| 572 | 572 | { |
| 573 | 573 | return $this->add($this->renderContent($ifTrue)); |
| 574 | 574 | } |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | */ |
| 29 | 29 | public function __construct($path) |
| 30 | 30 | { |
| 31 | - if($path instanceof FolderInfo) |
|
| 31 | + if ($path instanceof FolderInfo) |
|
| 32 | 32 | { |
| 33 | 33 | $this->folder = $path; |
| 34 | 34 | } |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | ); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - public function makeRecursive(bool $recursive=true) : self |
|
| 49 | + public function makeRecursive(bool $recursive = true) : self |
|
| 50 | 50 | { |
| 51 | 51 | return $this->setOption(self::OPTION_RECURSIVE, $recursive); |
| 52 | 52 | } |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | |
| 77 | 77 | $result = array(); |
| 78 | 78 | |
| 79 | - foreach($this->folders as $folder) |
|
| 79 | + foreach ($this->folders as $folder) |
|
| 80 | 80 | { |
| 81 | 81 | $result[] = $this->resolvePath($folder); |
| 82 | 82 | } |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | private function resolvePath(FolderInfo $folder) : string |
| 98 | 98 | { |
| 99 | - if(!$this->isPathModeAbsolute()) |
|
| 99 | + if (!$this->isPathModeAbsolute()) |
|
| 100 | 100 | { |
| 101 | 101 | return $folder->getRelativeTo($this->folder); |
| 102 | 102 | } |
@@ -117,9 +117,9 @@ discard block |
||
| 117 | 117 | { |
| 118 | 118 | $d = new DirectoryIterator($folder->getPath()); |
| 119 | 119 | |
| 120 | - foreach($d as $item) |
|
| 120 | + foreach ($d as $item) |
|
| 121 | 121 | { |
| 122 | - if($item->isDir() && !$item->isDot()) |
|
| 122 | + if ($item->isDir() && !$item->isDot()) |
|
| 123 | 123 | { |
| 124 | 124 | $this->processFolder(FileHelper::getFolderInfo($item->getPathname())); |
| 125 | 125 | } |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | { |
| 141 | 141 | $this->folders[] = $folder; |
| 142 | 142 | |
| 143 | - if($this->isRecursive()) |
|
| 143 | + if ($this->isRecursive()) |
|
| 144 | 144 | { |
| 145 | 145 | $this->scanFolder($folder); |
| 146 | 146 | } |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | ) |
| 51 | 51 | ); |
| 52 | 52 | |
| 53 | - if($result !== false) { |
|
| 53 | + if ($result !== false) { |
|
| 54 | 54 | return $result; |
| 55 | 55 | } |
| 56 | 56 | |
@@ -59,7 +59,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 126 | 126 | |
| 127 | 127 | proc_close($process); |
| 128 | 128 | |
| 129 | - if($stdout === false) |
|
| 129 | + if ($stdout === false) |
|
| 130 | 130 | { |
| 131 | 131 | return ''; |
| 132 | 132 | } |
@@ -27,12 +27,12 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | |
@@ -35,7 +35,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -47,15 +47,15 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |