> On Jul 13, 2015, at 1:56 PM, Dean Eigenmann <dean.eigenm...@icloud.com> wrote:
> 
> I have updated the RFC with a new section showing the updates
> 
> Sent from my iPhone
> 
>> On 13 Jul 2015, at 20:47, Benjamin Eberlei <kont...@beberlei.de> wrote:
>> 
>> On Mon, Jul 13, 2015 at 3:22 PM, Dean Eigenmann <dean.eigenm...@icloud.com>
>> wrote:
>> 
>>> Ive just opened a new RFC https://wiki.php.net/rfc/jsonserializable 
>>> regarding
>>> Json to Object unserialization.
>> 
>> The approach with typecasting will not work, because the function
>> json_decode doesn't have that information.
>> 
>> Instead something like the JMS Serializer api is probably necessary: $user
>> = json_decode($data, 'User');
>> 
>> I agree with Guilherme that we need a second interface for this, especially
>> because changing the existing one would be a BC break.
> 
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

What are the advantages of the proposed functionality versus writing a static 
constructor?

Writing $user = json_decode_to_class($json, User::class); doesn’t seem to offer 
anything over $user = User::fromJson($json);. In my opinion, it seems less 
obvious what is happening in the former case and the latter case requires no 
additional functions or modification to the engine.

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

Reply via email to