On 23 September 2013 10:39, Rasmus Lerdorf <ras...@lerdorf.com> wrote:
> On 09/22/2013 11:39 PM, Joe Watkins wrote:
>>     https://wiki.php.net/rfc/anonymous_classes
>>
>>     I'd like to hear thoughts regarding the addition of anonymous
>> classes, patch included.
>
> I am having a hard time picturing a real-world use-case for this.

It is a widely used pattern in object oriented programming:

$subject->attach(new class implements SplObserver {
  function update(SplSubject $s) {
    printf("Got update from: %s\n" $subject);
  }
);


I'd rather go for a `new BaseType` syntax, though:

$subject->attach(new SplObserver() {
  function update(SplSubject $s) {
    printf("Got update from: %s\n" $subject);
  }
);



-- 
Regards,
Mike

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to