Hi On 3/18/26 19:38, Levi Morrison wrote:
Tim, I am curious if adding a backing value in a future release would be considered a breaking change or not, something like:enum SortDirection { case Ascending = 1; case Descending = -1; } The exact values don't matter for my question, only whether or not it would be considered a backwards compatibility break.
That's complicated to answer. From a LSP POV changing a UnitEnum to a BackedEnum is just “adding new things” (and indeed the BackendEnum interface extends UnitEnum), which is safe from a backwards compatibility PoV. However I've seen folks doing `instanceof` checks in the folks to decide whether to use the ->name or ->value for serialization. Changing from UnitEnum to BackedEnum would introduce a behavioral change there.
All that said, I believe making an enum backed is almost always a mistake, since there is rarely a single obvious "blessed" scalar representation of an enum value, doubly so for the featured enum of this RFC, as explained by the RFC. See also the first paragraph of this email from me in another discussion thread: https://news-web.php.net/php.internals/129408
Best regards Tim Düsterhus
