@@ -57,11 +57,11 @@ discard block |
||
| 57 | 57 | do { |
| 58 | 58 | if ($cfg === null) { |
| 59 | 59 | // Default handler MUST be present by design and always return something useful. |
| 60 | - $cfg = self::getExceptionHandlerConfig()[ RB::KEY_DEFAULT ]; |
|
| 60 | + $cfg = self::getExceptionHandlerConfig()[RB::KEY_DEFAULT]; |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - $handler = new $cfg[ RB::KEY_HANDLER ](); |
|
| 64 | - $handler_result = $handler->handle($cfg[ RB::KEY_CONFIG ], $ex); |
|
| 63 | + $handler = new $cfg[RB::KEY_HANDLER](); |
|
| 64 | + $handler_result = $handler->handle($cfg[RB::KEY_CONFIG], $ex); |
|
| 65 | 65 | if ($handler_result !== null) { |
| 66 | 66 | $result = self::processException($ex, $handler_result); |
| 67 | 67 | } else { |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | $cfg = self::getExceptionHandlerConfig(); |
| 186 | 186 | |
| 187 | 187 | // This config entry is guaranted to exist. Enforced by tests. |
| 188 | - $cfg = $cfg[ HttpException::class ][ RB::KEY_CONFIG ][ HttpResponse::HTTP_UNAUTHORIZED ]; |
|
| 188 | + $cfg = $cfg[HttpException::class][RB::KEY_CONFIG][HttpResponse::HTTP_UNAUTHORIZED]; |
|
| 189 | 189 | |
| 190 | 190 | /** |
| 191 | 191 | * NOTE: no typehint due to compatibility with Laravel signature. |
@@ -329,14 +329,14 @@ discard block |
||
| 329 | 329 | |
| 330 | 330 | // check for exact class name match... |
| 331 | 331 | if (\array_key_exists($cls, $cfg)) { |
| 332 | - $result = $cfg[ $cls ]; |
|
| 332 | + $result = $cfg[$cls]; |
|
| 333 | 333 | } else { |
| 334 | 334 | // no exact match, then lets try with `instanceof` |
| 335 | 335 | // Config entries are already sorted by priority. |
| 336 | 336 | foreach (\array_keys($cfg) as $class_name) { |
| 337 | 337 | /** @var string $class_name */ |
| 338 | 338 | if ($ex instanceof $class_name) { |
| 339 | - $result = $cfg[ $class_name ]; |
|
| 339 | + $result = $cfg[$class_name]; |
|
| 340 | 340 | break; |
| 341 | 341 | } |
| 342 | 342 | } |
@@ -391,11 +391,11 @@ discard block |
||
| 391 | 391 | $data = (new Converter())->convert($data); |
| 392 | 392 | if ($data !== null) { |
| 393 | 393 | // ensure we get object in final JSON structure in data node |
| 394 | - $data = (object)$data; |
|
| 394 | + $data = (object) $data; |
|
| 395 | 395 | } |
| 396 | 396 | |
| 397 | 397 | if ($data === null && Config::get(RB::CONF_KEY_DATA_ALWAYS_OBJECT, false)) { |
| 398 | - $data = (object)[]; |
|
| 398 | + $data = (object) []; |
|
| 399 | 399 | } |
| 400 | 400 | |
| 401 | 401 | // get human readable message for API code or use message string (if given instead of API code) |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | |
| 418 | 418 | if ($debug_data !== null) { |
| 419 | 419 | $debug_key = Config::get(RB::CONF_KEY_DEBUG_DEBUG_KEY, RB::KEY_DEBUG); |
| 420 | - $response[ $debug_key ] = $debug_data; |
|
| 420 | + $response[$debug_key] = $debug_data; |
|
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | return $response; |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | protected function getPrimitiveMappingConfigOrThrow($data): array |
| 63 | 63 | { |
| 64 | 64 | $type = \gettype($data); |
| 65 | - $result = $this->primitives[ $type ] ?? null; |
|
| 65 | + $result = $this->primitives[$type] ?? null; |
|
| 66 | 66 | |
| 67 | 67 | if ($result === null) { |
| 68 | 68 | throw new Ex\ConfigurationNotFoundException( |
@@ -94,14 +94,14 @@ discard block |
||
| 94 | 94 | $cls = \get_class($data); |
| 95 | 95 | if (\is_string($cls)) { |
| 96 | 96 | if (\array_key_exists($cls, $this->classes)) { |
| 97 | - $result = $this->classes[ $cls ]; |
|
| 97 | + $result = $this->classes[$cls]; |
|
| 98 | 98 | $debug_result = 'exact config match'; |
| 99 | 99 | } else { |
| 100 | 100 | // no exact match, then lets try with `instanceof` |
| 101 | 101 | foreach (\array_keys($this->classes) as $class_name) { |
| 102 | 102 | /** @var string $class_name */ |
| 103 | 103 | if ($data instanceof $class_name) { |
| 104 | - $result = $this->classes[ $class_name ]; |
|
| 104 | + $result = $this->classes[$class_name]; |
|
| 105 | 105 | $debug_result = "subclass of {$class_name}"; |
| 106 | 106 | break; |
| 107 | 107 | } |
@@ -150,9 +150,9 @@ discard block |
||
| 150 | 150 | |
| 151 | 151 | if ($result === null && \is_object($data)) { |
| 152 | 152 | $cfg = $this->getClassMappingConfigOrThrow($data); |
| 153 | - $worker = new $cfg[ RB::KEY_HANDLER ](); |
|
| 153 | + $worker = new $cfg[RB::KEY_HANDLER](); |
|
| 154 | 154 | $result = $worker->convert($data, $cfg); |
| 155 | - $result = $cfg[ RB::KEY_KEY ] === null ? $result : [$cfg[ RB::KEY_KEY ] => $result]; |
|
| 155 | + $result = $cfg[RB::KEY_KEY] === null ? $result : [$cfg[RB::KEY_KEY] => $result]; |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | if ($result === null && \is_array($data)) { |
@@ -160,12 +160,12 @@ discard block |
||
| 160 | 160 | |
| 161 | 161 | $result = $this->convertArray($data); |
| 162 | 162 | if (!Util::isArrayWithNonNumericKeys($data)) { |
| 163 | - $result = [$cfg[ RB::KEY_KEY ] => $result]; |
|
| 163 | + $result = [$cfg[RB::KEY_KEY] => $result]; |
|
| 164 | 164 | } |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | if (\is_bool($data) || \is_float($data) || \is_int($data) || \is_string($data)) { |
| 168 | - $result = [$this->getPrimitiveMappingConfigOrThrow($data)[ RB::KEY_KEY ] => $data]; |
|
| 168 | + $result = [$this->getPrimitiveMappingConfigOrThrow($data)[RB::KEY_KEY] => $data]; |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | return $result; |
@@ -188,12 +188,12 @@ discard block |
||
| 188 | 188 | |
| 189 | 189 | foreach ($data as $key => $val) { |
| 190 | 190 | if (\is_array($val)) { |
| 191 | - $data[ $key ] = $this->convertArray($val); |
|
| 191 | + $data[$key] = $this->convertArray($val); |
|
| 192 | 192 | } elseif (\is_object($val)) { |
| 193 | 193 | $cfg = $this->getClassMappingConfigOrThrow($val); |
| 194 | - $worker = new $cfg[ RB::KEY_HANDLER ](); |
|
| 194 | + $worker = new $cfg[RB::KEY_HANDLER](); |
|
| 195 | 195 | $converted_data = $worker->convert($val, $cfg); |
| 196 | - $data[ $key ] = $converted_data; |
|
| 196 | + $data[$key] = $converted_data; |
|
| 197 | 197 | } |
| 198 | 198 | } |
| 199 | 199 | |