Skip to content

Commit 80379f8

Browse files
committed
phpdoc and typehint cleanups
1 parent c91a1a9 commit 80379f8

2 files changed

Lines changed: 9 additions & 13 deletions

File tree

src/Jarischaefer/HalApi/Controllers/HalApiResourceController.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ abstract class HalApiResourceController extends HalApiController implements HalA
4141
/**
4242
* The model's transformer.
4343
*
44-
* @var HalApiTransformer
44+
* @var HalApiTransformerContract
4545
*/
4646
protected $transformer;
4747
/**
@@ -69,10 +69,10 @@ abstract class HalApiResourceController extends HalApiController implements HalA
6969

7070
/**
7171
* @param HalApiControllerParameters $parameters
72-
* @param HalApiTransformer $transformer
72+
* @param HalApiTransformerContract $transformer
7373
* @param Builder $schemaBuilder
7474
*/
75-
public function __construct(HalApiControllerParameters $parameters, HalApiTransformer $transformer, Builder $schemaBuilder)
75+
public function __construct(HalApiControllerParameters $parameters, HalApiTransformerContract $transformer, Builder $schemaBuilder)
7676
{
7777
parent::__construct($parameters);
7878

@@ -84,10 +84,6 @@ public function __construct(HalApiControllerParameters $parameters, HalApiTransf
8484
$this->schemaBuilder = $schemaBuilder;
8585
$this->model = static::getModel();
8686

87-
if (!is_subclass_of($this->transformer, HalApiTransformerContract::class)) {
88-
throw new RuntimeException('Transformer must be child of ' . HalApiTransformerContract::class);
89-
}
90-
9187
if (!is_subclass_of($this->model, Model::class)) {
9288
throw new RuntimeException('Model must be child of ' . Model::class);
9389
}

src/Jarischaefer/HalApi/Controllers/HalApiResourceControllerContract.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22

33
use Exception;
44
use Illuminate\Database\Eloquent\Model;
5-
use Illuminate\Http\Request;
65
use Jarischaefer\HalApi\Exceptions\BadPostRequestException;
76
use Jarischaefer\HalApi\Exceptions\BadPutRequestException;
87
use Jarischaefer\HalApi\Exceptions\DatabaseConflictException;
98
use Jarischaefer\HalApi\Exceptions\DatabaseSaveException;
10-
use Jarischaefer\HalApi\Transformers\HalApiTransformer;
9+
use Jarischaefer\HalApi\Transformers\HalApiTransformerContract;
1110
use Symfony\Component\HttpFoundation\Response;
1211

1312
/**
@@ -39,11 +38,12 @@ public static function getModel();
3938
* exception.
4039
*
4140
* If you do not typehint your method (take a look at the update method in this class), the variable passed
42-
* will be null. Otherwise an instance of your model with the ->exists property set to false is passed.
41+
* will be the original route parameter.
42+
* Otherwise, an instance of your model with the ->exists property set to false is passed.
4343
*
44-
* public function update($user = null)
44+
* public function update($user)
4545
* {
46-
* var_dump($user) // null if not found in database
46+
* var_dump($user) // original route parameter (e.g. new resource's ID) if not found in database
4747
* }
4848
*
4949
* public function update(User $user)
@@ -61,7 +61,7 @@ public static function getModelBindingCallback();
6161
/**
6262
* Returns an instance of a transformer to be used for all transformations in this controller.
6363
*
64-
* @return HalApiTransformer
64+
* @return HalApiTransformerContract
6565
*/
6666
public function getTransformer();
6767

0 commit comments

Comments
 (0)