On Tue, Feb 24, 2015 at 1:37 PM, S.A.N <ua.san.a...@gmail.com> wrote:
> Would have been more useful, inline sintex like JSON:
>
> $object =
> {
>     'property': $value,
>     'method':  function (){...}
> };
>
> $object->property;
> $object->method();

I know what you're saying here, and object literals like this would be
rather interesting someday. They are, however, quite different to the
concept of anonymous classes.

JSON syntax would make it very hard for the usual PHP functionality to
be used. Properties and methods look the same, visibility scopes
cannot be used, implementing interfaces becomes impossible, traits
dont have a home, etc. By the time you have catered to all of that you
have something very different to JSON, and very different to PHP.

Or, you have the syntax being proposed here, which is identical to
existing declared class syntax other than there being no name.

Another RFC to replace $foo = (object) [ 'foo' => 'bar' ]; someday
would be nice, but that is not what this is up to.

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

Reply via email to