@@ -46,7 +46,7 @@ |
||
| 46 | 46 | $newName = $this->getFileName($key); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - move_uploaded_file($this->getFileByKey($key, 'tmp_name'), $destinationPath . '/' . $newName); |
|
| 49 | + move_uploaded_file($this->getFileByKey($key, 'tmp_name'), $destinationPath.'/'.$newName); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | public function clearTemp($key) |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | public function add($object) |
| 21 | 21 | { |
| 22 | 22 | if (!is_object($object) && !is_array($object)) { |
| 23 | - $object = [ $object ]; |
|
| 23 | + $object = [$object]; |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | if ($this->serializationRule !== ResponseBag::SINGLE_OBJECT) { |
@@ -186,13 +186,13 @@ |
||
| 186 | 186 | $servername = $this->getServerName(); |
| 187 | 187 | |
| 188 | 188 | if ($port && $this->server('SERVER_PORT' !== false)) { |
| 189 | - $servername .= ':' . $this->server('SERVER_PORT'); |
|
| 189 | + $servername .= ':'.$this->server('SERVER_PORT'); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | if ($protocol) { |
| 193 | 193 | $servername = ( |
| 194 | 194 | ($this->server('HTTPS') !== 'off' |
| 195 | - || $this->server('SERVER_PORT') == 443) ? "https://" : "http://") . $servername |
|
| 195 | + || $this->server('SERVER_PORT') == 443) ? "https://" : "http://").$servername |
|
| 196 | 196 | ; |
| 197 | 197 | } |
| 198 | 198 | |
@@ -125,8 +125,9 @@ |
||
| 125 | 125 | |
| 126 | 126 | // loop data blocks |
| 127 | 127 | foreach ($blocks as $id => $block) { |
| 128 | - if (empty($block)) |
|
| 129 | - continue; |
|
| 128 | + if (empty($block)) { |
|
| 129 | + continue; |
|
| 130 | + } |
|
| 130 | 131 | |
| 131 | 132 | $name = []; |
| 132 | 133 | preg_match('/\bname=\"([^\"]*)\"\s*;/s', $block, $name); |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | /** |
| 11 | 11 | * @var Request |
| 12 | 12 | */ |
| 13 | - protected $psrRequest ; |
|
| 13 | + protected $psrRequest; |
|
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | $this->server["REMOTE_ADDR"] = "127.0.0.1"; |
| 54 | 54 | $this->server["REMOTE_PORT"] = rand(1000, 60000); |
| 55 | 55 | $this->server["SERVER_SOFTWARE"] = "Mock"; |
| 56 | - $this->server["SERVER_PROTOCOL"] = "HTTP/" . $this->psrRequest->getProtocolVersion(); |
|
| 56 | + $this->server["SERVER_PROTOCOL"] = "HTTP/".$this->psrRequest->getProtocolVersion(); |
|
| 57 | 57 | $this->server["SERVER_NAME"] = $this->psrRequest->getUri()->getHost(); |
| 58 | 58 | $this->server["SERVER_PORT"] = $this->psrRequest->getUri()->getPort(); |
| 59 | 59 | $this->server["REQUEST_URI"] = $this->psrRequest->getRequestTarget(); |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | // Headers and Cookies |
| 71 | 71 | $this->cookie = []; |
| 72 | 72 | foreach ($this->psrRequest->getHeaders() as $key => $value) { |
| 73 | - $this->server["HTTP_" . strtoupper($key)] = $this->psrRequest->getHeaderLine($key); |
|
| 73 | + $this->server["HTTP_".strtoupper($key)] = $this->psrRequest->getHeaderLine($key); |
|
| 74 | 74 | |
| 75 | 75 | if ($key == "Cookie") { |
| 76 | 76 | parse_str(preg_replace("/;\s*/", "&", $this->psrRequest->getHeaderLine($key)), $this->cookie); |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | 'name' => $filename[1], |
| 158 | 158 | 'type' => (empty($contentType) ? "" : trim($contentType[1])), |
| 159 | 159 | 'size' => strlen($content), |
| 160 | - 'tmp_name' => sys_get_temp_dir() . "/" . $filename[1], |
|
| 160 | + 'tmp_name' => sys_get_temp_dir()."/".$filename[1], |
|
| 161 | 161 | 'error' => null |
| 162 | 162 | ]; |
| 163 | 163 | file_put_contents($strut["tmp_name"], $content); |
@@ -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 | /** |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | if (defined("RESTSERVER_TEST")) { |
| 63 | 63 | return; |
| 64 | 64 | } |
| 65 | - header("Content-Type: " . $this->contentType); |
|
| 65 | + header("Content-Type: ".$this->contentType); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | public function getContentType() |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | { |
| 75 | 75 | foreach ($response->getHeaders() as $header => $value) { |
| 76 | 76 | if (is_array($value)) { |
| 77 | - header("$header: " . array_shift($value), true); |
|
| 77 | + header("$header: ".array_shift($value), true); |
|
| 78 | 78 | foreach ($value as $headerValue) { |
| 79 | 79 | header("$header: $headerValue", false); |
| 80 | 80 | } |
@@ -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 | } |
@@ -43,9 +43,9 @@ |
||
| 43 | 43 | * |
| 44 | 44 | ********************************************************* */ |
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * @return int|null A handler may return nothing, or a Handler::HANDLE_* constant |
|
| 48 | - */ |
|
| 46 | + /** |
|
| 47 | + * @return int|null A handler may return nothing, or a Handler::HANDLE_* constant |
|
| 48 | + */ |
|
| 49 | 49 | public function handle() |
| 50 | 50 | { |
| 51 | 51 | if (!empty($this->outputProcessor)) { |
@@ -92,38 +92,38 @@ |
||
| 92 | 92 | |
| 93 | 93 | // Processing |
| 94 | 94 | switch ($routeInfo[0]) { |
| 95 | - case Dispatcher::NOT_FOUND: |
|
| 96 | - if ($this->tryDeliveryPhysicalFile() === false) { |
|
| 97 | - $this->initializeProcessor($response, $request); |
|
| 98 | - throw new Error404Exception("Route '$uri' not found"); |
|
| 99 | - } |
|
| 100 | - return true; |
|
| 101 | - |
|
| 102 | - case Dispatcher::METHOD_NOT_ALLOWED: |
|
| 95 | + case Dispatcher::NOT_FOUND: |
|
| 96 | + if ($this->tryDeliveryPhysicalFile() === false) { |
|
| 103 | 97 | $this->initializeProcessor($response, $request); |
| 104 | - throw new Error405Exception('Method not allowed'); |
|
| 98 | + throw new Error404Exception("Route '$uri' not found"); |
|
| 99 | + } |
|
| 100 | + return true; |
|
| 101 | + |
|
| 102 | + case Dispatcher::METHOD_NOT_ALLOWED: |
|
| 103 | + $this->initializeProcessor($response, $request); |
|
| 104 | + throw new Error405Exception('Method not allowed'); |
|
| 105 | 105 | |
| 106 | - case Dispatcher::FOUND: |
|
| 107 | - // ... 200 Process: |
|
| 108 | - $vars = array_merge($routeInfo[2], $queryStr); |
|
| 106 | + case Dispatcher::FOUND: |
|
| 107 | + // ... 200 Process: |
|
| 108 | + $vars = array_merge($routeInfo[2], $queryStr); |
|
| 109 | 109 | |
| 110 | - // Get the Selected Route |
|
| 111 | - $selectedRoute = $routeInfo[1]; |
|
| 110 | + // Get the Selected Route |
|
| 111 | + $selectedRoute = $routeInfo[1]; |
|
| 112 | 112 | |
| 113 | - // Default Handler for errors and |
|
| 114 | - $outputProcessor = $this->initializeProcessor($response, $request, $selectedRoute["output_processor"]); |
|
| 113 | + // Default Handler for errors and |
|
| 114 | + $outputProcessor = $this->initializeProcessor($response, $request, $selectedRoute["output_processor"]); |
|
| 115 | 115 | |
| 116 | - // Class |
|
| 117 | - $class = $selectedRoute["class"]; |
|
| 118 | - $request->appendVars($vars); |
|
| 116 | + // Class |
|
| 117 | + $class = $selectedRoute["class"]; |
|
| 118 | + $request->appendVars($vars); |
|
| 119 | 119 | |
| 120 | - // Execute the request |
|
| 121 | - $this->executeRequest($outputProcessor, $class, $response, $request); |
|
| 120 | + // Execute the request |
|
| 121 | + $this->executeRequest($outputProcessor, $class, $response, $request); |
|
| 122 | 122 | |
| 123 | - break; |
|
| 123 | + break; |
|
| 124 | 124 | |
| 125 | - default: |
|
| 126 | - throw new Error520Exception('Unknown'); |
|
| 125 | + default: |
|
| 126 | + throw new Error520Exception('Unknown'); |
|
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | 129 | |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | protected $detailedErrorHandler = false; |
| 30 | 30 | protected $disableCors = false; |
| 31 | 31 | protected $corsOrigins = ['.*']; |
| 32 | - protected $corsMethods = [ 'GET', 'POST', 'PUT', 'DELETE', 'PATCH']; |
|
| 32 | + protected $corsMethods = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH']; |
|
| 33 | 33 | protected $corsHeaders = [ |
| 34 | 34 | 'Authorization', |
| 35 | 35 | 'Content-Type', |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | if (preg_match("~^.*//$origin$~", $request->server('HTTP_ORIGIN'))) { |
| 176 | 176 | $response->addHeader("Access-Control-Allow-Origin", $request->server('HTTP_ORIGIN')); |
| 177 | 177 | $response->addHeader('Access-Control-Allow-Credentials', 'true'); |
| 178 | - $response->addHeader('Access-Control-Max-Age', '86400'); // cache for 1 day |
|
| 178 | + $response->addHeader('Access-Control-Max-Age', '86400'); // cache for 1 day |
|
| 179 | 179 | |
| 180 | 180 | // Access-Control headers are received during OPTIONS requests |
| 181 | 181 | if ($request->server('REQUEST_METHOD') == 'OPTIONS') { |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | |
| 210 | 210 | // Process Class::Method() |
| 211 | 211 | $function = $class[1]; |
| 212 | - $class = $class[0]; |
|
| 212 | + $class = $class[0]; |
|
| 213 | 213 | if (!class_exists($class)) { |
| 214 | 214 | throw new ClassNotFoundException("Class '$class' defined in the route is not found"); |
| 215 | 215 | } |
@@ -402,7 +402,7 @@ discard block |
||
| 402 | 402 | throw new InvalidArgumentException("Default processor needs to class name of an OutputProcessor"); |
| 403 | 403 | } |
| 404 | 404 | if (!is_subclass_of($processor, BaseOutputProcessor::class)) { |
| 405 | - throw new InvalidArgumentException("Needs to be a class of " . BaseOutputProcessor::class); |
|
| 405 | + throw new InvalidArgumentException("Needs to be a class of ".BaseOutputProcessor::class); |
|
| 406 | 406 | } |
| 407 | 407 | } |
| 408 | 408 | |