@@ -29,26 +29,26 @@ |
||
| 29 | 29 | |
| 30 | 30 | protected function _validate() |
| 31 | 31 | { |
| 32 | - if(!is_string($this->value)) { |
|
| 32 | + if (!is_string($this->value)) { |
|
| 33 | 33 | return ''; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | $value = trim($this->value); |
| 37 | 37 | |
| 38 | - if(empty($value)) { |
|
| 38 | + if (empty($value)) { |
|
| 39 | 39 | return ''; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | // strictly validate for objects? |
| 43 | - if($this->getBoolOption('arrays') === false) |
|
| 43 | + if ($this->getBoolOption('arrays') === false) |
|
| 44 | 44 | { |
| 45 | - if(is_object(json_decode($value))) { |
|
| 45 | + if (is_object(json_decode($value))) { |
|
| 46 | 46 | return $value; |
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | else |
| 50 | 50 | { |
| 51 | - if(is_array(json_decode($value, true))) { |
|
| 51 | + if (is_array(json_decode($value, true))) { |
|
| 52 | 52 | return $value; |
| 53 | 53 | } |
| 54 | 54 | } |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | protected function _validate() |
| 29 | 29 | { |
| 30 | - if(!is_scalar($this->value)) { |
|
| 30 | + if (!is_scalar($this->value)) { |
|
| 31 | 31 | return null; |
| 32 | 32 | } |
| 33 | 33 | |
@@ -35,13 +35,13 @@ discard block |
||
| 35 | 35 | // is a boolan, which is converted to an integer when |
| 36 | 36 | // converted to string, which in turn can be validated |
| 37 | 37 | // with a regex. |
| 38 | - if(is_bool($this->value)) { |
|
| 38 | + if (is_bool($this->value)) { |
|
| 39 | 39 | return null; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | $value = (string)$this->value; |
| 43 | 43 | |
| 44 | - if(preg_match($this->getStringOption('regex'), $value)) { |
|
| 44 | + if (preg_match($this->getStringOption('regex'), $value)) { |
|
| 45 | 45 | return $value; |
| 46 | 46 | } |
| 47 | 47 | |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | |
| 30 | 30 | protected function _validate() |
| 31 | 31 | { |
| 32 | - if(in_array($this->value, $this->getArrayOption('values'))) { |
|
| 32 | + if (in_array($this->value, $this->getArrayOption('values'))) { |
|
| 33 | 33 | return $this->value; |
| 34 | 34 | } |
| 35 | 35 | |
@@ -40,7 +40,7 @@ |
||
| 40 | 40 | str_replace(' ', '-', $this->type) |
| 41 | 41 | ); |
| 42 | 42 | |
| 43 | - if($this->info->getBoolOption('prepend-type') && !$this->info->isNull()) |
|
| 43 | + if ($this->info->getBoolOption('prepend-type') && !$this->info->isNull()) |
|
| 44 | 44 | { |
| 45 | 45 | $typeLabel = '<span style="color:#1c2eb1" class="variable-type">'.$this->info->getType().'</span> '; |
| 46 | 46 | $converted = $typeLabel.' '.$converted; |
@@ -107,13 +107,13 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | protected function detectAttributes() |
| 109 | 109 | { |
| 110 | - if(!$this->options['@attributes']) { |
|
| 110 | + if (!$this->options['@attributes']) { |
|
| 111 | 111 | return; |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | $attributes = $this->subject->attributes(); |
| 115 | 115 | |
| 116 | - if(!empty($attributes)) |
|
| 116 | + if (!empty($attributes)) |
|
| 117 | 117 | { |
| 118 | 118 | $this->result['@attributes'] = array_map('strval', iterator_to_array($attributes)); |
| 119 | 119 | } |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | $children = $this->subject; |
| 125 | 125 | $depth = $this->options['depth'] - 1; |
| 126 | 126 | |
| 127 | - if($depth <= 0) |
|
| 127 | + if ($depth <= 0) |
|
| 128 | 128 | { |
| 129 | 129 | $children = []; |
| 130 | 130 | } |
@@ -137,9 +137,9 @@ discard block |
||
| 137 | 137 | |
| 138 | 138 | $decorator->options = ['depth' => $depth] + $this->options; |
| 139 | 139 | |
| 140 | - if(isset($this->result[$name])) |
|
| 140 | + if (isset($this->result[$name])) |
|
| 141 | 141 | { |
| 142 | - if(!is_array($this->result[$name])) |
|
| 142 | + if (!is_array($this->result[$name])) |
|
| 143 | 143 | { |
| 144 | 144 | $this->result[$name] = [$this->result[$name]]; |
| 145 | 145 | } |
@@ -158,9 +158,9 @@ discard block |
||
| 158 | 158 | // json encode non-whitespace element simplexml text values. |
| 159 | 159 | $text = trim((string)$this->subject); |
| 160 | 160 | |
| 161 | - if(strlen($text)) |
|
| 161 | + if (strlen($text)) |
|
| 162 | 162 | { |
| 163 | - if($this->options['@text']) |
|
| 163 | + if ($this->options['@text']) |
|
| 164 | 164 | { |
| 165 | 165 | $this->result['@text'] = $text; |
| 166 | 166 | } |
@@ -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 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | { |
| 56 | 56 | $real = realpath($path); |
| 57 | 57 | |
| 58 | - if($real === false) |
|
| 58 | + if ($real === false) |
|
| 59 | 59 | { |
| 60 | 60 | throw new FileHelper_Exception( |
| 61 | 61 | 'Target path does not exist', |
@@ -290,22 +290,22 @@ discard block |
||
| 290 | 290 | return $this->getAll(); |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | - protected function find(string $path, bool $isRoot=false) : void |
|
| 293 | + protected function find(string $path, bool $isRoot = false) : void |
|
| 294 | 294 | { |
| 295 | - if($isRoot) { |
|
| 295 | + if ($isRoot) { |
|
| 296 | 296 | $this->found = array(); |
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | $recursive = $this->getBoolOption('recursive'); |
| 300 | 300 | |
| 301 | 301 | $d = new \DirectoryIterator($path); |
| 302 | - foreach($d as $item) |
|
| 302 | + foreach ($d as $item) |
|
| 303 | 303 | { |
| 304 | 304 | $pathname = $item->getPathname(); |
| 305 | 305 | |
| 306 | - if($item->isDir()) |
|
| 306 | + if ($item->isDir()) |
|
| 307 | 307 | { |
| 308 | - if($recursive && !$item->isDot()) { |
|
| 308 | + if ($recursive && !$item->isDot()) { |
|
| 309 | 309 | $this->find($pathname); |
| 310 | 310 | } |
| 311 | 311 | |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | |
| 315 | 315 | $file = $this->filterFile($pathname); |
| 316 | 316 | |
| 317 | - if($file !== null) |
|
| 317 | + if ($file !== null) |
|
| 318 | 318 | { |
| 319 | 319 | $this->found[] = $file; |
| 320 | 320 | } |
@@ -327,23 +327,23 @@ discard block |
||
| 327 | 327 | |
| 328 | 328 | $extension = FileHelper::getExtension($path); |
| 329 | 329 | |
| 330 | - if(!$this->filterExclusion($extension)) { |
|
| 330 | + if (!$this->filterExclusion($extension)) { |
|
| 331 | 331 | return null; |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | $path = $this->filterPath($path); |
| 335 | 335 | |
| 336 | - if($this->getOption('strip-extensions') === true) |
|
| 336 | + if ($this->getOption('strip-extensions') === true) |
|
| 337 | 337 | { |
| 338 | 338 | $path = str_replace('.'.$extension, '', $path); |
| 339 | 339 | } |
| 340 | 340 | |
| 341 | - if($path === '') { |
|
| 341 | + if ($path === '') { |
|
| 342 | 342 | return null; |
| 343 | 343 | } |
| 344 | 344 | |
| 345 | 345 | $replace = $this->getOption('slash-replacement'); |
| 346 | - if(!empty($replace)) { |
|
| 346 | + if (!empty($replace)) { |
|
| 347 | 347 | $path = str_replace('/', $replace, $path); |
| 348 | 348 | } |
| 349 | 349 | |
@@ -362,15 +362,15 @@ discard block |
||
| 362 | 362 | $include = $this->getOption('include-extensions'); |
| 363 | 363 | $exclude = $this->getOption('exclude-extensions'); |
| 364 | 364 | |
| 365 | - if(!empty($include)) |
|
| 365 | + if (!empty($include)) |
|
| 366 | 366 | { |
| 367 | - if(!in_array($extension, $include)) { |
|
| 367 | + if (!in_array($extension, $include)) { |
|
| 368 | 368 | return false; |
| 369 | 369 | } |
| 370 | 370 | } |
| 371 | - else if(!empty($exclude)) |
|
| 371 | + else if (!empty($exclude)) |
|
| 372 | 372 | { |
| 373 | - if(in_array($extension, $exclude)) { |
|
| 373 | + if (in_array($extension, $exclude)) { |
|
| 374 | 374 | return false; |
| 375 | 375 | } |
| 376 | 376 | } |
@@ -386,7 +386,7 @@ discard block |
||
| 386 | 386 | */ |
| 387 | 387 | protected function filterPath(string $path) : string |
| 388 | 388 | { |
| 389 | - switch($this->getStringOption('pathmode')) |
|
| 389 | + switch ($this->getStringOption('pathmode')) |
|
| 390 | 390 | { |
| 391 | 391 | case self::PATH_MODE_STRIP: |
| 392 | 392 | return basename($path); |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | public function addLimitParam(string $name) : Request_URLComparer |
| 81 | 81 | { |
| 82 | - if(!in_array($name, $this->limitParams)) { |
|
| 82 | + if (!in_array($name, $this->limitParams)) { |
|
| 83 | 83 | $this->limitParams[] = $name; |
| 84 | 84 | } |
| 85 | 85 | |
@@ -88,14 +88,14 @@ discard block |
||
| 88 | 88 | |
| 89 | 89 | public function addLimitParams(array $names) : Request_URLComparer |
| 90 | 90 | { |
| 91 | - foreach($names as $name) { |
|
| 91 | + foreach ($names as $name) { |
|
| 92 | 92 | $this->addLimitParam($name); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | return $this; |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - public function setIgnoreFragment(bool $ignore=true) : Request_URLComparer |
|
| 98 | + public function setIgnoreFragment(bool $ignore = true) : Request_URLComparer |
|
| 99 | 99 | { |
| 100 | 100 | $this->ignoreFragment = $ignore; |
| 101 | 101 | return $this; |
@@ -121,13 +121,13 @@ discard block |
||
| 121 | 121 | 'query' |
| 122 | 122 | ); |
| 123 | 123 | |
| 124 | - if(!$this->ignoreFragment) { |
|
| 124 | + if (!$this->ignoreFragment) { |
|
| 125 | 125 | $keys[] = 'fragment'; |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - foreach($keys as $key) |
|
| 128 | + foreach ($keys as $key) |
|
| 129 | 129 | { |
| 130 | - if(!$this->compareKey($key)) { |
|
| 130 | + if (!$this->compareKey($key)) { |
|
| 131 | 131 | return false; |
| 132 | 132 | } |
| 133 | 133 | } |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | |
| 143 | 143 | $filter = 'filter_'.$key; |
| 144 | 144 | |
| 145 | - if(method_exists($this, $filter)) |
|
| 145 | + if (method_exists($this, $filter)) |
|
| 146 | 146 | { |
| 147 | 147 | $sVal = $this->$filter($sVal); |
| 148 | 148 | $tVal = $this->$filter($tVal); |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | protected function filter_path(string $path) : string |
| 155 | 155 | { |
| 156 | 156 | // fix double slashes in URLs |
| 157 | - while(stristr($path, '//')) { |
|
| 157 | + while (stristr($path, '//')) { |
|
| 158 | 158 | $path = str_replace('//', '/', $path); |
| 159 | 159 | } |
| 160 | 160 | |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | |
| 164 | 164 | protected function filter_query(string $query) : string |
| 165 | 165 | { |
| 166 | - if(empty($query)) { |
|
| 166 | + if (empty($query)) { |
|
| 167 | 167 | return ''; |
| 168 | 168 | } |
| 169 | 169 | |
@@ -178,15 +178,15 @@ discard block |
||
| 178 | 178 | |
| 179 | 179 | protected function limitParams(array $params) : array |
| 180 | 180 | { |
| 181 | - if(empty($this->limitParams)) { |
|
| 181 | + if (empty($this->limitParams)) { |
|
| 182 | 182 | return $params; |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | $keep = array(); |
| 186 | 186 | |
| 187 | - foreach($this->limitParams as $name) |
|
| 187 | + foreach ($this->limitParams as $name) |
|
| 188 | 188 | { |
| 189 | - if(isset($params[$name])) { |
|
| 189 | + if (isset($params[$name])) { |
|
| 190 | 190 | $keep[$name] = $params[$name]; |
| 191 | 191 | } |
| 192 | 192 | } |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | protected function __construct($subject) |
| 63 | 63 | { |
| 64 | - if(is_array($subject)) |
|
| 64 | + if (is_array($subject)) |
|
| 65 | 65 | { |
| 66 | 66 | $this->parseSerialized($subject); |
| 67 | 67 | } |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | */ |
| 116 | 116 | public function getPrevious() : ConvertHelper_ThrowableInfo |
| 117 | 117 | { |
| 118 | - if(isset($this->previous)) { |
|
| 118 | + if (isset($this->previous)) { |
|
| 119 | 119 | return $this->previous; |
| 120 | 120 | } |
| 121 | 121 | |
@@ -140,18 +140,18 @@ discard block |
||
| 140 | 140 | |
| 141 | 141 | $string = 'Exception'; |
| 142 | 142 | |
| 143 | - if($this->hasCode()) { |
|
| 143 | + if ($this->hasCode()) { |
|
| 144 | 144 | $string .= ' #'.$this->code; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | $string .= ': '.$this->getMessage().PHP_EOL; |
| 148 | 148 | |
| 149 | - foreach($calls as $call) |
|
| 149 | + foreach ($calls as $call) |
|
| 150 | 150 | { |
| 151 | 151 | $string .= $call->toString().PHP_EOL; |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - if($this->hasPrevious()) |
|
| 154 | + if ($this->hasPrevious()) |
|
| 155 | 155 | { |
| 156 | 156 | $string .= PHP_EOL.PHP_EOL. |
| 157 | 157 | 'Previous error:'.PHP_EOL.PHP_EOL. |
@@ -242,11 +242,11 @@ discard block |
||
| 242 | 242 | 'previous' => null, |
| 243 | 243 | ); |
| 244 | 244 | |
| 245 | - if($this->hasPrevious()) { |
|
| 246 | - $result['previous'] = $this->previous->serialize(); |
|
| 245 | + if ($this->hasPrevious()) { |
|
| 246 | + $result['previous'] = $this->previous->serialize(); |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | - foreach($this->calls as $call) |
|
| 249 | + foreach ($this->calls as $call) |
|
| 250 | 250 | { |
| 251 | 251 | $result['calls'][] = $call->serialize(); |
| 252 | 252 | } |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | public function getFolderDepth() : int |
| 276 | 276 | { |
| 277 | 277 | $depth = $this->getOption('folder-depth'); |
| 278 | - if(!empty($depth)) { |
|
| 278 | + if (!empty($depth)) { |
|
| 279 | 279 | return $depth; |
| 280 | 280 | } |
| 281 | 281 | |
@@ -311,12 +311,12 @@ discard block |
||
| 311 | 311 | |
| 312 | 312 | $this->setOptions($serialized['options']); |
| 313 | 313 | |
| 314 | - if(!empty($serialized['previous'])) |
|
| 314 | + if (!empty($serialized['previous'])) |
|
| 315 | 315 | { |
| 316 | 316 | $this->previous = ConvertHelper_ThrowableInfo::fromSerialized($serialized['previous']); |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | - foreach($serialized['calls'] as $def) |
|
| 319 | + foreach ($serialized['calls'] as $def) |
|
| 320 | 320 | { |
| 321 | 321 | $this->calls[] = ConvertHelper_ThrowableInfo_Call::fromSerialized($this, $def); |
| 322 | 322 | } |
@@ -328,16 +328,16 @@ discard block |
||
| 328 | 328 | $this->message = $e->getMessage(); |
| 329 | 329 | $this->code = intval($e->getCode()); |
| 330 | 330 | |
| 331 | - if(!isset($_REQUEST['REQUEST_URI'])) { |
|
| 331 | + if (!isset($_REQUEST['REQUEST_URI'])) { |
|
| 332 | 332 | $this->context = self::CONTEXT_COMMAND_LINE; |
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | $previous = $e->getPrevious(); |
| 336 | - if(!empty($previous)) { |
|
| 336 | + if (!empty($previous)) { |
|
| 337 | 337 | $this->previous = ConvertHelper::throwable2info($previous); |
| 338 | 338 | } |
| 339 | 339 | |
| 340 | - if(isset($_SERVER['REQUEST_URI'])) { |
|
| 340 | + if (isset($_SERVER['REQUEST_URI'])) { |
|
| 341 | 341 | $this->referer = $_SERVER['REQUEST_URI']; |
| 342 | 342 | } |
| 343 | 343 | |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | |
| 352 | 352 | $idx = 1; |
| 353 | 353 | |
| 354 | - foreach($trace as $entry) |
|
| 354 | + foreach ($trace as $entry) |
|
| 355 | 355 | { |
| 356 | 356 | $this->calls[] = ConvertHelper_ThrowableInfo_Call::fromTrace($this, $idx, $entry); |
| 357 | 357 | |
@@ -142,7 +142,7 @@ |
||
| 142 | 142 | |
| 143 | 143 | protected function getInfoKey(string $name) : string |
| 144 | 144 | { |
| 145 | - if(isset($this->info[$name])) { |
|
| 145 | + if (isset($this->info[$name])) { |
|
| 146 | 146 | return (string)$this->info[$name]; |
| 147 | 147 | } |
| 148 | 148 | |