On 05/12/2020 15:08, Larry Garfield wrote:
* Are cases serializable?
`Suit::Spades === unserialize(serialize(Suit::Spades)) // true`
Right now they'd do the same as objects, so they'd serialize as an object.
Unserializing like that, though... hm, that would probably NOT still be === due
to the way PHP handles objects. That's probably undesireable, but I'm not sure
at the moment the best way around that. I'll have to discuss with Iliya.
I guess what it comes down to is whether / how easily a class can return
an existing instance when asked to unserialize, rather than setting
properties on an existing instance. That is, given the string
"C:4:Suit:6:{Spades}" can the class definition return the appropriate
singleton for Suits::Spades rather than a newly constructed object?
If this proves tricky to implement, it would probably be better to
forbid serialization than using the default object format and breaking
the singleton-ness of the case objects.
Regards,
--
Rowan Tommins (né Collins)
[IMSoP]
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php