2013/9/23 Joe Watkins <krak...@php.net>

> On 09/23/2013 07:39 AM, Joe Watkins wrote:
>
>> Morning All,
>>
>>      
>> https://wiki.php.net/rfc/**anonymous_classes<https://wiki.php.net/rfc/anonymous_classes>
>>
>>      I'd like to hear thoughts regarding the addition of anonymous
>> classes, patch included.
>>
>> Cheers
>> Joe
>>
>
> Serialization:
>
>   As I have said, serialization does work, and unserialization does work
> ...
>

Actually if you cant unserialize a "serialized object", it isn't a
serialized object, but only a string describing the object it was created
from.


>
>   Classes do have unique names, so as long as the entry is present upon
> unserialize you will get the object you expect ... if the entry is not
> present unserialization will fail silently.
>

Which name do you give them? The name of the originating interface/class?

if ($debug) {
    $listener = new class extends ListenerInterface () {
        public function onFoo() { debug(); };
    };
} else {
    $listener = new class extends ListenerInterface () {
        public function onFoo() { normal(); };
    };
}

$someBar->addListener($listener);
$x = serialize($listener);



>
>   The same kind of thing can happen where you have declared a class based
> on some predicate, whose value has changed upon unserialize and so the
> entry is not present ...


>   I'm not sure it is necessary to force any particular behaviour for
> serialization, it depends entirely on the application whether or not the
> entry is present upon serialization, it should be left down to the
> programmer.


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


-- 
github.com/KingCrunch

Reply via email to