2013/9/23 Rasmus Lerdorf <ras...@lerdorf.com>

> 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.
>

The use case is one-time usage of an "implementation", where you currently
probably pass callbacks into a "Callback*"-class like

    $x = new CallbackFoo(function() {
        /* do something */
    });

vs.

    $x = new Foo () {
        public function doSometing()
        {
            /* do something */
        }
    });

Imagine you have several abstract methods in one interface/class, which
would need several callbacks passed to the constructor.
Also '$this' is mapped to the right objects.

Regards,
Sebastian


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


-- 
github.com/KingCrunch

Reply via email to