1 | <?php |
||
18 | abstract class ResponseBuilder implements Arrayable, Jsonable |
||
19 | { |
||
20 | /** |
||
21 | * A factory for making responses. |
||
22 | * |
||
23 | * @var \Flugg\Responder\Http\Responses\Factories\ResponseFactory |
||
24 | */ |
||
25 | protected $responseFactory; |
||
26 | |||
27 | /** |
||
28 | * A HTTP status code for the response. |
||
29 | * |
||
30 | * @var int |
||
31 | */ |
||
32 | protected $status; |
||
33 | |||
34 | /** |
||
35 | * Construct the builder class. |
||
36 | * |
||
37 | * @param \Flugg\Responder\Contracts\ResponseFactory $responseFactory |
||
38 | */ |
||
39 | public function __construct(ResponseFactory $responseFactory) |
||
43 | |||
44 | /** |
||
45 | * Respond with a successful response. |
||
46 | * |
||
47 | * @param int|null $status |
||
48 | * @param array $headers |
||
49 | * @return \Illuminate\Http\JsonResponse |
||
50 | */ |
||
51 | public function respond(int $status = null, array $headers = []): JsonResponse |
||
59 | |||
60 | /** |
||
61 | * Convert the response to an array. |
||
62 | * |
||
63 | * @return array |
||
64 | */ |
||
65 | public function toArray(): array |
||
69 | |||
70 | /** |
||
71 | * Convert the response to an Illuminate collection. |
||
72 | * |
||
73 | * @return \Illuminate\Support\Collection |
||
74 | */ |
||
75 | public function toCollection(): Collection |
||
79 | |||
80 | /** |
||
81 | * Convert the response to JSON. |
||
82 | * |
||
83 | * @param int $options |
||
84 | * @return string |
||
85 | */ |
||
86 | public function toJson($options = 0): string |
||
90 | |||
91 | /** |
||
92 | * Set the HTTP status code for the response. |
||
93 | * |
||
94 | * @param int $status |
||
95 | * @return void |
||
96 | */ |
||
97 | protected function setStatusCode(int $status): void |
||
101 | |||
102 | /** |
||
103 | * Get the serialized response output. |
||
104 | * |
||
105 | * @return array |
||
106 | */ |
||
107 | abstract protected function getOutput(): array; |
||
108 | |||
109 | /** |
||
110 | * Convert the response to an array. |
||
111 | * |
||
112 | * @param int $status |
||
113 | * @return void |
||
114 | */ |
||
115 | abstract protected function validateStatusCode(int $status): void; |
||
116 | } |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..