On Tue, Feb 24, 2015 at 9:34 AM, Dmitry Stogov <dmi...@zend.com> wrote:
>
>
> On Tue, Feb 24, 2015 at 5:19 PM, Philip Sturgeon <pjsturg...@gmail.com>
> wrote:
>>
>> On Tue, Feb 24, 2015 at 9:10 AM, Dmitry Stogov <dmi...@zend.com> wrote:
>> > I think the proposal is a bit incomplete.
>> > It's possible to instantiate an anonymous class, but currently it's not
>> > possible to do with them anything else (assign to variable, pass to
>> > function, etc). Something similar to Closure objects should be
>> > introduced.
>> >
>> > Thanks. Dmitry.
>>
>> 1. You can absolutely assign the instantiated classes to variables.
>>
>> Check out this test in the patch:
>>
>> https://github.com/krakjoe/php-src/compare/anon#diff-25e330fb5a98810de178a5b798102d01R1
>>
>
> In tests you assign instantiated objects.
>
> $a = new class {...};
> $b = new class {...};
>
> I'm talking about classes as first class objects.
>
> $c = class {...};
> $a = new $c;
> $b = new $c;
>
>
>>
>> 2. Why do you say they cannot be passed to a function? I can add a
>> test if you can give me an example of what you're suggesting doesn't
>> work.
>>
>> 3. Not sure why we'd need a Closure-alike object. Anonymous classes
>> are just a class, and classes have all the types and hinting
>> functionality of regular classes. You don't need to implement a class
>> to let people know its a class.
>>
>> Maybe you could expand on that a bit? :)
>
>
> I tried it in the example above.
>
> Also, classes may be useful without objects at all (just static properties
> and methods).
>
> $c = class {...};
> $c::static_foo();
>
> Thanks. Dmitry.

Thank you for the example! Your example explains my question 1, but
doesn't seem to explain 2 or 3.

I'll play around with static usage and show it off in the tests.

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

Reply via email to