@@ -40,8 +40,8 @@ |
||
| 40 | 40 | public function getDetailedErrorHandler(); |
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | - * @return Handler |
|
| 44 | - */ |
|
| 43 | + * @return Handler |
|
| 44 | + */ |
|
| 45 | 45 | public function getErrorHandler(); |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | { |
| 19 | 19 | $refClass = new \ReflectionClass($ex); |
| 20 | 20 | |
| 21 | - $title = str_replace("Exception", "", $refClass->getShortName()); |
|
| 21 | + $title = str_replace("Exception", "", $refClass->getShortName()); |
|
| 22 | 22 | $title = preg_replace("/([a-z0-9])([A-Z])/", "$1 $2", $title); |
| 23 | 23 | return preg_replace("/([a-z])(\d)/", "$1 $2", $title); |
| 24 | 24 | } |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | if (!is_object($object) && !is_array($object)) { |
| 29 | - $object = [ $object ]; |
|
| 29 | + $object = [$object]; |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | if ($this->serializationRule !== ResponseBag::SINGLE_OBJECT && $this->serializationRule !== ResponseBag::RAW) { |
@@ -83,7 +83,7 @@ |
||
| 83 | 83 | |
| 84 | 84 | foreach ($response->getHeaders() as $header => $value) { |
| 85 | 85 | if (is_array($value)) { |
| 86 | - $this->writer->header("$header: " . array_shift($value), true); |
|
| 86 | + $this->writer->header("$header: ".array_shift($value), true); |
|
| 87 | 87 | foreach ($value as $headerValue) { |
| 88 | 88 | $this->writer->header("$header: $headerValue", false); |
| 89 | 89 | } |
@@ -98,37 +98,37 @@ |
||
| 98 | 98 | |
| 99 | 99 | // Processing |
| 100 | 100 | switch ($routeInfo[0]) { |
| 101 | - case Dispatcher::NOT_FOUND: |
|
| 102 | - $outputProcessor->processResponse($this->getHttpResponse()); |
|
| 103 | - throw new Error404Exception("Route '$uri' not found"); |
|
| 101 | + case Dispatcher::NOT_FOUND: |
|
| 102 | + $outputProcessor->processResponse($this->getHttpResponse()); |
|
| 103 | + throw new Error404Exception("Route '$uri' not found"); |
|
| 104 | 104 | |
| 105 | - case Dispatcher::METHOD_NOT_ALLOWED: |
|
| 106 | - $outputProcessor->processResponse($this->getHttpResponse()); |
|
| 107 | - throw new Error405Exception('Method not allowed'); |
|
| 105 | + case Dispatcher::METHOD_NOT_ALLOWED: |
|
| 106 | + $outputProcessor->processResponse($this->getHttpResponse()); |
|
| 107 | + throw new Error405Exception('Method not allowed'); |
|
| 108 | 108 | |
| 109 | - case Dispatcher::FOUND: |
|
| 110 | - // ... 200 Process: |
|
| 111 | - $vars = array_merge($routeInfo[2], $queryStr); |
|
| 109 | + case Dispatcher::FOUND: |
|
| 110 | + // ... 200 Process: |
|
| 111 | + $vars = array_merge($routeInfo[2], $queryStr); |
|
| 112 | 112 | |
| 113 | - // Get the Selected Route |
|
| 114 | - $selectedRoute = $routeInfo[1]; |
|
| 113 | + // Get the Selected Route |
|
| 114 | + $selectedRoute = $routeInfo[1]; |
|
| 115 | 115 | |
| 116 | - // Class |
|
| 117 | - $class = $selectedRoute["class"]; |
|
| 118 | - $this->getHttpRequest()->appendVars($vars); |
|
| 116 | + // Class |
|
| 117 | + $class = $selectedRoute["class"]; |
|
| 118 | + $this->getHttpRequest()->appendVars($vars); |
|
| 119 | 119 | |
| 120 | - // Get OutputProcessor |
|
| 121 | - $outputProcessor = $this->initializeProcessor( |
|
| 122 | - $selectedRoute["output_processor"] |
|
| 123 | - ); |
|
| 120 | + // Get OutputProcessor |
|
| 121 | + $outputProcessor = $this->initializeProcessor( |
|
| 122 | + $selectedRoute["output_processor"] |
|
| 123 | + ); |
|
| 124 | 124 | |
| 125 | - // Execute the request |
|
| 126 | - $this->executeRequest($outputProcessor, $class); |
|
| 125 | + // Execute the request |
|
| 126 | + $this->executeRequest($outputProcessor, $class); |
|
| 127 | 127 | |
| 128 | - break; |
|
| 128 | + break; |
|
| 129 | 129 | |
| 130 | - default: |
|
| 131 | - throw new Error520Exception('Unknown'); |
|
| 130 | + default: |
|
| 131 | + throw new Error520Exception('Unknown'); |
|
| 132 | 132 | } |
| 133 | 133 | } |
| 134 | 134 | |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | |
| 203 | 203 | // Process Class::Method() |
| 204 | 204 | $function = $class[1]; |
| 205 | - $class = $class[0]; |
|
| 205 | + $class = $class[0]; |
|
| 206 | 206 | if (!class_exists($class)) { |
| 207 | 207 | throw new ClassNotFoundException("Class '$class' defined in the route is not found"); |
| 208 | 208 | } |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | throw new InvalidArgumentException("Default processor needs to class name of an OutputProcessor"); |
| 281 | 281 | } |
| 282 | 282 | if (!is_subclass_of($processor, BaseOutputProcessor::class)) { |
| 283 | - throw new InvalidArgumentException("Needs to be a class of " . BaseOutputProcessor::class); |
|
| 283 | + throw new InvalidArgumentException("Needs to be a class of ".BaseOutputProcessor::class); |
|
| 284 | 284 | } |
| 285 | 285 | } |
| 286 | 286 | |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | const CORS_OPTIONS = 'CORS_OPTIONS'; |
| 16 | 16 | |
| 17 | 17 | protected $corsOrigins = ['.*']; |
| 18 | - protected $corsMethods = [ 'GET', 'POST', 'PUT', 'DELETE', 'PATCH']; |
|
| 18 | + protected $corsMethods = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH']; |
|
| 19 | 19 | protected $corsHeaders = [ |
| 20 | 20 | 'Authorization', |
| 21 | 21 | 'Content-Type', |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | if (preg_match("~^.*//$origin$~", $request->server('HTTP_ORIGIN'))) { |
| 75 | 75 | $response->addHeader("Access-Control-Allow-Origin", $request->server('HTTP_ORIGIN')); |
| 76 | 76 | $response->addHeader('Access-Control-Allow-Credentials', 'true'); |
| 77 | - $response->addHeader('Access-Control-Max-Age', '86400'); // cache for 1 day |
|
| 77 | + $response->addHeader('Access-Control-Max-Age', '86400'); // cache for 1 day |
|
| 78 | 78 | |
| 79 | 79 | // Access-Control headers are received during OPTIONS requests |
| 80 | 80 | if ($request->server('REQUEST_METHOD') == 'OPTIONS') { |
@@ -49,9 +49,9 @@ |
||
| 49 | 49 | * |
| 50 | 50 | ********************************************************* */ |
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * @return int|null A handler may return nothing, or a Handler::HANDLE_* constant |
|
| 54 | - */ |
|
| 52 | + /** |
|
| 53 | + * @return int|null A handler may return nothing, or a Handler::HANDLE_* constant |
|
| 54 | + */ |
|
| 55 | 55 | public function handle() |
| 56 | 56 | { |
| 57 | 57 | $r = new ReflectionMethod($this->effectiveHandler, 'getException'); |
@@ -17,8 +17,8 @@ |
||
| 17 | 17 | |
| 18 | 18 | if ($replace) { |
| 19 | 19 | $headerParts = explode(':', $header); |
| 20 | - for ($i=0; $i<count($this->headerList); $i++) { |
|
| 21 | - if (preg_match("~^" . $headerParts[0] . "~", $this->headerList[$i]) === 1) { |
|
| 20 | + for ($i = 0; $i < count($this->headerList); $i++) { |
|
| 21 | + if (preg_match("~^".$headerParts[0]."~", $this->headerList[$i]) === 1) { |
|
| 22 | 22 | $this->headerList[$i] = $header; |
| 23 | 23 | return; |
| 24 | 24 | } |
@@ -36,7 +36,7 @@ |
||
| 36 | 36 | $file = $requestUri->getPath(); |
| 37 | 37 | } else { |
| 38 | 38 | $script = explode('/', $_SERVER['SCRIPT_FILENAME']); |
| 39 | - $script[count($script)-1] = ltrim($requestUri->getPath(), '/'); |
|
| 39 | + $script[count($script) - 1] = ltrim($requestUri->getPath(), '/'); |
|
| 40 | 40 | $file = implode('/', $script); |
| 41 | 41 | } |
| 42 | 42 | |