Completed
Push — master ( 72e711...113d4b )
by ARCANEDEV
03:42
created

src/Traits/JsonResponses.php (1 issue)

Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php namespace Arcanedev\LaravelApiHelper\Traits;
2
3
/**
4
 * Class     JsonResponses
5
 *
6
 * @package  Arcanedev\LaravelApiHelper\Traits
7
 * @author   ARCANEDEV <[email protected]>
8
 */
9
trait JsonResponses
10
{
11
    /* -----------------------------------------------------------------
12
     |  Main Methods
13
     | -----------------------------------------------------------------
14
     */
15
16
    /**
17
     * Get the json response instance.
18
     *
19
     * @return \Arcanedev\LaravelApiHelper\Contracts\Http\JsonResponse
20
     */
21 12
    public function jsonResponse()
22
    {
23 12
        return json_response();
24
    }
25
26
    /**
27
     * Respond with a success response.
28
     *
29
     * @param  array   $data
30
     * @param  int     $status
31
     * @param  string  $code
32
     * @param  array   $headers
33
     * @param  int     $options
34
     *
35
     * @return \Illuminate\Http\JsonResponse
36
     */
37 9
    public function jsonResponseSuccess(array $data, $status = 200, $code = 'success', array $headers = [], $options = 0)
38
    {
39 9
        return $this->jsonResponse()->success($data, $status, $code, $headers, $options);
40
    }
41
42
    /**
43
     * Respond with an error response.
44
     *
45
     * @param  string  $message
46
     * @param  int     $status
47
     * @param  string  $code
48
     * @param  array   $headers
49
     * @param  int     $options
50
     *
51
     * @return \Illuminate\Http\JsonResponse
52
     */
53 3
    public function jsonResponseError($message, $status = 400, $code = 'error', array $headers = [], $options = 0)
54
    {
55 3
        return $this->jsonResponse()->error($message, $status, $code, $headers, $options);
0 ignored issues
show
$message is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
56
    }
57
}
58