kiota icon indicating copy to clipboard operation
kiota copied to clipboard

PHP enum normalization can emit duplicate class constants

Open Shubham-Padkonde opened this issue 2 months ago • 0 comments

Generating PHP for two distinct enum values, "chat.conversation.join" and "chat.conversation_join", emits the same CHAT_CONVERSATION_JOIN constant twice. PHP then fails to load the enum with "Cannot redefine class constant". This occurs in the Twitter schema's CreateActivitySubscriptionRequest_event_type and can be reproduced with a single string enum property.

A third value "chat.conversation_join_2" already maps to CHAT_CONVERSATION_JOIN_2, so simply appending _2 to the duplicate would create another collision.

I have a tested fix that reserves all original normalized constant names, keeps the first occurrence unchanged, and chooses an unused numeric suffix for later collisions. Wire values and constructor defaults remain unchanged. The minimal generated enum passes PHP syntax validation, and each value parses and serializes correctly with the Kiota PHP runtime. All 136 PHP-focused generator tests pass.

Found during follow-up validation of #7997; independent of the binary factory changes in #8248. Prepared with Codex assistance.

Shubham-Padkonde avatar Sep 21 '26 12:09 Shubham-Padkonde