Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Enums #302

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Add support for Enums #302

wants to merge 1 commit into from

Conversation

joehoyle
Copy link
Collaborator

@joehoyle joehoyle commented Dec 5, 2023

This adds an EnumBuilder to create PHP enums, and a #[php_enum] macro which you can attach to Rust enums.

Only symbolic enums are supported from Rust. PHP doesn't support enums that hold data. They do support scalar backend-enums, however Rust does not support that. So, the #[php_enum] can only be used for non-backed enums. You can implement backed enums via the EnumBuilder in cses where you'd want to implement your own IntoZval / FromZval for your name and do something custom with the backed value.

We could potentially add attributes to the enum for their string / int scale values in PHP though.

I've added cfg php8.1 to this, as enums are only supported in PHP >= 8.1. I think it's better to conintue supporting PHP 8.0 for the time being, and just have the enums only be available in >= php 8.1.

This adds an EnumBuilder to create PHP enums, and a `#[php_enum]` macro which you can attach to Rust enums.

Only symbolic enums are supported from Rust. PHP doesn't support enums that hold data. They do support scalar backend-enums, however Rust does not support that. So, the `#[php_enum]` can only be used for non-backed enums. You can implement backed enums via the EnumBuilder in cses where you'd want to implement your own IntoZval / FromZval for your name and do something custom with the backed value.

We could potentially add attributes to the enum for their string / int scale values in PHP though.

I've added cfg php8.1 to this, as enums are only supported in PHP >= 8.1. I think it's better to conintue supporting PHP 8.0 for the time being, and just have the enums only be available in >= php 8.1.
@joehoyle joehoyle marked this pull request as draft December 5, 2023 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant