Re: RFC: Anonymous Classes

From: Date: Thu, 26 Sep 2013 09:28:53 +0000
Subject: Re: RFC: Anonymous Classes
References: 1 2 3 4 5 6 7 8 9 10 11 12 13  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
I think what Terence was talking about is more like this:

class A
{
}

class AProxifier
{
    protected function protectedMethod() {...}

    function getAProxy()
    {
        return new class extends A { /* How do you call
AProxifier->protectedMethod() here? */ };
    }
}

This is possible with anonymous functions, that's a big feature of PHP5.4.
And for the same reasons might be expected here too?
I don't have the answer, just raising the point.


(new class ...
>>      protected $value;
>>      public function __construct($value)
>>      {
>>          $this->value = $value;
>>      }
>>
>>      public function doSomething()
>>      {
>>          echo $this->value;
>>      })($val)
>>
>

Btw, I can't get used to ($val) beeing at the end of the declaration. I
feel it very confusing.

Nicolas


Thread (55 messages)

« previous php.internals (#69344) next »