From 7676ba2801bf3fcd1eb9c3b81dc9a8eab3910697 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 29 Jul 2022 16:29:24 +0900 Subject: [PATCH 1/3] docs: fix types in PHPDocs --- system/RESTful/ResourceController.php | 25 +++++++++++++----------- system/RESTful/ResourcePresenter.php | 28 ++++++++++++++------------- 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/system/RESTful/ResourceController.php b/system/RESTful/ResourceController.php index 809545c1513b..2cdcc5b11e2c 100644 --- a/system/RESTful/ResourceController.php +++ b/system/RESTful/ResourceController.php @@ -12,6 +12,7 @@ namespace CodeIgniter\RESTful; use CodeIgniter\API\ResponseTrait; +use CodeIgniter\HTTP\Response; /** * An extendable controller to provide a RESTful API for a resource. @@ -23,7 +24,7 @@ class ResourceController extends BaseResource /** * Return an array of resource objects, themselves in array format * - * @return mixed + * @return Response */ public function index() { @@ -33,9 +34,9 @@ public function index() /** * Return the properties of a resource object * - * @param mixed $id + * @param string|null $id * - * @return mixed + * @return Response */ public function show($id = null) { @@ -45,7 +46,7 @@ public function show($id = null) /** * Return a new resource object, with default properties * - * @return mixed + * @return Response */ public function new() { @@ -55,7 +56,7 @@ public function new() /** * Create a new resource object, from "posted" parameters * - * @return mixed + * @return Response */ public function create() { @@ -65,9 +66,9 @@ public function create() /** * Return the editable properties of a resource object * - * @param mixed $id + * @param string|null $id * - * @return mixed + * @return Response */ public function edit($id = null) { @@ -77,9 +78,9 @@ public function edit($id = null) /** * Add or update a model resource, from "posted" properties * - * @param mixed $id + * @param string|null $id * - * @return mixed + * @return Response */ public function update($id = null) { @@ -89,9 +90,9 @@ public function update($id = null) /** * Delete the designated resource object from the model * - * @param mixed $id + * @param string|null $id * - * @return mixed + * @return Response */ public function delete($id = null) { @@ -100,6 +101,8 @@ public function delete($id = null) /** * Set/change the expected response representation for returned objects + * + * @return void */ public function setFormat(string $format = 'json') { diff --git a/system/RESTful/ResourcePresenter.php b/system/RESTful/ResourcePresenter.php index 467e2687c40d..d39405fffcf6 100644 --- a/system/RESTful/ResourcePresenter.php +++ b/system/RESTful/ResourcePresenter.php @@ -11,6 +11,8 @@ namespace CodeIgniter\RESTful; +use CodeIgniter\HTTP\Response; + /** * An extendable controller to help provide a UI for a resource. */ @@ -19,7 +21,7 @@ class ResourcePresenter extends BaseResource /** * Present a view of resource objects * - * @return mixed + * @return Response|string */ public function index() { @@ -29,9 +31,9 @@ public function index() /** * Present a view to present a specific resource object * - * @param mixed $id + * @param string|null $id * - * @return mixed + * @return Response|string */ public function show($id = null) { @@ -41,7 +43,7 @@ public function show($id = null) /** * Present a view to present a new single resource object * - * @return mixed + * @return Response|string */ public function new() { @@ -52,7 +54,7 @@ public function new() * Process the creation/insertion of a new resource object. * This should be a POST. * - * @return mixed + * @return Response|string */ public function create() { @@ -62,9 +64,9 @@ public function create() /** * Present a view to edit the properties of a specific resource object * - * @param mixed $id + * @param string|null $id * - * @return mixed + * @return Response|string */ public function edit($id = null) { @@ -75,9 +77,9 @@ public function edit($id = null) * Process the updating, full or partial, of a specific resource object. * This should be a POST. * - * @param mixed $id + * @param string|null $id * - * @return mixed + * @return Response|string */ public function update($id = null) { @@ -87,9 +89,9 @@ public function update($id = null) /** * Present a view to confirm the deletion of a specific resource object * - * @param mixed $id + * @param string|null $id * - * @return mixed + * @return Response|string */ public function remove($id = null) { @@ -99,9 +101,9 @@ public function remove($id = null) /** * Process the deletion of a specific resource object * - * @param mixed $id + * @param string|null $id * - * @return mixed + * @return Response|string */ public function delete($id = null) { From a0ababfa56583f0036b0487e882a3d5ac8db4d96 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 4 Aug 2022 17:25:06 +0900 Subject: [PATCH 2/3] docs: fix @return Controller method can return string or void. --- system/RESTful/ResourceController.php | 14 +++++++------- system/RESTful/ResourcePresenter.php | 16 ++++++++-------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/system/RESTful/ResourceController.php b/system/RESTful/ResourceController.php index 2cdcc5b11e2c..07c4fcae760f 100644 --- a/system/RESTful/ResourceController.php +++ b/system/RESTful/ResourceController.php @@ -24,7 +24,7 @@ class ResourceController extends BaseResource /** * Return an array of resource objects, themselves in array format * - * @return Response + * @return Response|string|void */ public function index() { @@ -36,7 +36,7 @@ public function index() * * @param string|null $id * - * @return Response + * @return Response|string|void */ public function show($id = null) { @@ -46,7 +46,7 @@ public function show($id = null) /** * Return a new resource object, with default properties * - * @return Response + * @return Response|string|void */ public function new() { @@ -56,7 +56,7 @@ public function new() /** * Create a new resource object, from "posted" parameters * - * @return Response + * @return Response|string|void */ public function create() { @@ -68,7 +68,7 @@ public function create() * * @param string|null $id * - * @return Response + * @return Response|string|void */ public function edit($id = null) { @@ -80,7 +80,7 @@ public function edit($id = null) * * @param string|null $id * - * @return Response + * @return Response|string|void */ public function update($id = null) { @@ -92,7 +92,7 @@ public function update($id = null) * * @param string|null $id * - * @return Response + * @return Response|string|void */ public function delete($id = null) { diff --git a/system/RESTful/ResourcePresenter.php b/system/RESTful/ResourcePresenter.php index d39405fffcf6..8655c2e48487 100644 --- a/system/RESTful/ResourcePresenter.php +++ b/system/RESTful/ResourcePresenter.php @@ -21,7 +21,7 @@ class ResourcePresenter extends BaseResource /** * Present a view of resource objects * - * @return Response|string + * @return Response|string|void */ public function index() { @@ -33,7 +33,7 @@ public function index() * * @param string|null $id * - * @return Response|string + * @return Response|string|void */ public function show($id = null) { @@ -43,7 +43,7 @@ public function show($id = null) /** * Present a view to present a new single resource object * - * @return Response|string + * @return Response|string|void */ public function new() { @@ -54,7 +54,7 @@ public function new() * Process the creation/insertion of a new resource object. * This should be a POST. * - * @return Response|string + * @return Response|string|void */ public function create() { @@ -66,7 +66,7 @@ public function create() * * @param string|null $id * - * @return Response|string + * @return Response|string|void */ public function edit($id = null) { @@ -79,7 +79,7 @@ public function edit($id = null) * * @param string|null $id * - * @return Response|string + * @return Response|string|void */ public function update($id = null) { @@ -91,7 +91,7 @@ public function update($id = null) * * @param string|null $id * - * @return Response|string + * @return Response|string|void */ public function remove($id = null) { @@ -103,7 +103,7 @@ public function remove($id = null) * * @param string|null $id * - * @return Response|string + * @return Response|string|void */ public function delete($id = null) { From d6cd7b1b43c740cb794ed5db3ed14c777272eede Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 4 Aug 2022 17:27:53 +0900 Subject: [PATCH 3/3] docs: add int to @param $id There is no way to pass int value to the controller method now, unless extending Router. But $id may be essentially int, and we should support int. --- system/RESTful/ResourceController.php | 8 ++++---- system/RESTful/ResourcePresenter.php | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/system/RESTful/ResourceController.php b/system/RESTful/ResourceController.php index 07c4fcae760f..42bf93831e85 100644 --- a/system/RESTful/ResourceController.php +++ b/system/RESTful/ResourceController.php @@ -34,7 +34,7 @@ public function index() /** * Return the properties of a resource object * - * @param string|null $id + * @param int|string|null $id * * @return Response|string|void */ @@ -66,7 +66,7 @@ public function create() /** * Return the editable properties of a resource object * - * @param string|null $id + * @param int|string|null $id * * @return Response|string|void */ @@ -78,7 +78,7 @@ public function edit($id = null) /** * Add or update a model resource, from "posted" properties * - * @param string|null $id + * @param string|null|int$id * * @return Response|string|void */ @@ -90,7 +90,7 @@ public function update($id = null) /** * Delete the designated resource object from the model * - * @param string|null $id + * @param int|string|null $id * * @return Response|string|void */ diff --git a/system/RESTful/ResourcePresenter.php b/system/RESTful/ResourcePresenter.php index 8655c2e48487..3b832a2412be 100644 --- a/system/RESTful/ResourcePresenter.php +++ b/system/RESTful/ResourcePresenter.php @@ -31,7 +31,7 @@ public function index() /** * Present a view to present a specific resource object * - * @param string|null $id + * @param int|string|null $id * * @return Response|string|void */ @@ -64,7 +64,7 @@ public function create() /** * Present a view to edit the properties of a specific resource object * - * @param string|null $id + * @param int|string|null $id * * @return Response|string|void */ @@ -77,7 +77,7 @@ public function edit($id = null) * Process the updating, full or partial, of a specific resource object. * This should be a POST. * - * @param string|null $id + * @param int|string|null $id * * @return Response|string|void */ @@ -89,7 +89,7 @@ public function update($id = null) /** * Present a view to confirm the deletion of a specific resource object * - * @param string|null $id + * @param int|string|null $id * * @return Response|string|void */ @@ -101,7 +101,7 @@ public function remove($id = null) /** * Process the deletion of a specific resource object * - * @param string|null $id + * @param int|string|null $id * * @return Response|string|void */