Re: Re: HTTP supergloblas and request body/query (was: Parsing PUT data)
| From: | Florian Anderiasch | Date: | Wed, 02 Oct 2013 15:47:18 +0000 |
| Subject: | Re: Re: HTTP supergloblas and request body/query (was: Parsing PUT data) | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-69456@lists.php.net to get a copy of this message | ||
On 02.10.2013 17:29, Daniel Lowrey wrote:
> The superglobals are a hopelessly poor abstraction. Can we stop trying to
> put the proverbial gold ring in the pig's snout on this?
>
> [...]
>
> Something like the following would be an infinitely superior solution:
>
> interface HttpRequest {
> function getMethod();
> [...]
> }
>
> By adding a global function such as
get_request() that returns
> the
> immutable request object you get all the functionality you could want:
>
> 1. Entity body parsing (for cookies or form data) could be done JIT
> 2. Userland code can easily typehint against the request
> 3. No more mutability, eminently testable
> 4. Eliminates the need for $_GET,
> $_POST, $_COOKIE, etc ...
>
> This is simply an example of a much better way to model HTTP requests --
> it's not a suggestion for a final implementation. But IMO if we're going to
> fix this then we should really fix it and not continuously tickle the same
> broken abstraction.
While I totally agree with your point, I don't see why this needs to be
in core. This is perfectly done in userspace, even the immutable part.
The only benefit of putting that in core would be the standard-defining
part, but not much else. Plus it's not minimizing any abuse, as long as
the superglobals are still available (and I don't think renaming or
removing them would be a good idea.
Greetings,
Florian