PHPGenerics / php-generics-rfc

Mirror of https://wiki.php.net/rfc/generics for easier collaboration
186 stars 1 forks source link

Serialization #29

Open mindplay-dk opened 6 years ago

mindplay-dk commented 6 years ago

How would serialize() and unserialize() work in terms of serializing reified types?

orolyn commented 6 years ago

Trying out a BC format. Type arguments coming after properties.

echo serialize(new Dictionary<string, Dictionary<string, DateTime>>());

// O:10:"Dictionary":0:{}:2:{i:0;s:6:"string";i:1;O:10:"Dictionary":2:{i:0;s:6:"string";i:1;O:8:"DateTime";}}

/*
O:10:"Dictionary"
    :0:{}
    :2:{
        i:0;s:6:"string";
        i:1;O:10:"Dictionary"
            :2:{
                i:0;s:6:"string";
                i:1;O:8:"DateTime";
            }
    }
*/