2525 */
2626class ResponseBuilder extends ResponseBuilderBase
2727{
28- protected bool $ success = false ;
28+ protected bool $ success = false ;
2929 protected int $ api_code ;
30- protected ?int $ http_code = null ;
31- protected ?string $ message = null ;
30+ protected ?int $ http_code = null ;
31+ protected ?string $ message = null ;
3232 /** @var array<string, mixed>|null */
33- protected ?array $ placeholders = null ;
34- protected ?int $ json_opts = null ;
33+ protected ?array $ placeholders = null ;
34+ protected ?int $ json_opts = null ;
3535 /** @var array<string, mixed>|null */
36- protected ?array $ debug_data = null ;
36+ protected ?array $ debug_data = null ;
3737 /** @var array<string, mixed> */
38- protected array $ http_headers = [];
38+ protected array $ http_headers = [];
3939
4040 /** @var mixed|null $data */
4141 protected $ data = null ;
@@ -59,18 +59,18 @@ protected function __construct(bool $success, int $api_code)
5959 /**
6060 * Returns success
6161 *
62- * @param mixed|null $data Array of primitives and supported objects to be returned in
63- * 'data' node of the JSON response, single supported object
64- * or @null if there's no to be returned.
65- * @param integer|null $api_code API code to be returned or @null to use value of
66- * BaseApiCodes::OK().
67- * @param array<string, mixed>|null $placeholders Placeholders passed to Lang::get() for message placeholders
68- * substitution or @null if none.
69- * @param integer|null $http_code HTTP code to be used for HttpResponse sent or @null
70- * for default DEFAULT_HTTP_CODE_OK.
71- * @param integer|null $json_opts See http://php.net/manual/en/function.json-encode.php for
72- * supported options or pass @null to use value from your
73- * config (or defaults).
62+ * @param mixed|null $data Array of primitives and supported objects to be returned in
63+ * 'data' node of the JSON response, single supported object
64+ * or @null if there's no to be returned.
65+ * @param integer|null $api_code API code to be returned or @null to use value of
66+ * BaseApiCodes::OK().
67+ * @param array<string, mixed>|null $placeholders Placeholders passed to Lang::get() for message placeholders
68+ * substitution or @null if none.
69+ * @param integer|null $http_code HTTP code to be used for HttpResponse sent or @null
70+ * for default DEFAULT_HTTP_CODE_OK.
71+ * @param integer|null $json_opts See http://php.net/manual/en/function.json-encode.php for
72+ * supported options or pass @null to use value from your
73+ * config (or defaults).
7474 *
7575 * @throws Ex\MissingConfigurationKeyException
7676 * @throws Ex\ConfigurationNotFoundException
@@ -97,17 +97,17 @@ public static function success(mixed $data = null,
9797 * Builds error Response object. Supports optional arguments passed to Lang::get() if associated error
9898 * message uses placeholders as well as return data payload
9999 *
100- * @param integer $api_code Your API code to be returned with the response object.
101- * @param array<string, mixed>|null $placeholders Placeholders passed to Lang::get() for message
102- * placeholders substitution or @null if none.
103- * @param object|array<string, mixed>|null $data Array of primitives and supported objects to be
104- * returned in 'data' node of the JSON response, single
105- * supported object or @null if there's no to be returned.
106- * @param integer|null $http_code HTTP code to be used for HttpResponse sent or @null
107- * for default DEFAULT_HTTP_CODE_ERROR.
108- * @param integer|null $json_opts See http://php.net/manual/en/function.json-encode.php
109- * for supported options or pass @null to use value from
110- * your config (or defaults).
100+ * @param integer $api_code Your API code to be returned with the response object.
101+ * @param array<string, mixed>|null $placeholders Placeholders passed to Lang::get() for message
102+ * placeholders substitution or @null if none.
103+ * @param object|array<string, mixed>|null $data Array of primitives and supported objects to be
104+ * returned in 'data' node of the JSON response, single
105+ * supported object or @null if there's no to be returned.
106+ * @param integer|null $http_code HTTP code to be used for HttpResponse sent or @null
107+ * for default DEFAULT_HTTP_CODE_ERROR.
108+ * @param integer|null $json_opts See http://php.net/manual/en/function.json-encode.php
109+ * for supported options or pass @null to use value from
110+ * your config (or defaults).
111111 *
112112 * @throws Ex\ArrayWithMixedKeysException
113113 * @throws Ex\MissingConfigurationKeyException
@@ -119,8 +119,8 @@ public static function success(mixed $data = null,
119119 public static function error (int $ api_code ,
120120 ?array $ placeholders = null ,
121121 mixed $ data = null ,
122- int $ http_code = null ,
123- int $ json_opts = null ): HttpResponse
122+ ? int $ http_code = null ,
123+ ? int $ json_opts = null ): HttpResponse
124124 {
125125 return static ::asError ($ api_code )
126126 ->withPlaceholders ($ placeholders )
@@ -139,7 +139,7 @@ public static function error(int $api_code,
139139 * @throws Ex\MissingConfigurationKeyException
140140 * @throws Ex\NotIntegerException
141141 */
142- public static function asSuccess (int $ api_code = null ): self
142+ public static function asSuccess (? int $ api_code = null ): self
143143 {
144144 /** @noinspection PhpUnhandledExceptionInspection */
145145 return new static (true , $ api_code ?? BaseApiCodes::OK ());
@@ -321,21 +321,21 @@ public function build(): HttpResponse
321321 }
322322
323323 /**
324- * @param boolean $success TRUE if response reports successful operation,
325- * FALSE otherwise.
326- * @param integer $api_code API code to be returned with the response object.
327- * @param string|integer $msg_or_api_code Message string or valid API code to get message for
328- * @param mixed|null $data optional additional data to be included in response.
329- * @param integer|null $http_code HTTP code for the HttpResponse or @null for either
330- * DEFAULT_HTTP_CODE_OK or DEFAULT_HTTP_CODE_ERROR
331- * depending on the $success.
332- * @param array<string, mixed>|null $placeholders Placeholders passed to Lang::get() for message
333- * placeholders substitution or @null if none.
334- * @param array<string, mixed>|null $http_headers Optional HTTP headers to be returned in the response.
335- * @param integer|null $json_opts See http://php.net/manual/en/function.json-encode.php
336- * for supported options or pass @null to use value from
337- * your config (or defaults).
338- * @param array<string, mixed>|null $debug_data Optional debug data array to be added to returned JSON.
324+ * @param boolean $success TRUE if response reports successful operation,
325+ * FALSE otherwise.
326+ * @param integer $api_code API code to be returned with the response object.
327+ * @param string|integer $msg_or_api_code Message string or valid API code to get message for
328+ * @param mixed|null $data optional additional data to be included in response.
329+ * @param integer|null $http_code HTTP code for the HttpResponse or @null for either
330+ * DEFAULT_HTTP_CODE_OK or DEFAULT_HTTP_CODE_ERROR
331+ * depending on the $success.
332+ * @param array<string, mixed>|null $placeholders Placeholders passed to Lang::get() for message
333+ * placeholders substitution or @null if none.
334+ * @param array<string, mixed>|null $http_headers Optional HTTP headers to be returned in the response.
335+ * @param integer|null $json_opts See http://php.net/manual/en/function.json-encode.php
336+ * for supported options or pass @null to use value from
337+ * your config (or defaults).
338+ * @param array<string, mixed>|null $debug_data Optional debug data array to be added to returned JSON.
339339 *
340340 * @throws Ex\MissingConfigurationKeyException
341341 * @throws Ex\ConfigurationNotFoundException
@@ -382,13 +382,13 @@ protected function make(bool $success,
382382 * added to reported JSON for easier manual debugging. Returns response ready to be encoded as
383383 * JSON and sent back to client.
384384 *
385- * @param boolean $success TRUE if response reports successful operation, FALSE otherwise.
386- * @param integer $api_code Your API code to be returned with the response object.
387- * @param string|integer $msg_or_api_code Message string or valid API code to get message for.
388- * @param array<string, mixed>|null $placeholders Placeholders passed to Lang::get() for message placeholders
389- * substitution or @null if none.
390- * @param mixed|null $data API response data if any
391- * @param array<string, mixed>|null $debug_data optional debug data array to be added to returned JSON.
385+ * @param boolean $success TRUE if response reports successful operation, FALSE otherwise.
386+ * @param integer $api_code Your API code to be returned with the response object.
387+ * @param string|integer $msg_or_api_code Message string or valid API code to get message for.
388+ * @param array<string, mixed>|null $placeholders Placeholders passed to Lang::get() for message placeholders
389+ * substitution or @null if none.
390+ * @param mixed|null $data API response data if any
391+ * @param array<string, mixed>|null $debug_data optional debug data array to be added to returned JSON.
392392 *
393393 * @return array<string, mixed>
394394 *
0 commit comments