@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | * @see FileHelper_FileFinder |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -declare(strict_types = 1); |
|
| 10 | +declare(strict_types=1); |
|
| 11 | 11 | |
| 12 | 12 | namespace AppUtils; |
| 13 | 13 | |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | { |
| 59 | 59 | $real = realpath($path); |
| 60 | 60 | |
| 61 | - if($real === false) |
|
| 61 | + if ($real === false) |
|
| 62 | 62 | { |
| 63 | 63 | throw new FileHelper_Exception( |
| 64 | 64 | 'Target path does not exist', |
@@ -305,22 +305,22 @@ discard block |
||
| 305 | 305 | return $this->getAll(); |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | - protected function find(string $path, bool $isRoot=false) : void |
|
| 308 | + protected function find(string $path, bool $isRoot = false) : void |
|
| 309 | 309 | { |
| 310 | - if($isRoot) { |
|
| 310 | + if ($isRoot) { |
|
| 311 | 311 | $this->found = array(); |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | $recursive = $this->getBoolOption('recursive'); |
| 315 | 315 | |
| 316 | 316 | $d = new \DirectoryIterator($path); |
| 317 | - foreach($d as $item) |
|
| 317 | + foreach ($d as $item) |
|
| 318 | 318 | { |
| 319 | 319 | $pathname = $item->getPathname(); |
| 320 | 320 | |
| 321 | - if($item->isDir()) |
|
| 321 | + if ($item->isDir()) |
|
| 322 | 322 | { |
| 323 | - if($recursive && !$item->isDot()) { |
|
| 323 | + if ($recursive && !$item->isDot()) { |
|
| 324 | 324 | $this->find($pathname); |
| 325 | 325 | } |
| 326 | 326 | |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | |
| 330 | 330 | $file = $this->filterFile($pathname); |
| 331 | 331 | |
| 332 | - if($file !== null) |
|
| 332 | + if ($file !== null) |
|
| 333 | 333 | { |
| 334 | 334 | $this->found[] = $file; |
| 335 | 335 | } |
@@ -342,23 +342,23 @@ discard block |
||
| 342 | 342 | |
| 343 | 343 | $extension = FileHelper::getExtension($path); |
| 344 | 344 | |
| 345 | - if(!$this->filterExclusion($extension)) { |
|
| 345 | + if (!$this->filterExclusion($extension)) { |
|
| 346 | 346 | return null; |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | $path = $this->filterPath($path); |
| 350 | 350 | |
| 351 | - if($this->getOption('strip-extensions') === true) |
|
| 351 | + if ($this->getOption('strip-extensions') === true) |
|
| 352 | 352 | { |
| 353 | 353 | $path = str_replace('.'.$extension, '', $path); |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | - if($path === '') { |
|
| 356 | + if ($path === '') { |
|
| 357 | 357 | return null; |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | $replace = $this->getOption('slash-replacement'); |
| 361 | - if(!empty($replace)) { |
|
| 361 | + if (!empty($replace)) { |
|
| 362 | 362 | $path = str_replace('/', $replace, $path); |
| 363 | 363 | } |
| 364 | 364 | |
@@ -377,15 +377,15 @@ discard block |
||
| 377 | 377 | $include = $this->getOption(self::OPTION_INCLUDE_EXTENSIONS); |
| 378 | 378 | $exclude = $this->getOption(self::OPTION_EXCLUDE_EXTENSIONS); |
| 379 | 379 | |
| 380 | - if(!empty($include)) |
|
| 380 | + if (!empty($include)) |
|
| 381 | 381 | { |
| 382 | - if(!in_array($extension, $include)) { |
|
| 382 | + if (!in_array($extension, $include)) { |
|
| 383 | 383 | return false; |
| 384 | 384 | } |
| 385 | 385 | } |
| 386 | - else if(!empty($exclude)) |
|
| 386 | + else if (!empty($exclude)) |
|
| 387 | 387 | { |
| 388 | - if(in_array($extension, $exclude)) { |
|
| 388 | + if (in_array($extension, $exclude)) { |
|
| 389 | 389 | return false; |
| 390 | 390 | } |
| 391 | 391 | } |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | */ |
| 402 | 402 | protected function filterPath(string $path) : string |
| 403 | 403 | { |
| 404 | - switch($this->getStringOption(self::OPTION_PATHMODE)) |
|
| 404 | + switch ($this->getStringOption(self::OPTION_PATHMODE)) |
|
| 405 | 405 | { |
| 406 | 406 | case self::PATH_MODE_STRIP: |
| 407 | 407 | return basename($path); |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | { |
| 106 | 106 | $name = $this->getName(); |
| 107 | 107 | |
| 108 | - if($this->info->hasNamespace()) { |
|
| 108 | + if ($this->info->hasNamespace()) { |
|
| 109 | 109 | $name = $this->info->getNamespace().'\\'.$this->name; |
| 110 | 110 | } |
| 111 | 111 | |
@@ -160,12 +160,12 @@ discard block |
||
| 160 | 160 | $parts[] = 'class'; |
| 161 | 161 | $parts[] = $this->getName(); |
| 162 | 162 | |
| 163 | - if(!empty($this->extends)) { |
|
| 163 | + if (!empty($this->extends)) { |
|
| 164 | 164 | $parts[] = 'extends'; |
| 165 | 165 | $parts[] = $this->extends; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - if(!empty($this->implements)) { |
|
| 168 | + if (!empty($this->implements)) { |
|
| 169 | 169 | $parts[] = 'implements'; |
| 170 | 170 | $parts[] = implode(', ', $this->implements); |
| 171 | 171 | } |
@@ -184,9 +184,9 @@ discard block |
||
| 184 | 184 | |
| 185 | 185 | protected function analyzeCode() : void |
| 186 | 186 | { |
| 187 | - if($this->keyword == 'abstract') { |
|
| 187 | + if ($this->keyword == 'abstract') { |
|
| 188 | 188 | $this->abstract = true; |
| 189 | - } else if($this->keyword == 'final') { |
|
| 189 | + } else if ($this->keyword == 'final') { |
|
| 190 | 190 | $this->final = true; |
| 191 | 191 | } |
| 192 | 192 | |
@@ -203,16 +203,16 @@ discard block |
||
| 203 | 203 | |
| 204 | 204 | $tokenName = 'none'; |
| 205 | 205 | |
| 206 | - foreach($parts as $part) |
|
| 206 | + foreach ($parts as $part) |
|
| 207 | 207 | { |
| 208 | 208 | $part = str_replace(',', '', $part); |
| 209 | 209 | $part = trim($part); |
| 210 | - if(empty($part)) { |
|
| 210 | + if (empty($part)) { |
|
| 211 | 211 | continue; |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | $name = strtolower($part); |
| 215 | - if($name == 'extends' || $name == 'implements') { |
|
| 215 | + if ($name == 'extends' || $name == 'implements') { |
|
| 216 | 216 | $tokenName = $name; |
| 217 | 217 | continue; |
| 218 | 218 | } |
@@ -222,13 +222,13 @@ discard block |
||
| 222 | 222 | |
| 223 | 223 | $this->implements = $tokens['implements']; |
| 224 | 224 | |
| 225 | - if(!empty($this->implements)) { |
|
| 225 | + if (!empty($this->implements)) { |
|
| 226 | 226 | usort($this->implements, function(string $a, string $b) { |
| 227 | 227 | return strnatcasecmp($a, $b); |
| 228 | 228 | }); |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | - if(!empty($tokens['extends'])) { |
|
| 231 | + if (!empty($tokens['extends'])) { |
|
| 232 | 232 | $this->extends = $tokens['extends'][0]; |
| 233 | 233 | } |
| 234 | 234 | } |
@@ -104,11 +104,11 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | public static function fromClosure(Closure $closure, $origin) : NamedClosure |
| 106 | 106 | { |
| 107 | - if(is_object($origin)) |
|
| 107 | + if (is_object($origin)) |
|
| 108 | 108 | { |
| 109 | 109 | $description = get_class($origin); |
| 110 | 110 | } |
| 111 | - else if(is_array($origin)) |
|
| 111 | + else if (is_array($origin)) |
|
| 112 | 112 | { |
| 113 | 113 | $description = ConvertHelper::callback2string($origin); |
| 114 | 114 | } |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | * @param string|object $origin Optional origin. If not specified, the object and method name are used instead. |
| 127 | 127 | * @return NamedClosure |
| 128 | 128 | */ |
| 129 | - public static function fromObject(object $object, string $method, $origin='') : NamedClosure |
|
| 129 | + public static function fromObject(object $object, string $method, $origin = '') : NamedClosure |
|
| 130 | 130 | { |
| 131 | 131 | return self::fromArray(array($object, $method), $origin); |
| 132 | 132 | } |
@@ -136,11 +136,11 @@ discard block |
||
| 136 | 136 | * @param string|object $origin |
| 137 | 137 | * @return NamedClosure |
| 138 | 138 | */ |
| 139 | - public static function fromArray(array $callback, $origin='') : NamedClosure |
|
| 139 | + public static function fromArray(array $callback, $origin = '') : NamedClosure |
|
| 140 | 140 | { |
| 141 | - if(empty($origin)) { |
|
| 141 | + if (empty($origin)) { |
|
| 142 | 142 | $origin = ConvertHelper::callback2string($callback); |
| 143 | - } else if(is_object($origin)) { |
|
| 143 | + } else if (is_object($origin)) { |
|
| 144 | 144 | $origin = get_class($origin); |
| 145 | 145 | } |
| 146 | 146 | |