PHP backed enum → Edm.EnumType
Note: this release is additive for primitive-only consumers and surfaces a new opt-in feature for backed-enum columns. It ships as a patch alongside v1.0.2/v1.0.3 because all three current consumers (
laravelui5/core,laravelui5/sdk,pragmatiqu/timesheet.biz) are in-house. SemVer credit is spent here deliberately; the next release that crosses the public funnel boundary should bump the major.
Added
- PHP backed enum →
Edm.EnumTypebridge. Declare a column as a PHP int-backed enum class-string and the engine reflects it into an<EnumType>element in$metadataand emits the symbolic member name on the wire ("tier":"Single").
public function columns(): array
{
return [
'id' => EdmPrimitiveType::Int64,
'tier' => LicenseTier::class, // ← new
];
}Implementation lives across EnumType::fromBackedEnum(), AbstractEntitySet::entityType(), EdmBuilder::addEntityType() (now auto-registers enum types it discovers), EdmBuilder::addEnumType() (now idempotent on identical re-registration, throws on same-qualified-name collisions with different definitions), and Protocol\Execution\RowCoercion (per-property value→name lookup, unknown ints fall through unchanged).
Changed
EdmBuilder::addEntityType()now walks declared properties to auto-register anyEnumTypeInterfaceit finds on the schema. Consumers never touchaddEnumType()directly. Latent inconsistencies (manually pre-registered enum + entity-type-carried enum with diverging definitions) now throw\LogicExceptionat build time.
Migration
No code changes required — composer update picks up the bridge.
EdmPrimitiveType column declarations continue to work exactly as before.
To adopt for an enum-typed column: swap 'tier' => EdmPrimitiveType::Int64 for 'tier' => LicenseTier::class, then drop any UI5 formatter that was reconstructing the label client-side. The new wire payload is what sap.ui.model.odata.type.Enum parses by default.
Out of scope (deferred)
String-backed enums, IsFlags, complex types, POST/PATCH deserialization ("Single" → 1). Open them as new atoms when a consumer asks.