Re: Let's discuss enums!

From: Date: Fri, 18 Sep 2015 00:05:48 +0000
Subject: Re: Let's discuss enums!
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-88300@lists.php.net to get a copy of this message
On 18/09/2015 00:34, user@domain.invalid wrote:
Well, how are you supposed to serialize an enum value without some sort of numerical representation or value? Maybe you could serialize it by converting the enum to a string representation of its name but that wouldn't be efficient and also if a developer refactored its code base and renamed an enum, when unserializing the data it wouldn't be properly assigned.
I don't think serializing to a name is particularly more inefficient than serializing to an integer - depending on the internal implementation, of course. Or do you mean efficiency in terms of the length of the string produced? Nor do I see it as particularly likely that somebody will rename an enum member - that would instantly break all code referring to it anyway. They could however change the order of fields without realising that it would make any difference, since most access would be of the form TypeName::ValueName. Regards, -- Rowan Collins [IMSoP]

« previous php.internals (#88300) next »