@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | $whoops = new \Whoops\Run(); |
83 | 83 | |
84 | 84 | if (is_ajax() or $this->mimeType === 'application/json' or $this->mimeType === 'application/xml') { |
85 | - $whoops->pushHandler(new CallbackHandler(function ($error) { |
|
85 | + $whoops->pushHandler(new CallbackHandler(function($error) { |
|
86 | 86 | $this->send([ |
87 | 87 | 'status' => 500, |
88 | 88 | 'success' => false, |
@@ -123,10 +123,10 @@ discard block |
||
123 | 123 | |
124 | 124 | if (is_array($lastError)) { |
125 | 125 | $this->errorHandler( |
126 | - $lastError[ 'type' ], |
|
127 | - $lastError[ 'message' ], |
|
128 | - $lastError[ 'file' ], |
|
129 | - $lastError[ 'line' ] |
|
126 | + $lastError['type'], |
|
127 | + $lastError['message'], |
|
128 | + $lastError['file'], |
|
129 | + $lastError['line'] |
|
130 | 130 | ); |
131 | 131 | } |
132 | 132 | } |
@@ -257,8 +257,8 @@ discard block |
||
257 | 257 | if (strpos($mimeType, '/') === false) { |
258 | 258 | $extension = ltrim($mimeType, '.'); |
259 | 259 | // Is this extension supported? |
260 | - if (isset($mimes[ $extension ])) { |
|
261 | - $mimeType =& $mimes[ $extension ]; |
|
260 | + if (isset($mimes[$extension])) { |
|
261 | + $mimeType = & $mimes[$extension]; |
|
262 | 262 | if (is_array($mimeType)) { |
263 | 263 | $mimeType = current($mimeType); |
264 | 264 | } |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | */ |
289 | 289 | public function addHeader($name, $value) |
290 | 290 | { |
291 | - $this->headers[ $name ] = $value; |
|
291 | + $this->headers[$name] = $value; |
|
292 | 292 | |
293 | 293 | return $this; |
294 | 294 | } |
@@ -312,56 +312,56 @@ discard block |
||
312 | 312 | ]; |
313 | 313 | |
314 | 314 | if (is_array($data)) { |
315 | - if (isset($data[ 'status' ])) { |
|
316 | - $response[ 'status' ] = $statusCode = $data[ 'status' ]; |
|
317 | - unset($data[ 'status' ]); |
|
315 | + if (isset($data['status'])) { |
|
316 | + $response['status'] = $statusCode = $data['status']; |
|
317 | + unset($data['status']); |
|
318 | 318 | } |
319 | 319 | |
320 | - if (isset($data[ 'reason' ])) { |
|
321 | - $response[ 'reason' ] = $reasonPhrase = $data[ 'reason' ]; |
|
322 | - unset($data[ 'reason' ]); |
|
320 | + if (isset($data['reason'])) { |
|
321 | + $response['reason'] = $reasonPhrase = $data['reason']; |
|
322 | + unset($data['reason']); |
|
323 | 323 | } |
324 | 324 | |
325 | - if (isset($data[ 'success' ])) { |
|
326 | - $response[ 'success' ] = $data[ 'success' ]; |
|
327 | - unset($data[ 'success' ]); |
|
325 | + if (isset($data['success'])) { |
|
326 | + $response['success'] = $data['success']; |
|
327 | + unset($data['success']); |
|
328 | 328 | } |
329 | 329 | |
330 | - if (isset($data[ 'message' ])) { |
|
331 | - $response[ 'message' ] = $data[ 'message' ]; |
|
332 | - unset($data[ 'message' ]); |
|
330 | + if (isset($data['message'])) { |
|
331 | + $response['message'] = $data['message']; |
|
332 | + unset($data['message']); |
|
333 | 333 | } |
334 | 334 | |
335 | - if (isset($data[ 'metadata' ])) { |
|
336 | - $response[ 'metadata' ] = $data[ 'metadata' ]; |
|
337 | - unset($data[ 'metadata' ]); |
|
335 | + if (isset($data['metadata'])) { |
|
336 | + $response['metadata'] = $data['metadata']; |
|
337 | + unset($data['metadata']); |
|
338 | 338 | } |
339 | 339 | |
340 | - if (isset($data[ 'result' ])) { |
|
341 | - $data = $data[ 'result' ]; |
|
340 | + if (isset($data['result'])) { |
|
341 | + $data = $data['result']; |
|
342 | 342 | } |
343 | 343 | |
344 | - if (isset($data[ 'data' ])) { |
|
345 | - $data = $data[ 'data' ]; |
|
344 | + if (isset($data['data'])) { |
|
345 | + $data = $data['data']; |
|
346 | 346 | } |
347 | 347 | } elseif (is_object($data)) { |
348 | 348 | if (isset($data->status)) { |
349 | - $response[ 'status' ] = $statusCode = $data->status; |
|
349 | + $response['status'] = $statusCode = $data->status; |
|
350 | 350 | unset($data->status); |
351 | 351 | } |
352 | 352 | |
353 | 353 | if (isset($data->reason)) { |
354 | - $response[ 'reason' ] = $reasonPhrase = $data->reason; |
|
354 | + $response['reason'] = $reasonPhrase = $data->reason; |
|
355 | 355 | unset($data->reason); |
356 | 356 | } |
357 | 357 | |
358 | 358 | if (isset($data->success)) { |
359 | - $response[ 'success' ] = $data->success; |
|
359 | + $response['success'] = $data->success; |
|
360 | 360 | unset($data->success); |
361 | 361 | } |
362 | 362 | |
363 | 363 | if (isset($data->message)) { |
364 | - $response[ 'message' ] = $data->message; |
|
364 | + $response['message'] = $data->message; |
|
365 | 365 | unset($data->message); |
366 | 366 | } |
367 | 367 | |
@@ -388,16 +388,16 @@ discard block |
||
388 | 388 | |
389 | 389 | if (is_array($data)) { |
390 | 390 | if (is_string(key($data))) { |
391 | - $response[ 'result' ] = [$data]; |
|
391 | + $response['result'] = [$data]; |
|
392 | 392 | } elseif (is_numeric(key($data))) { |
393 | - $response[ 'result' ] = $data; |
|
393 | + $response['result'] = $data; |
|
394 | 394 | } |
395 | 395 | } else { |
396 | - $response[ 'result' ] = $data; |
|
396 | + $response['result'] = $data; |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | if (is_ajax()) { |
400 | - $contentType = isset($_SERVER[ 'HTTP_X_REQUESTED_CONTENT_TYPE' ]) ? $_SERVER[ 'HTTP_X_REQUESTED_CONTENT_TYPE' ] : 'application/json'; |
|
400 | + $contentType = isset($_SERVER['HTTP_X_REQUESTED_CONTENT_TYPE']) ? $_SERVER['HTTP_X_REQUESTED_CONTENT_TYPE'] : 'application/json'; |
|
401 | 401 | $this->setContentType($contentType); |
402 | 402 | } |
403 | 403 | |
@@ -410,12 +410,12 @@ discard block |
||
410 | 410 | $this->arrayToXml($response, $xml); |
411 | 411 | |
412 | 412 | echo $xml->asXML(); |
413 | - } elseif(is_cli()) { |
|
413 | + } elseif (is_cli()) { |
|
414 | 414 | print_cli($response, true); |
415 | - } elseif(is_array($response['result'])) { |
|
415 | + } elseif (is_array($response['result'])) { |
|
416 | 416 | print_r($response['result']); |
417 | 417 | } else { |
418 | - echo $response[ 'result' ]; |
|
418 | + echo $response['result']; |
|
419 | 419 | } |
420 | 420 | } |
421 | 421 | |
@@ -434,8 +434,8 @@ discard block |
||
434 | 434 | foreach (headers_list() as $header) { |
435 | 435 | $headerParts = explode(':', $header); |
436 | 436 | $headerParts = array_map('trim', $headerParts); |
437 | - $headers[ $headerParts[ 0 ] ] = $headerParts[ 1 ]; |
|
438 | - header_remove($header[ 0 ]); |
|
437 | + $headers[$headerParts[0]] = $headerParts[1]; |
|
438 | + header_remove($header[0]); |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | if (count($headers)) { |
@@ -561,21 +561,21 @@ discard block |
||
561 | 561 | ]; |
562 | 562 | |
563 | 563 | $this->statusCode = $code; |
564 | - $this->reasonPhrase = $error[ 'title' ]; |
|
564 | + $this->reasonPhrase = $error['title']; |
|
565 | 565 | |
566 | 566 | if (is_string($vars)) { |
567 | 567 | $vars = ['message' => $vars]; |
568 | - } elseif (is_array($vars) and empty($vars[ 'message' ])) { |
|
569 | - $vars[ 'message' ] = $error[ 'message' ]; |
|
568 | + } elseif (is_array($vars) and empty($vars['message'])) { |
|
569 | + $vars['message'] = $error['message']; |
|
570 | 570 | } |
571 | 571 | |
572 | - if (isset($vars[ 'message' ])) { |
|
573 | - $error[ 'message' ] = $vars[ 'message' ]; |
|
572 | + if (isset($vars['message'])) { |
|
573 | + $error['message'] = $vars['message']; |
|
574 | 574 | } |
575 | 575 | |
576 | 576 | if (is_ajax() or $this->mimeType !== 'text/html') { |
577 | 577 | $this->statusCode = $code; |
578 | - $this->reasonPhrase = $error[ 'title' ]; |
|
578 | + $this->reasonPhrase = $error['title']; |
|
579 | 579 | $this->send($vars); |
580 | 580 | |
581 | 581 | exit(EXIT_ERROR); |