Skip to content

Commit c0b9928

Browse files
authored
Merge pull request #6311 from kenjis/fix-type-RESTful-controllers
docs: fix types in PHPDocs in RESTful controllers
2 parents 237e5da + d6cd7b1 commit c0b9928

File tree

2 files changed

+29
-24
lines changed

2 files changed

+29
-24
lines changed

system/RESTful/ResourceController.php

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace CodeIgniter\RESTful;
1313

1414
use CodeIgniter\API\ResponseTrait;
15+
use CodeIgniter\HTTP\Response;
1516

1617
/**
1718
* An extendable controller to provide a RESTful API for a resource.
@@ -23,7 +24,7 @@ class ResourceController extends BaseResource
2324
/**
2425
* Return an array of resource objects, themselves in array format
2526
*
26-
* @return mixed
27+
* @return Response|string|void
2728
*/
2829
public function index()
2930
{
@@ -33,9 +34,9 @@ public function index()
3334
/**
3435
* Return the properties of a resource object
3536
*
36-
* @param mixed $id
37+
* @param int|string|null $id
3738
*
38-
* @return mixed
39+
* @return Response|string|void
3940
*/
4041
public function show($id = null)
4142
{
@@ -45,7 +46,7 @@ public function show($id = null)
4546
/**
4647
* Return a new resource object, with default properties
4748
*
48-
* @return mixed
49+
* @return Response|string|void
4950
*/
5051
public function new()
5152
{
@@ -55,7 +56,7 @@ public function new()
5556
/**
5657
* Create a new resource object, from "posted" parameters
5758
*
58-
* @return mixed
59+
* @return Response|string|void
5960
*/
6061
public function create()
6162
{
@@ -65,9 +66,9 @@ public function create()
6566
/**
6667
* Return the editable properties of a resource object
6768
*
68-
* @param mixed $id
69+
* @param int|string|null $id
6970
*
70-
* @return mixed
71+
* @return Response|string|void
7172
*/
7273
public function edit($id = null)
7374
{
@@ -77,9 +78,9 @@ public function edit($id = null)
7778
/**
7879
* Add or update a model resource, from "posted" properties
7980
*
80-
* @param mixed $id
81+
* @param string|null|int$id
8182
*
82-
* @return mixed
83+
* @return Response|string|void
8384
*/
8485
public function update($id = null)
8586
{
@@ -89,9 +90,9 @@ public function update($id = null)
8990
/**
9091
* Delete the designated resource object from the model
9192
*
92-
* @param mixed $id
93+
* @param int|string|null $id
9394
*
94-
* @return mixed
95+
* @return Response|string|void
9596
*/
9697
public function delete($id = null)
9798
{
@@ -100,6 +101,8 @@ public function delete($id = null)
100101

101102
/**
102103
* Set/change the expected response representation for returned objects
104+
*
105+
* @return void
103106
*/
104107
public function setFormat(string $format = 'json')
105108
{

system/RESTful/ResourcePresenter.php

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace CodeIgniter\RESTful;
1313

14+
use CodeIgniter\HTTP\Response;
15+
1416
/**
1517
* An extendable controller to help provide a UI for a resource.
1618
*/
@@ -19,7 +21,7 @@ class ResourcePresenter extends BaseResource
1921
/**
2022
* Present a view of resource objects
2123
*
22-
* @return mixed
24+
* @return Response|string|void
2325
*/
2426
public function index()
2527
{
@@ -29,9 +31,9 @@ public function index()
2931
/**
3032
* Present a view to present a specific resource object
3133
*
32-
* @param mixed $id
34+
* @param int|string|null $id
3335
*
34-
* @return mixed
36+
* @return Response|string|void
3537
*/
3638
public function show($id = null)
3739
{
@@ -41,7 +43,7 @@ public function show($id = null)
4143
/**
4244
* Present a view to present a new single resource object
4345
*
44-
* @return mixed
46+
* @return Response|string|void
4547
*/
4648
public function new()
4749
{
@@ -52,7 +54,7 @@ public function new()
5254
* Process the creation/insertion of a new resource object.
5355
* This should be a POST.
5456
*
55-
* @return mixed
57+
* @return Response|string|void
5658
*/
5759
public function create()
5860
{
@@ -62,9 +64,9 @@ public function create()
6264
/**
6365
* Present a view to edit the properties of a specific resource object
6466
*
65-
* @param mixed $id
67+
* @param int|string|null $id
6668
*
67-
* @return mixed
69+
* @return Response|string|void
6870
*/
6971
public function edit($id = null)
7072
{
@@ -75,9 +77,9 @@ public function edit($id = null)
7577
* Process the updating, full or partial, of a specific resource object.
7678
* This should be a POST.
7779
*
78-
* @param mixed $id
80+
* @param int|string|null $id
7981
*
80-
* @return mixed
82+
* @return Response|string|void
8183
*/
8284
public function update($id = null)
8385
{
@@ -87,9 +89,9 @@ public function update($id = null)
8789
/**
8890
* Present a view to confirm the deletion of a specific resource object
8991
*
90-
* @param mixed $id
92+
* @param int|string|null $id
9193
*
92-
* @return mixed
94+
* @return Response|string|void
9395
*/
9496
public function remove($id = null)
9597
{
@@ -99,9 +101,9 @@ public function remove($id = null)
99101
/**
100102
* Process the deletion of a specific resource object
101103
*
102-
* @param mixed $id
104+
* @param int|string|null $id
103105
*
104-
* @return mixed
106+
* @return Response|string|void
105107
*/
106108
public function delete($id = null)
107109
{

0 commit comments

Comments
 (0)