Re: [RFC] Anonymous Classes

From: Date: Sat, 07 Mar 2015 02:14:18 +0000
Subject: Re: [RFC] Anonymous Classes
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-84394@lists.php.net to get a copy of this message
Hi all, On Wed, Feb 25, 2015 at 4:06 AM, S.A.N <ua.san.alex@gmail.com> wrote: > Yes, is problem - properties and methods look the same, how to solve > this problem in PHP I do not know. > Perhaps PHP could interpret this code: > $object = > { > 'property' => $value, > 'method' => function (){...} > }; > > AS > > $object = new class > { > public $property = $value; > public function method (){...} > } > > Use case - inline object without inheritance and traits, only the > properties and methods it brief and easily understood JSON syntax, I > think it would be popular with developers of PHP. > It's not directly related to the topic, but I would like to have "code block" that returns "value" with this syntax rather than defining anonymous class/object. BTW, I'm +1 for the idea having anonymous class. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net

« previous php.internals (#84394) next »