Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions lib/public/AppFramework/Http/DataResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,18 @@
* A generic DataResponse class that is used to return generic data responses
* for responders to transform
* @since 8.0.0
* @template T
*/
class DataResponse extends Response {
/**
* response data
* @var array|int|float|string|bool|object
* @var T
*/
protected $data;


/**
* @param array|int|float|string|bool|object $data the object or array that should be transformed
* @param T $data the object or array that should be transformed
* @param int $statusCode the Http status code, defaults to 200
* @param array $headers additional key value based headers
* @since 8.0.0
Expand All @@ -57,7 +58,7 @@ public function __construct($data = [], $statusCode = Http::STATUS_OK,

/**
* Sets values in the data json array
* @param array|int|float|string|object $data an array or object which will be transformed
* @param T $data an array or object which will be transformed
* @return DataResponse Reference to this object
* @since 8.0.0
*/
Expand All @@ -70,7 +71,7 @@ public function setData($data) {

/**
* Used to get the set parameters
* @return array|int|float|string|bool|object the data
* @return T the data
* @since 8.0.0
*/
public function getData() {
Expand Down
9 changes: 5 additions & 4 deletions lib/public/AppFramework/Http/JSONResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,19 @@
/**
* A renderer for JSON calls
* @since 6.0.0
* @template T
*/
class JSONResponse extends Response {
/**
* response data
* @var array|object
* @var T
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this weakens the type. before it was an array or object. now it can be anything

*/
protected $data;


/**
* constructor of JSONResponse
* @param array|object $data the object or array that should be transformed
* @param T $data the object or array that should be transformed
* @param int $statusCode the Http status code, defaults to 200
* @since 6.0.0
*/
Expand All @@ -68,7 +69,7 @@ public function render() {

/**
* Sets values in the data json array
* @param array|object $data an array or object which will be transformed
* @param T $data an array or object which will be transformed
* to JSON
* @return JSONResponse Reference to this object
* @since 6.0.0 - return value was added in 7.0.0
Expand All @@ -82,7 +83,7 @@ public function setData($data) {

/**
* Used to get the set parameters
* @return array the data
* @return T the data
* @since 6.0.0
*/
public function getData() {
Expand Down