class EnumCaseSerializationTest extends TestCase (View source)

Enum-case values captured from reflection must not travel as live enum instances.

The reflection pipeline serializes in the container for the version being reflected and unserializes in test_runner. A live enum instance only survives if the declaring class exists on both sides, and unlike ordinary objects an enum cannot degrade to __PHP_Incomplete_Class — so an unresolvable one aborts the entire payload, not just that value.

makeSerializable() had a branch meant to handle this, but it tested method_exists($value, 'name'); name is a property on an enum case, not a method, so the branch never fired and enums fell through to a bare class-name fallback that lost the case entirely.

Methods

testReferenceSurvivesTheSerializationHop()

The whole point: the converted value must survive a serialize/unserialize hop.

testLiveEnumUsesTheFragileSerializationFormat()

A live enum instance uses PHP's E: serialization format, which hard-fails when the class is absent. This documents the hazard the reference avoids — it is why an unresolvable enum takes the entire payload down rather than degrading.

testReferenceRendersIdenticallyToALiveEnum()

The reference must render exactly as a live instance did, so caches generated before and after this change are byte-identical. Verified end-to-end against Reflection8.6.json as well.

testEnumFqnIsNormalised()

A leading backslash is normalised away, matching get_class() of a real case.

testOrdinaryValuesAreUnaffected()

Non-enum values must be untouched by the new branch.

Details

testPureEnumCaseBecomesAPortableReference()

No description

testBackedEnumCaseIsAlsoConverted()

No description

testReferenceSurvivesTheSerializationHop()

The whole point: the converted value must survive a serialize/unserialize hop.

testLiveEnumUsesTheFragileSerializationFormat()

A live enum instance uses PHP's E: serialization format, which hard-fails when the class is absent. This documents the hazard the reference avoids — it is why an unresolvable enum takes the entire payload down rather than degrading.

testReferenceRendersIdenticallyToALiveEnum()

The reference must render exactly as a live instance did, so caches generated before and after this change are byte-identical. Verified end-to-end against Reflection8.6.json as well.

testEnumFqnIsNormalised()

A leading backslash is normalised away, matching get_class() of a real case.

testOrdinaryValuesAreUnaffected()

Non-enum values must be untouched by the new branch.