Sherif Ramadan wrote on 31/10/2014 17:27:


On Fri, Oct 31, 2014 at 1:09 PM, Rowan Collins <rowan.coll...@gmail.com <mailto:rowan.coll...@gmail.com>> wrote:


    Let me repeat my question:

    Say I write a class "AwesomeHTTPReceive implements
    HttpMessageReceive", what do I then do with this class in order
    for it to perform any actions?

    How does PHP know that my class is the one it should populate, or
    when that population should happen?



It wouldn't. You would need to extend the base class, since it already implements the necessary interface.

If extending the base class is mandatory, then an interface should not exist. An interface's purpose is to define something's structure independent of an inheritance tree.

However, this doesn't change the question, because "AwesomeHTTPReceive extends HttpMessageReceive" still doesn't tell PHP anything about when this class will be used.

The only possibility it opens is that the base class could have a constructor (marked as final) which slurped the HTTP response out of some invisible superglobal whenever you ran "$foo = new AwesomeHTTPReceive"

PHP would simply call on the last subtype of HttpRequest during the request init phase.

It is not possible for a declarative piece of code to be discovered during the init phase without an ini setting or similar, because there is no way of knowing what files will be require()d during execution. Moreover, modern practice is to put each class in a separate file and use an autoloader, so a class is declared when it is first used.

Of course, this is an implementation detail as of now. There could certainly be other/better ways to accomplish this.

I think this detail is fundamental to how the proposal will work, and it is hard to proceed any further with the discussion without some idea of what mechanism would be used to tie the custom implementation into the engine/SAPI.

What do you propose?

Nothing, it's not my RFC, and I am trying to understand what you intended by its proposal.

--
Rowan Collins
[IMSoP]

Reply via email to