8000 [3.0] [HttpFoundation] clean up/redesign Request class · Issue #6406 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
[3.0] [HttpFoundation] clean up/redesign Request class #6406
Closed
@Tobion

Description

@Tobion

There are several inconsistent method names and I think the class can be better designed.

  • Synchronization of setters, getters, and parameter bags (server etc.) is unclear and inconsistent. For example there is a setMethod method which also modifies the ServerBag but there is no setPath. So either a Request should be immutable or mutable. But we have a mix of it. Furthermore, some getters a cached like getPathInfo and some are not like getHost. So when modifying the public parameter bags, sometimes it has influence on the Request getters and sometimes not. See also [HttpFoundation] Request::getPathInfo() inconsistencies #10478
  • getUriForPath is wrong. The correct name according to the current behavior would be getUriForPathInfo
  • the names for getBaseUrl and getBasePath are both unfortunate because the only difference is the inclusion of the script file name and has nothing to do with URL vs path.

The method name for Request::getPathInfo() is so bad because

  1. it returns the path of a URI and not a "path info" (there is no such thing in the URI spec)
  2. it suggest to return "more info" in form of an array like the php function pathinfo does, but it only returns the plain path
    So the name is really confusing as it does not behave similar to phps pathinfo() and is also semantically wrong.
    I suggest to deprecate getPathInfo() and introduce getPath().
    Working with it bothered me ever since. And I think we should fix that now before it's too late.

Changing some names like baseUrl (that also does not exist in CGI terms) will need to be reflected in the routing component as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureHttpFoundationRFCRFC = 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

      0