Error response shouldn't use return
- Dominant language
- No language data
- Stars
- 19
- Forks
- 21
- PR merge metrics
- No merged PRs in 30d
Description
In [Wiki: Responding With An Error](https://github.com/dingo/api/wiki/Responses#responding-with-an-error) it states:
```
return $this->response->errorUnauthorized();
```
However, all the method does is throws an error. The method itself has no return statement. Isn't the `return` redundant?
Consider the following controller method as example. If a return is added to the errorResponse, it does nothing except adds a warning to the IDE because there's a conflict between `return void` and the declared return type. (Adding `|void` to `@return` causes a warning too.)
```
/**
* Display the specified resource.
*
* @param \App\Letter $letter
* @return \Dingo\Api\Http\Response
*/
public function show(Letter $letter)
{
/** @var User $user */
$user = $this->auth->user();
if( $user->cannot('view', $letter) ) {
$this->response->errorUnauthorized();
}
return $this->response->item($letter, new LetterTransformer);
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.