Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[RFC] AbstractController::noContent(): Response #49751

Closed as not planned
Closed as not planned
@ro0NL

Description

@ro0NL

Description

Hi,

in #49518 i realized we have 2 ways of handling null as a controller result

  1. json encode as null + http 200
  2. no content + http 204

i figured having a controller utility builtin creates better autocompletion due the use of $this->... already

considering #49518, this allows doing:

#[Serialize(201)]
endpoint(): mixed {
    if ($someSpecialCase) {
        return $this->noContent(); // 204
    }

    return $someOtherSpecialCase ? ['data' => true] : null; // 201
}

Example

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrameworkBundleRFCRFC = Request For Comments (proposals about features that you want to be discussed)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions