Sherif Ramadan wrote on 31/10/2014 14:30:
On Fri, Oct 31, 2014 at 5:25 AM, Andrea Faulds <a...@ajf.me> wrote:
This is no less of a backwards-compatibility headache. This still breaks
every PHP app I have ever written.
To be perfectly clear, the default behavior would remain the same, so no
PHP app you have ever written would break. The difference is, you would now
be able to override any part of the default behavior by extending the
HttpRequest class in your own code.
No no, I'm not concerned about the contents of the interface. I'm
wondering what, exactly, this "interface" does? I don't see how a mere
interface would replace the superglobals, unless you want a superglobal
request object that anyone can swap out, which sounds like a bad idea.
The interfaces do exactly what you see here. They specified which methods
the HttpRequest and HttpResponse objects must implement.
If you bothered to invest nearly as much time in reading the updates to the
RFC as you did to making blanket statements and objections, you might
actually find less reason to respond with objections so abruptly. The
HttpRequest and HttpResponse classes are intended to provide a central
place for message handling behaviors and their properties can be used to
describe these behaviors.
So, if you wanted to support a $_PUT superglobal, rather than adding one to
the language, you can simply add the behavior to do the processing of PUT
requests in your HttpRequest class, by extending HttpRequest and defining
how PUT variables are handled there.
I think the piece that's missing is how exactly these interfaces would
interact with core, or rather with the SAPIs which handle the actual
transfer of HTTP requests and responses.
Say I write a class "AwesomeHTTPReceive implements HttpMessageReceive",
what do I then do with this class in order for it to perform any actions?
Presumably there will need to be some mechanism where I can register
this so that it is passed the actual data from the PHP SAPI?
In order to actually replace the default behaviour, this would need to
be an ini setting, since no PHP code can run before the default
superglobal behaviour occurs. Alternatively, it could be repeatable, by
having some global function like populate_http_message_object( new
AwesomeHTTPReceive );
Similarly, there would need to be some mechanism for tying up the
response object to the HTTP response to be issued by the SAPI, with some
way for existing functions such as header() to interact with it
appropriately.
--
Rowan Collins
[IMSoP]
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php