chargebee-php icon indicating copy to clipboard operation
chargebee-php copied to clipboard

No Enums in Resource sub-types ?

Open ychedemois opened this issue 5 months ago • 2 comments

What problem does your feature request address?

It seems a couple properties (mostly in sub-entities ?) were not converted to Enums : $subscrption->contract_term->action_at_term_end $subscrption->subscription_items[N]->item_type $subscrption->subscription_items[N]->billing_period_unit $invoice->line_items[N]->entity_type $invoice->linked_payments[N]->status

I didn't check all other sub-types in detail, but it seems only Resources 1st level properties have been converted to Enums

That's a bit unfortunate, but I'm not sure of the best approach about this, though, since converting them to Enum now would be a BC break 🤔

Describe the desired solution

No response

Alternatives considered

No response

Additional context

No response

ychedemois avatar Jul 21 '25 15:07 ychedemois

Example of confusing code : $event->webhook_status is a Chargebee\Resources\Event\Enums\WebhookStatus $event->webhooks[N]->webhook_status is a string

ychedemois avatar Jul 21 '25 15:07 ychedemois

@cb-alish I see that release 4.8.0 intends to adress this 👍🙏

I'm not sure I understand why using class-based enums instead of regular enums would be less of a BC-break though ? Even if an object has a __toString() method, it will not be seen as strictly equal (===) to the string value, and I would think the large majority of code uses strict comparison these days.

So if you're going for a BC break anyway, maybe going with regular enums would be more consistent ?

ychedemois avatar Aug 04 '25 10:08 ychedemois