Error response shouldn't use return
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 50/100
- Issue type
- Documentation
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- php
- Domain
- documentation
Research direction
Read the Wiki's “Responding With An Error” section and inspect the errorUnauthorized() behavior described in the issue. Done means the example accurately reflects that behavior and no longer introduces the reported return-type warning.
Written by the indexing model from the issue text.
Description
In Wiki: 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);
}
- Dominant language
- No language data
- Stars
- 19
- Forks
- 21
- PR merge metrics
- No merged PRs in 30d
Getting set up
We have not checked this project's setup files yet. Start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dingo/api-docs
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
Difficulty 1/5 1-3 hours Newbie friendliness 35/100
Similar issues
-
area:docs area:render bug criticality:p3 triage:needs-implementation
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
registrystack/registry-stack#1618 ·
Maintainers usually reply within 1 day
-
curriculum documentation quality
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
githubnext/gh-aw-workshop#3897 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
siderolabs/docs#791 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
nestjs/docs.nestjs.com#3554 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 98/100
huggingface/course#1320 ·
Maintainers usually reply within 1 day