@@ -84,9 +84,9 @@ discard block |
||
| 84 | 84 | $this->path = $path; |
| 85 | 85 | $this->closure = $closure; |
| 86 | 86 | $this->domain = is_null($domain) |
| 87 | - ? isset($_SERVER[ 'HTTP_HOST' ]) |
|
| 88 | - ? @$_SERVER[ 'HTTP_HOST' ] |
|
| 89 | - : @$_SERVER[ 'SERVER_NAME' ] |
|
| 87 | + ? isset($_SERVER['HTTP_HOST']) |
|
| 88 | + ? @$_SERVER['HTTP_HOST'] |
|
| 89 | + : @$_SERVER['SERVER_NAME'] |
|
| 90 | 90 | : $domain; |
| 91 | 91 | |
| 92 | 92 | // Remove www |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | if (preg_match_all("/{(.*)}/", $this->domain, $matches)) { |
| 98 | - foreach ($matches[ 1 ] as $match) { |
|
| 98 | + foreach ($matches[1] as $match) { |
|
| 99 | 99 | $this->closureParameters[] = $match; |
| 100 | 100 | } |
| 101 | 101 | } |
@@ -202,9 +202,9 @@ discard block |
||
| 202 | 202 | */ |
| 203 | 203 | public function isValidDomain() |
| 204 | 204 | { |
| 205 | - $domain = isset($_SERVER[ 'HTTP_HOST' ]) |
|
| 206 | - ? $_SERVER[ 'HTTP_HOST' ] |
|
| 207 | - : $_SERVER[ 'SERVER_NAME' ]; |
|
| 205 | + $domain = isset($_SERVER['HTTP_HOST']) |
|
| 206 | + ? $_SERVER['HTTP_HOST'] |
|
| 207 | + : $_SERVER['SERVER_NAME']; |
|
| 208 | 208 | |
| 209 | 209 | if ($this->domain === $domain) { |
| 210 | 210 | return true; |
@@ -243,22 +243,22 @@ discard block |
||
| 243 | 243 | if (($class = $parameter->getClass()) instanceof \ReflectionClass) { |
| 244 | 244 | $className = $class->getName(); |
| 245 | 245 | if (class_exists($className)) { |
| 246 | - if (isset($matches[ $parameter->name ])) { |
|
| 247 | - $parameters[ $index ] = new $className($matches[ $parameter->name ]); |
|
| 246 | + if (isset($matches[$parameter->name])) { |
|
| 247 | + $parameters[$index] = new $className($matches[$parameter->name]); |
|
| 248 | 248 | } |
| 249 | 249 | } |
| 250 | - } elseif (isset($matches[ $parameter->name ])) { |
|
| 251 | - $parameters[ $index ] = $matches[ $parameter->name ]; |
|
| 250 | + } elseif (isset($matches[$parameter->name])) { |
|
| 251 | + $parameters[$index] = $matches[$parameter->name]; |
|
| 252 | 252 | } else { |
| 253 | - $parameters[ $index ] = null; |
|
| 253 | + $parameters[$index] = null; |
|
| 254 | 254 | } |
| 255 | 255 | } |
| 256 | 256 | } else { |
| 257 | 257 | foreach ($closure->getParameters() as $index => $parameter) { |
| 258 | - if (isset($matches[ $index ])) { |
|
| 259 | - $parameters[ $index ] = $matches[ $index ]; |
|
| 258 | + if (isset($matches[$index])) { |
|
| 259 | + $parameters[$index] = $matches[$index]; |
|
| 260 | 260 | } else { |
| 261 | - $parameters[ $index ] = null; |
|
| 261 | + $parameters[$index] = null; |
|
| 262 | 262 | } |
| 263 | 263 | } |
| 264 | 264 | } |
@@ -310,16 +310,16 @@ discard block |
||
| 310 | 310 | $parameters = []; |
| 311 | 311 | |
| 312 | 312 | for ($i = 0; $i <= count($pathParts); $i++) { |
| 313 | - if (isset($pathParts[ $i ]) && isset($stringParts[ $i ])) { |
|
| 314 | - if ($pathParts[ $i ] == $stringParts[ $i ]) { |
|
| 315 | - $matches[ $i ] = $stringParts[ $i ]; |
|
| 313 | + if (isset($pathParts[$i]) && isset($stringParts[$i])) { |
|
| 314 | + if ($pathParts[$i] == $stringParts[$i]) { |
|
| 315 | + $matches[$i] = $stringParts[$i]; |
|
| 316 | 316 | } |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | - if (isset($pathParts[ $i ])) { |
|
| 320 | - if (preg_match("/{(.*)}/", $pathParts[ $i ])) { |
|
| 321 | - $index = str_replace(['{$', '}'], '', $pathParts[ $i ]); |
|
| 322 | - $parameters[ $index ] = isset($stringParts[ $i ]) ? $stringParts[ $i ] : null; |
|
| 319 | + if (isset($pathParts[$i])) { |
|
| 320 | + if (preg_match("/{(.*)}/", $pathParts[$i])) { |
|
| 321 | + $index = str_replace(['{$', '}'], '', $pathParts[$i]); |
|
| 322 | + $parameters[$index] = isset($stringParts[$i]) ? $stringParts[$i] : null; |
|
| 323 | 323 | } |
| 324 | 324 | } |
| 325 | 325 | } |
@@ -142,8 +142,8 @@ discard block |
||
| 142 | 142 | $path = '/' . ltrim($path, '/'); |
| 143 | 143 | $translations = $this->getTranslations($domain); |
| 144 | 144 | |
| 145 | - if (isset($translations[ $path ])) { |
|
| 146 | - return $translations[ $path ]; |
|
| 145 | + if (isset($translations[$path])) { |
|
| 146 | + return $translations[$path]; |
|
| 147 | 147 | } elseif (count($translations)) { |
| 148 | 148 | foreach ($translations as $translation => $action) { |
| 149 | 149 | if ($action->isValidUriString($path)) { |
@@ -177,12 +177,12 @@ discard block |
||
| 177 | 177 | |
| 178 | 178 | $translations = []; |
| 179 | 179 | |
| 180 | - if (isset($this->translations[ $domain ])) { |
|
| 181 | - $translations = $this->translations[ $domain ]; |
|
| 180 | + if (isset($this->translations[$domain])) { |
|
| 181 | + $translations = $this->translations[$domain]; |
|
| 182 | 182 | } else { |
| 183 | 183 | $domain = new Domain($domain); |
| 184 | 184 | if (array_key_exists($domain->getString(), $this->translations)) { |
| 185 | - $translations = $this->translations[ $domain->getString() ]; |
|
| 185 | + $translations = $this->translations[$domain->getString()]; |
|
| 186 | 186 | } else { |
| 187 | 187 | foreach ($this->translations as $domainRoute => $domainMap) { |
| 188 | 188 | if (preg_match('/[{][a-zA-Z0-9$_]+[}]/', $domainRoute)) { |
@@ -191,13 +191,13 @@ discard block |
||
| 191 | 191 | if ($domain->getParentDomain() === $domainRoute->getParentDomain() AND |
| 192 | 192 | $domain->getTotalSubDomains() == $domainRoute->getTotalSubDomains() |
| 193 | 193 | ) { |
| 194 | - if (isset($domainMap[ $domainRoute->getSubDomain() ])) { |
|
| 194 | + if (isset($domainMap[$domainRoute->getSubDomain()])) { |
|
| 195 | 195 | $translations = $domainMap; |
| 196 | - $address = $translations[ $domainRoute->getSubDomain() ]->setClosureParameters( |
|
| 196 | + $address = $translations[$domainRoute->getSubDomain()]->setClosureParameters( |
|
| 197 | 197 | $domain->getSubDomains() |
| 198 | 198 | ); |
| 199 | 199 | |
| 200 | - unset($translations[ $domainRoute->getSubDomain() ]); |
|
| 200 | + unset($translations[$domainRoute->getSubDomain()]); |
|
| 201 | 201 | |
| 202 | 202 | if (false !== ($closureParameters = $address->getClosure())) { |
| 203 | 203 | |
@@ -259,8 +259,8 @@ discard block |
||
| 259 | 259 | } else { |
| 260 | 260 | |
| 261 | 261 | if (is_string($address)) { |
| 262 | - $namespace = isset($this->attributes[ 'namespace' ]) |
|
| 263 | - ? $this->attributes[ 'namespace' ] |
|
| 262 | + $namespace = isset($this->attributes['namespace']) |
|
| 263 | + ? $this->attributes['namespace'] |
|
| 264 | 264 | : null; |
| 265 | 265 | $controllerClassName = trim($namespace, '\\') . '\\' . $address; |
| 266 | 266 | |
@@ -269,17 +269,17 @@ discard block |
||
| 269 | 269 | } |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | - $closure = function () use ($address) { |
|
| 272 | + $closure = function() use ($address) { |
|
| 273 | 273 | return $address; |
| 274 | 274 | }; |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | - $domain = isset($this->attributes[ 'domain' ]) |
|
| 278 | - ? $this->attributes[ 'domain' ] |
|
| 277 | + $domain = isset($this->attributes['domain']) |
|
| 278 | + ? $this->attributes['domain'] |
|
| 279 | 279 | : null; |
| 280 | 280 | |
| 281 | - $prefix = isset($this->attributes[ 'prefix' ]) |
|
| 282 | - ? $this->attributes[ 'prefix' ] |
|
| 281 | + $prefix = isset($this->attributes['prefix']) |
|
| 282 | + ? $this->attributes['prefix'] |
|
| 283 | 283 | : null; |
| 284 | 284 | |
| 285 | 285 | if ( ! preg_match('/[{][a-zA-Z0-9$_]+[}]/', $path)) { |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | |
| 289 | 289 | $action = new DataStructures\Action($method, $path, $closure, $domain); |
| 290 | 290 | |
| 291 | - $this->translations[ $action->getDomain() ][ $action->getPath() ] = $action; |
|
| 291 | + $this->translations[$action->getDomain()][$action->getPath()] = $action; |
|
| 292 | 292 | |
| 293 | 293 | return $this; |
| 294 | 294 | } |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | } |
| 373 | 373 | } |
| 374 | 374 | |
| 375 | - $this->domains[ $domain ] = $address; |
|
| 375 | + $this->domains[$domain] = $address; |
|
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | // ------------------------------------------------------------------------ |
@@ -387,20 +387,20 @@ discard block |
||
| 387 | 387 | public function getDomain($domain = null) |
| 388 | 388 | { |
| 389 | 389 | $domain = is_null($domain) |
| 390 | - ? isset($_SERVER[ 'HTTP_HOST' ]) |
|
| 391 | - ? $_SERVER[ 'HTTP_HOST' ] |
|
| 392 | - : $_SERVER[ 'SERVER_NAME' ] |
|
| 390 | + ? isset($_SERVER['HTTP_HOST']) |
|
| 391 | + ? $_SERVER['HTTP_HOST'] |
|
| 392 | + : $_SERVER['SERVER_NAME'] |
|
| 393 | 393 | : $domain; |
| 394 | 394 | |
| 395 | 395 | if (array_key_exists($domain, $this->domains)) { |
| 396 | - if (is_callable($this->domains[ $domain ])) { |
|
| 397 | - return call_user_func($this->domains[ $domain ]); |
|
| 396 | + if (is_callable($this->domains[$domain])) { |
|
| 397 | + return call_user_func($this->domains[$domain]); |
|
| 398 | 398 | } |
| 399 | 399 | |
| 400 | - return $this->domains[ $domain ]; |
|
| 401 | - } elseif (isset($this->domains[ '*' ]) and is_callable($this->domains[ '*' ])) { |
|
| 400 | + return $this->domains[$domain]; |
|
| 401 | + } elseif (isset($this->domains['*']) and is_callable($this->domains['*'])) { |
|
| 402 | 402 | // check wildcard domain closure |
| 403 | - if (false !== ($address = call_user_func($this->domains[ '*' ], $domain))) { |
|
| 403 | + if (false !== ($address = call_user_func($this->domains['*'], $domain))) { |
|
| 404 | 404 | return $address; |
| 405 | 405 | } |
| 406 | 406 | } elseif (count($this->domains)) { |
@@ -47,13 +47,13 @@ |
||
| 47 | 47 | */ |
| 48 | 48 | public function &__get($property) |
| 49 | 49 | { |
| 50 | - $get[ $property ] = false; |
|
| 50 | + $get[$property] = false; |
|
| 51 | 51 | |
| 52 | 52 | if (services()->has($property)) { |
| 53 | - $get[ $property ] = services()->get($property); |
|
| 53 | + $get[$property] = services()->get($property); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - return $get[ $property ]; |
|
| 56 | + return $get[$property]; |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | // ------------------------------------------------------------------------ |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | $loopThrough = []; |
| 107 | 107 | |
| 108 | 108 | foreach ($offset as $key) { |
| 109 | - $loopThrough[ $key ] = $this->filter($type, $key, $filter); |
|
| 109 | + $loopThrough[$key] = $this->filter($type, $key, $filter); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | if (empty($loopThrough)) { |
@@ -120,38 +120,38 @@ discard block |
||
| 120 | 120 | // of the simpler filter_input(); |
| 121 | 121 | switch ($type) { |
| 122 | 122 | case INPUT_GET: |
| 123 | - $value = isset($_GET[ $offset ]) |
|
| 124 | - ? $_GET[ $offset ] |
|
| 123 | + $value = isset($_GET[$offset]) |
|
| 124 | + ? $_GET[$offset] |
|
| 125 | 125 | : null; |
| 126 | 126 | break; |
| 127 | 127 | case INPUT_POST: |
| 128 | - $value = isset($_POST[ $offset ]) |
|
| 129 | - ? $_POST[ $offset ] |
|
| 128 | + $value = isset($_POST[$offset]) |
|
| 129 | + ? $_POST[$offset] |
|
| 130 | 130 | : null; |
| 131 | 131 | break; |
| 132 | 132 | case INPUT_SERVER: |
| 133 | - $value = isset($_SERVER[ $offset ]) |
|
| 134 | - ? $_SERVER[ $offset ] |
|
| 133 | + $value = isset($_SERVER[$offset]) |
|
| 134 | + ? $_SERVER[$offset] |
|
| 135 | 135 | : null; |
| 136 | 136 | break; |
| 137 | 137 | case INPUT_ENV: |
| 138 | - $value = isset($_ENV[ $offset ]) |
|
| 139 | - ? $_ENV[ $offset ] |
|
| 138 | + $value = isset($_ENV[$offset]) |
|
| 139 | + ? $_ENV[$offset] |
|
| 140 | 140 | : null; |
| 141 | 141 | break; |
| 142 | 142 | case INPUT_COOKIE: |
| 143 | - $value = isset($_COOKIE[ $offset ]) |
|
| 144 | - ? $_COOKIE[ $offset ] |
|
| 143 | + $value = isset($_COOKIE[$offset]) |
|
| 144 | + ? $_COOKIE[$offset] |
|
| 145 | 145 | : null; |
| 146 | 146 | break; |
| 147 | 147 | case INPUT_REQUEST: |
| 148 | - $value = isset($_REQUEST[ $offset ]) |
|
| 149 | - ? $_REQUEST[ $offset ] |
|
| 148 | + $value = isset($_REQUEST[$offset]) |
|
| 149 | + ? $_REQUEST[$offset] |
|
| 150 | 150 | : null; |
| 151 | 151 | break; |
| 152 | 152 | case INPUT_SESSION: |
| 153 | - $value = isset($_SESSION[ $offset ]) |
|
| 154 | - ? $_SESSION[ $offset ] |
|
| 153 | + $value = isset($_SESSION[$offset]) |
|
| 154 | + ? $_SESSION[$offset] |
|
| 155 | 155 | : null; |
| 156 | 156 | break; |
| 157 | 157 | default: |
@@ -210,13 +210,13 @@ discard block |
||
| 210 | 210 | { |
| 211 | 211 | foreach ($data as $key => $value) { |
| 212 | 212 | if (is_array($value) AND is_array($filter)) { |
| 213 | - $data[ $key ] = filter_var_array($value, $filter); |
|
| 213 | + $data[$key] = filter_var_array($value, $filter); |
|
| 214 | 214 | } elseif (is_array($value)) { |
| 215 | - $data[ $key ] = $this->filterRecursive($value, $filter); |
|
| 215 | + $data[$key] = $this->filterRecursive($value, $filter); |
|
| 216 | 216 | } elseif (isset($filter)) { |
| 217 | - $data[ $key ] = filter_var($value, $filter); |
|
| 217 | + $data[$key] = filter_var($value, $filter); |
|
| 218 | 218 | } else { |
| 219 | - $data[ $key ] = $value; |
|
| 219 | + $data[$key] = $value; |
|
| 220 | 220 | } |
| 221 | 221 | } |
| 222 | 222 | |
@@ -262,12 +262,12 @@ discard block |
||
| 262 | 262 | */ |
| 263 | 263 | final public function argv($offset = null, $filter = null) |
| 264 | 264 | { |
| 265 | - $arguments = $_SERVER[ 'argv' ]; |
|
| 266 | - $numArguments = $_SERVER[ 'argc' ]; |
|
| 265 | + $arguments = $_SERVER['argv']; |
|
| 266 | + $numArguments = $_SERVER['argc']; |
|
| 267 | 267 | |
| 268 | 268 | $argv = []; |
| 269 | 269 | for ($i = 1; $i < $numArguments; $i++) { |
| 270 | - $optionCommand = trim($arguments[ $i ]); |
|
| 270 | + $optionCommand = trim($arguments[$i]); |
|
| 271 | 271 | $optionValue = true; |
| 272 | 272 | |
| 273 | 273 | if (empty($optionCommand)) { |
@@ -278,10 +278,10 @@ discard block |
||
| 278 | 278 | $xOptionCommand = explode('=', $optionCommand); |
| 279 | 279 | $xOptionCommand = array_map('trim', $xOptionCommand); |
| 280 | 280 | |
| 281 | - $optionCommand = str_replace(['-', '--'], '', $xOptionCommand[ 0 ]); |
|
| 282 | - $optionValue = $xOptionCommand[ 1 ]; |
|
| 281 | + $optionCommand = str_replace(['-', '--'], '', $xOptionCommand[0]); |
|
| 282 | + $optionValue = $xOptionCommand[1]; |
|
| 283 | 283 | |
| 284 | - $argv[ $optionCommand ] = $optionValue; |
|
| 284 | + $argv[$optionCommand] = $optionValue; |
|
| 285 | 285 | continue; |
| 286 | 286 | } |
| 287 | 287 | |
@@ -290,14 +290,14 @@ discard block |
||
| 290 | 290 | ) { |
| 291 | 291 | $optionCommand = str_replace(['-', '--'], '', $optionCommand); |
| 292 | 292 | |
| 293 | - if (isset($arguments[ $i + 1 ])) { |
|
| 294 | - $nextOptionCommand = $arguments[ $i + 1 ]; |
|
| 293 | + if (isset($arguments[$i + 1])) { |
|
| 294 | + $nextOptionCommand = $arguments[$i + 1]; |
|
| 295 | 295 | |
| 296 | 296 | if (strpos($nextOptionCommand, '--') === false |
| 297 | 297 | || strpos($nextOptionCommand, '-') === false |
| 298 | 298 | ) { |
| 299 | 299 | $optionValue = $nextOptionCommand; |
| 300 | - $arguments[ $i + 1 ] = null; |
|
| 300 | + $arguments[$i + 1] = null; |
|
| 301 | 301 | } |
| 302 | 302 | } |
| 303 | 303 | } |
@@ -308,13 +308,13 @@ discard block |
||
| 308 | 308 | $optionValue = filter_var($optionValue, FILTER_DEFAULT); |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | - $argv[ $optionCommand ] = $optionValue; |
|
| 311 | + $argv[$optionCommand] = $optionValue; |
|
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | if (empty($offset)) { |
| 315 | 315 | return $argv; |
| 316 | - } elseif (isset($argv[ $offset ])) { |
|
| 317 | - return $argv[ $offset ]; |
|
| 316 | + } elseif (isset($argv[$offset])) { |
|
| 317 | + return $argv[$offset]; |
|
| 318 | 318 | } |
| 319 | 319 | } |
| 320 | 320 | |
@@ -339,8 +339,8 @@ discard block |
||
| 339 | 339 | */ |
| 340 | 340 | public function getApp() |
| 341 | 341 | { |
| 342 | - return isset($_SERVER[ 'argv' ][ 0 ]) |
|
| 343 | - ? $_SERVER[ 'argv' ][ 0 ] |
|
| 342 | + return isset($_SERVER['argv'][0]) |
|
| 343 | + ? $_SERVER['argv'][0] |
|
| 344 | 344 | : false; |
| 345 | 345 | } |
| 346 | 346 | |
@@ -353,8 +353,8 @@ discard block |
||
| 353 | 353 | */ |
| 354 | 354 | public function getCommand() |
| 355 | 355 | { |
| 356 | - return isset($_SERVER[ 'argv' ][ 1 ]) |
|
| 357 | - ? $_SERVER[ 'argv' ][ 1 ] |
|
| 356 | + return isset($_SERVER['argv'][1]) |
|
| 357 | + ? $_SERVER['argv'][1] |
|
| 358 | 358 | : false; |
| 359 | 359 | } |
| 360 | 360 | |
@@ -370,13 +370,13 @@ discard block |
||
| 370 | 370 | */ |
| 371 | 371 | public function getOptions($offset = null, $filter = null) |
| 372 | 372 | { |
| 373 | - $arguments = $_SERVER[ 'argv' ]; |
|
| 374 | - $numArguments = $_SERVER[ 'argc' ]; |
|
| 373 | + $arguments = $_SERVER['argv']; |
|
| 374 | + $numArguments = $_SERVER['argc']; |
|
| 375 | 375 | |
| 376 | 376 | $argv = []; |
| 377 | 377 | |
| 378 | 378 | for ($i = 2; $i < $numArguments; $i++) { |
| 379 | - $optionCommand = trim($arguments[ $i ]); |
|
| 379 | + $optionCommand = trim($arguments[$i]); |
|
| 380 | 380 | $optionValue = true; |
| 381 | 381 | |
| 382 | 382 | if (empty($optionCommand)) { |
@@ -387,10 +387,10 @@ discard block |
||
| 387 | 387 | $xOptionCommand = explode('=', $optionCommand); |
| 388 | 388 | $xOptionCommand = array_map('trim', $xOptionCommand); |
| 389 | 389 | |
| 390 | - $optionCommand = str_replace(['-', '--'], '', $xOptionCommand[ 0 ]); |
|
| 391 | - $optionValue = $xOptionCommand[ 1 ]; |
|
| 390 | + $optionCommand = str_replace(['-', '--'], '', $xOptionCommand[0]); |
|
| 391 | + $optionValue = $xOptionCommand[1]; |
|
| 392 | 392 | |
| 393 | - $argv[ $optionCommand ] = $optionValue; |
|
| 393 | + $argv[$optionCommand] = $optionValue; |
|
| 394 | 394 | continue; |
| 395 | 395 | } |
| 396 | 396 | |
@@ -399,14 +399,14 @@ discard block |
||
| 399 | 399 | ) { |
| 400 | 400 | $optionCommand = str_replace(['-', '--'], '', $optionCommand); |
| 401 | 401 | |
| 402 | - if (isset($arguments[ $i + 1 ])) { |
|
| 403 | - $nextOptionCommand = $arguments[ $i + 1 ]; |
|
| 402 | + if (isset($arguments[$i + 1])) { |
|
| 403 | + $nextOptionCommand = $arguments[$i + 1]; |
|
| 404 | 404 | |
| 405 | 405 | if (strpos($nextOptionCommand, '--') === false |
| 406 | 406 | || strpos($nextOptionCommand, '-') === false |
| 407 | 407 | ) { |
| 408 | 408 | $optionValue = $nextOptionCommand; |
| 409 | - $arguments[ $i + 1 ] = null; |
|
| 409 | + $arguments[$i + 1] = null; |
|
| 410 | 410 | } |
| 411 | 411 | } |
| 412 | 412 | } |
@@ -417,13 +417,13 @@ discard block |
||
| 417 | 417 | $optionValue = filter_var($optionValue, FILTER_DEFAULT); |
| 418 | 418 | } |
| 419 | 419 | |
| 420 | - $argv[ $optionCommand ] = $optionValue; |
|
| 420 | + $argv[$optionCommand] = $optionValue; |
|
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | if (empty($offset)) { |
| 424 | 424 | return $argv; |
| 425 | - } elseif (isset($argv[ $offset ])) { |
|
| 426 | - return $argv[ $offset ]; |
|
| 425 | + } elseif (isset($argv[$offset])) { |
|
| 426 | + return $argv[$offset]; |
|
| 427 | 427 | } |
| 428 | 428 | } |
| 429 | 429 | |
@@ -63,9 +63,9 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | public function parseRequest() |
| 65 | 65 | { |
| 66 | - $argv = $_SERVER[ 'argv' ]; |
|
| 66 | + $argv = $_SERVER['argv']; |
|
| 67 | 67 | |
| 68 | - if ($_SERVER[ 'SCRIPT_NAME' ] === $_SERVER[ 'argv' ][ 0 ]) { |
|
| 68 | + if ($_SERVER['SCRIPT_NAME'] === $_SERVER['argv'][0]) { |
|
| 69 | 69 | array_shift($argv); |
| 70 | 70 | |
| 71 | 71 | if (empty($argv)) { |
@@ -73,11 +73,11 @@ discard block |
||
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - $this->string = str_replace(['/', '\\', ':'], '/', $argv[ 0 ]); |
|
| 76 | + $this->string = str_replace(['/', '\\', ':'], '/', $argv[0]); |
|
| 77 | 77 | $this->commands = explode('/', $this->string); |
| 78 | 78 | |
| 79 | - if (strpos($this->commands[ 0 ], '--') !== false |
|
| 80 | - || strpos($this->commands[ 0 ], '-') !== false |
|
| 79 | + if (strpos($this->commands[0], '--') !== false |
|
| 80 | + || strpos($this->commands[0], '-') !== false |
|
| 81 | 81 | ) { |
| 82 | 82 | $options = $this->commands; |
| 83 | 83 | $this->commands = []; |
@@ -96,8 +96,8 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | if (strpos($option, '=') !== false) { |
| 98 | 98 | $optionParts = explode('=', $option); |
| 99 | - $option = $optionParts[ 0 ]; |
|
| 100 | - $value = $optionParts[ 1 ]; |
|
| 99 | + $option = $optionParts[0]; |
|
| 100 | + $value = $optionParts[1]; |
|
| 101 | 101 | } else { |
| 102 | 102 | $value = current($options); |
| 103 | 103 | } |
@@ -111,21 +111,21 @@ discard block |
||
| 111 | 111 | if (strpos($value, '--') === false |
| 112 | 112 | || strpos($value, '-') === false |
| 113 | 113 | ) { |
| 114 | - $_GET[ $option ] = $value; |
|
| 114 | + $_GET[$option] = $value; |
|
| 115 | 115 | } else { |
| 116 | - $_GET[ $option ] = null; |
|
| 116 | + $_GET[$option] = null; |
|
| 117 | 117 | } |
| 118 | 118 | } else { |
| 119 | 119 | $keys = array_keys($_GET); |
| 120 | 120 | if (count($keys)) { |
| 121 | 121 | $key = end($keys); |
| 122 | - $_GET[ $key ] = $option; |
|
| 122 | + $_GET[$key] = $option; |
|
| 123 | 123 | } |
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | if (array_key_exists('verbose', $_GET) or array_key_exists('v', $_GET)) { |
| 128 | - $_ENV[ 'VERBOSE' ] = true; |
|
| 128 | + $_ENV['VERBOSE'] = true; |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | $this->parseCommands($this->commands); |
@@ -82,15 +82,15 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | if (is_array($lastError)) { |
| 84 | 84 | $this->errorHandler( |
| 85 | - $lastError[ 'type' ], |
|
| 86 | - $lastError[ 'message' ], |
|
| 87 | - $lastError[ 'file' ], |
|
| 88 | - $lastError[ 'line' ] |
|
| 85 | + $lastError['type'], |
|
| 86 | + $lastError['message'], |
|
| 87 | + $lastError['file'], |
|
| 88 | + $lastError['line'] |
|
| 89 | 89 | ); |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | // Execute shutdown service |
| 93 | - if(services()->has('shutdown')) { |
|
| 93 | + if (services()->has('shutdown')) { |
|
| 94 | 94 | shutdown()->execute(); |
| 95 | 95 | } |
| 96 | 96 | } |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | $error = new ErrorException($errstr, $errno, $errfile, $errline); |
| 135 | 135 | |
| 136 | 136 | // Logged the error |
| 137 | - if(services()->has('logger')) { |
|
| 137 | + if (services()->has('logger')) { |
|
| 138 | 138 | logger()->error( |
| 139 | 139 | implode( |
| 140 | 140 | ' ', |
@@ -370,8 +370,8 @@ discard block |
||
| 370 | 370 | $errors = require(str_replace('Cli', 'Config', __DIR__) . DIRECTORY_SEPARATOR . 'Errors.php'); |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - if (isset($errors[ $code ])) { |
|
| 374 | - $languageKey = $errors[ $code ]; |
|
| 373 | + if (isset($errors[$code])) { |
|
| 374 | + $languageKey = $errors[$code]; |
|
| 375 | 375 | } |
| 376 | 376 | |
| 377 | 377 | $languageKey = strtoupper($code . '_' . $languageKey); |
@@ -383,10 +383,10 @@ discard block |
||
| 383 | 383 | ]; |
| 384 | 384 | |
| 385 | 385 | $this->statusCode = $code; |
| 386 | - $this->reasonPhrase = $error[ 'title' ]; |
|
| 386 | + $this->reasonPhrase = $error['title']; |
|
| 387 | 387 | |
| 388 | 388 | if (is_string($vars)) { |
| 389 | - $error[ 'message' ] = $vars; |
|
| 389 | + $error['message'] = $vars; |
|
| 390 | 390 | } elseif (is_array($vars)) { |
| 391 | 391 | $error = array_merge($error, $vars); |
| 392 | 392 | } |
@@ -394,13 +394,13 @@ discard block |
||
| 394 | 394 | $this->write( |
| 395 | 395 | (new Format()) |
| 396 | 396 | ->setContextualClass(Format::DANGER) |
| 397 | - ->setString($error[ 'code' ] . ' - ' . $error[ 'title' ]) |
|
| 397 | + ->setString($error['code'] . ' - ' . $error['title']) |
|
| 398 | 398 | ->setNewLinesAfter(1) |
| 399 | 399 | ); |
| 400 | 400 | |
| 401 | 401 | $this->write( |
| 402 | 402 | (new Format()) |
| 403 | - ->setString($error[ 'message' ]) |
|
| 403 | + ->setString($error['message']) |
|
| 404 | 404 | ->setNewLinesAfter(1) |
| 405 | 405 | ); |
| 406 | 406 | |
@@ -419,7 +419,7 @@ discard block |
||
| 419 | 419 | */ |
| 420 | 420 | public function verbose($text, $type = 'stdout') |
| 421 | 421 | { |
| 422 | - if (isset($_ENV[ 'VERBOSE' ]) and $_ENV[ 'VERBOSE' ] === true) { |
|
| 422 | + if (isset($_ENV['VERBOSE']) and $_ENV['VERBOSE'] === true) { |
|
| 423 | 423 | $this->write($text, $type); |
| 424 | 424 | } |
| 425 | 425 | } |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | $this->services = new Kernel\Containers\Services(); |
| 57 | 57 | |
| 58 | - if (isset($_ENV[ 'DEBUG_STAGE' ]) and $_ENV[ 'DEBUG_STAGE' ] === 'DEVELOPER') { |
|
| 58 | + if (isset($_ENV['DEBUG_STAGE']) and $_ENV['DEBUG_STAGE'] === 'DEVELOPER') { |
|
| 59 | 59 | $this->services->load(Gear\Profiler::class); |
| 60 | 60 | if (profiler() !== false) { |
| 61 | 61 | profiler()->watch('Starting Kernel Services'); |
@@ -147,14 +147,14 @@ discard block |
||
| 147 | 147 | */ |
| 148 | 148 | public function &__get($property) |
| 149 | 149 | { |
| 150 | - $get[ $property ] = null; |
|
| 150 | + $get[$property] = null; |
|
| 151 | 151 | |
| 152 | 152 | if (isset($this->{$property})) { |
| 153 | - $get[ $property ] =& $this->{$property}; |
|
| 153 | + $get[$property] = & $this->{$property}; |
|
| 154 | 154 | } elseif ($this->services->has($property)) { |
| 155 | - $get[ $property ] = $this->services->get($property); |
|
| 155 | + $get[$property] = $this->services->get($property); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - return $get[ $property ]; |
|
| 158 | + return $get[$property]; |
|
| 159 | 159 | } |
| 160 | 160 | } |
| 161 | 161 | \ No newline at end of file |
@@ -95,10 +95,10 @@ discard block |
||
| 95 | 95 | |
| 96 | 96 | if (is_array($lastError)) { |
| 97 | 97 | $this->errorHandler( |
| 98 | - $lastError[ 'type' ], |
|
| 99 | - $lastError[ 'message' ], |
|
| 100 | - $lastError[ 'file' ], |
|
| 101 | - $lastError[ 'line' ] |
|
| 98 | + $lastError['type'], |
|
| 99 | + $lastError['message'], |
|
| 100 | + $lastError['file'], |
|
| 101 | + $lastError['line'] |
|
| 102 | 102 | ); |
| 103 | 103 | } |
| 104 | 104 | } |
@@ -229,8 +229,8 @@ discard block |
||
| 229 | 229 | if (strpos($mimeType, '/') === false) { |
| 230 | 230 | $extension = ltrim($mimeType, '.'); |
| 231 | 231 | // Is this extension supported? |
| 232 | - if (isset($mimes[ $extension ])) { |
|
| 233 | - $mimeType =& $mimes[ $extension ]; |
|
| 232 | + if (isset($mimes[$extension])) { |
|
| 233 | + $mimeType = & $mimes[$extension]; |
|
| 234 | 234 | if (is_array($mimeType)) { |
| 235 | 235 | $mimeType = current($mimeType); |
| 236 | 236 | } |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | */ |
| 261 | 261 | public function addHeader($name, $value) |
| 262 | 262 | { |
| 263 | - $this->headers[ $name ] = $value; |
|
| 263 | + $this->headers[$name] = $value; |
|
| 264 | 264 | |
| 265 | 265 | return $this; |
| 266 | 266 | } |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | $reasonPhrase = $this->reasonPhrase; |
| 280 | 280 | |
| 281 | 281 | if (is_ajax()) { |
| 282 | - $contentType = isset($_SERVER[ 'HTTP_X_REQUESTED_CONTENT_TYPE' ]) ? $_SERVER[ 'HTTP_X_REQUESTED_CONTENT_TYPE' ] : 'application/json'; |
|
| 282 | + $contentType = isset($_SERVER['HTTP_X_REQUESTED_CONTENT_TYPE']) ? $_SERVER['HTTP_X_REQUESTED_CONTENT_TYPE'] : 'application/json'; |
|
| 283 | 283 | $this->setContentType($contentType); |
| 284 | 284 | } |
| 285 | 285 | |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | 'status' => (int)$statusCode, |
| 290 | 290 | 'reason' => $reasonPhrase, |
| 291 | 291 | 'success' => $statusCode >= 200 && $statusCode < 300 ? true : false, |
| 292 | - 'message' => isset($data[ 'message' ]) ? $data[ 'message' ] : '', |
|
| 292 | + 'message' => isset($data['message']) ? $data['message'] : '', |
|
| 293 | 293 | 'result' => [], |
| 294 | 294 | ]; |
| 295 | 295 | |
@@ -299,80 +299,80 @@ discard block |
||
| 299 | 299 | |
| 300 | 300 | if (is_array($data) and count($data)) { |
| 301 | 301 | if (is_numeric(key($data))) { |
| 302 | - $response[ 'result' ] = $data; |
|
| 302 | + $response['result'] = $data; |
|
| 303 | 303 | } elseif (is_string(key($data))) { |
| 304 | 304 | if (array_key_exists('success', $data)) { |
| 305 | - $response[ 'success' ] = $data[ 'success' ]; |
|
| 306 | - unset($data[ 'success' ]); |
|
| 305 | + $response['success'] = $data['success']; |
|
| 306 | + unset($data['success']); |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | if (array_key_exists('message', $data)) { |
| 310 | - $response[ 'message' ] = $data[ 'message' ]; |
|
| 311 | - unset($data[ 'message' ]); |
|
| 310 | + $response['message'] = $data['message']; |
|
| 311 | + unset($data['message']); |
|
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | if (array_key_exists('timestamp', $data)) { |
| 315 | - $response[ 'timestamp' ] = $data[ 'timestamp' ]; |
|
| 316 | - unset($data[ 'timestamp' ]); |
|
| 315 | + $response['timestamp'] = $data['timestamp']; |
|
| 316 | + unset($data['timestamp']); |
|
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | if (array_key_exists('metadata', $data)) { |
| 320 | - $response[ 'metadata' ] = $data[ 'metadata' ]; |
|
| 321 | - unset($data[ 'metadata' ]); |
|
| 320 | + $response['metadata'] = $data['metadata']; |
|
| 321 | + unset($data['metadata']); |
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | if (array_key_exists('errors', $data)) { |
| 325 | - $response[ 'errors' ] = $data[ 'errors' ]; |
|
| 325 | + $response['errors'] = $data['errors']; |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | if (array_key_exists('error', $data)) { |
| 329 | - $response[ 'error' ] = $data[ 'error' ]; |
|
| 329 | + $response['error'] = $data['error']; |
|
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | if (array_key_exists('data', $data)) { |
| 333 | - if ($data[ 'data' ] instanceof \ArrayIterator) { |
|
| 334 | - $data[ 'data' ] = $data[ 'data' ]->getArrayCopy(); |
|
| 333 | + if ($data['data'] instanceof \ArrayIterator) { |
|
| 334 | + $data['data'] = $data['data']->getArrayCopy(); |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | - if (is_array($data[ 'data' ])) { |
|
| 338 | - if (is_string(key($data[ 'data' ]))) { |
|
| 339 | - $response[ 'result' ] = [$data[ 'data' ]]; |
|
| 340 | - } elseif (is_numeric(key($data[ 'data' ]))) { |
|
| 341 | - $response[ 'result' ] = $data[ 'data' ]; |
|
| 337 | + if (is_array($data['data'])) { |
|
| 338 | + if (is_string(key($data['data']))) { |
|
| 339 | + $response['result'] = [$data['data']]; |
|
| 340 | + } elseif (is_numeric(key($data['data']))) { |
|
| 341 | + $response['result'] = $data['data']; |
|
| 342 | 342 | } |
| 343 | 343 | } else { |
| 344 | - $response[ 'result' ] = [$data[ 'data' ]]; |
|
| 344 | + $response['result'] = [$data['data']]; |
|
| 345 | 345 | } |
| 346 | 346 | } |
| 347 | 347 | } |
| 348 | 348 | } elseif (is_object($data)) { |
| 349 | 349 | if (isset($data->success)) { |
| 350 | - $response[ 'success' ] = $data->success; |
|
| 350 | + $response['success'] = $data->success; |
|
| 351 | 351 | unset($data->success); |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | if (isset($data->message)) { |
| 355 | - $response[ 'message' ] = $data->message; |
|
| 355 | + $response['message'] = $data->message; |
|
| 356 | 356 | unset($data->message); |
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | if (isset($data->timestamp)) { |
| 360 | - $response[ 'timestamp' ] = $data->timestamp; |
|
| 360 | + $response['timestamp'] = $data->timestamp; |
|
| 361 | 361 | unset($data->timestamp); |
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | if (isset($data->metadata)) { |
| 365 | - $response[ 'metadata' ] = $data->metadata; |
|
| 365 | + $response['metadata'] = $data->metadata; |
|
| 366 | 366 | unset($data->metadata); |
| 367 | 367 | } |
| 368 | 368 | |
| 369 | 369 | if (isset($data->errors)) { |
| 370 | - $response[ 'errors' ] = $data->errors; |
|
| 370 | + $response['errors'] = $data->errors; |
|
| 371 | 371 | unset($data->errors); |
| 372 | 372 | } |
| 373 | 373 | |
| 374 | 374 | if (isset($data->error)) { |
| 375 | - $response[ 'error' ] = $data->error; |
|
| 375 | + $response['error'] = $data->error; |
|
| 376 | 376 | unset($data->error); |
| 377 | 377 | } |
| 378 | 378 | |
@@ -383,12 +383,12 @@ discard block |
||
| 383 | 383 | |
| 384 | 384 | if (is_array($data->data)) { |
| 385 | 385 | if (is_string(key($data->data))) { |
| 386 | - $response[ 'result' ] = [$data->data]; |
|
| 386 | + $response['result'] = [$data->data]; |
|
| 387 | 387 | } elseif (is_numeric(key($data->data))) { |
| 388 | - $response[ 'result' ] = $data->data; |
|
| 388 | + $response['result'] = $data->data; |
|
| 389 | 389 | } |
| 390 | 390 | } else { |
| 391 | - $response[ 'result' ] = [$data->data]; |
|
| 391 | + $response['result'] = [$data->data]; |
|
| 392 | 392 | } |
| 393 | 393 | } |
| 394 | 394 | } |
@@ -415,8 +415,8 @@ discard block |
||
| 415 | 415 | foreach (headers_list() as $header) { |
| 416 | 416 | $headerParts = explode(':', $header); |
| 417 | 417 | $headerParts = array_map('trim', $headerParts); |
| 418 | - $headers[ $headerParts[ 0 ] ] = $headerParts[ 1 ]; |
|
| 419 | - header_remove($header[ 0 ]); |
|
| 418 | + $headers[$headerParts[0]] = $headerParts[1]; |
|
| 419 | + header_remove($header[0]); |
|
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | if (count($headers)) { |
@@ -590,21 +590,21 @@ discard block |
||
| 590 | 590 | ]; |
| 591 | 591 | |
| 592 | 592 | $this->statusCode = $code; |
| 593 | - $this->reasonPhrase = $error[ 'title' ]; |
|
| 593 | + $this->reasonPhrase = $error['title']; |
|
| 594 | 594 | |
| 595 | 595 | if (is_string($vars)) { |
| 596 | 596 | $vars = ['message' => $vars]; |
| 597 | - } elseif (is_array($vars) and empty($vars[ 'message' ])) { |
|
| 598 | - $vars[ 'message' ] = $error[ 'message' ]; |
|
| 597 | + } elseif (is_array($vars) and empty($vars['message'])) { |
|
| 598 | + $vars['message'] = $error['message']; |
|
| 599 | 599 | } |
| 600 | 600 | |
| 601 | - if (isset($vars[ 'message' ])) { |
|
| 602 | - $error[ 'message' ] = $vars[ 'message' ]; |
|
| 601 | + if (isset($vars['message'])) { |
|
| 602 | + $error['message'] = $vars['message']; |
|
| 603 | 603 | } |
| 604 | 604 | |
| 605 | 605 | if (is_ajax() or $this->mimeType !== 'text/html') { |
| 606 | 606 | $this->statusCode = $code; |
| 607 | - $this->reasonPhrase = $error[ 'title' ]; |
|
| 607 | + $this->reasonPhrase = $error['title']; |
|
| 608 | 608 | $this->send($vars); |
| 609 | 609 | |
| 610 | 610 | exit(EXIT_ERROR); |