Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Error response shouldn't use return

Open
#26 0 comments 0 reactions 0 assignees View on GitHub

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dingo/api-docs

All issues in dingo/api-docs

Similar issues

More Documentation issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.