Skip to content

feat(enum): add basic enum support #489

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

Merged
merged 10 commits into from
Jul 20, 2025
Merged

feat(enum): add basic enum support #489

merged 10 commits into from
Jul 20, 2025

Conversation

Xenira
Copy link
Collaborator

@Xenira Xenira commented Jul 6, 2025

Fixes: #178
Refs: #302

Description

PHP 8.1 introduced enums. This is a migration of #302 to the new macro system.

MR is currently incomplete, but the basic case already works.

I feature guarded this behind the enum feature. As I added this to the default features this is a soft bump of the minimum supported PHP version. Setting default-features to false will still allow 8.0 though.

Progress

  • Register unit enums
  • Register backed enums
  • Enums as return types (IntoZval)
  • Enums as parameters (FromZval)
  • TryFrom for backed enums
  • Stubs
  • Tests
  • Documentation

Checklist

Check the boxes that apply (put an x in the brackets, like [x]). You can also check boxes after the PR is created.

❤️ Thank you for your contribution!

@coveralls
Copy link

coveralls commented Jul 6, 2025

Pull Request Test Coverage Report for Build 16401140698

Details

  • 118 of 288 (40.97%) changed or added relevant lines in 7 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+1.2%) to 26.945%

Changes Missing Coverage Covered Lines Changed/Added Lines %
crates/macros/src/lib.rs 2 5 40.0%
src/describe/mod.rs 1 8 12.5%
src/builders/module.rs 0 17 0.0%
src/describe/stub.rs 0 19 0.0%
src/enum_.rs 9 29 31.03%
src/builders/enum_builder.rs 14 47 29.79%
crates/macros/src/enum_.rs 92 163 56.44%
Files with Coverage Reduction New Missed Lines %
src/builders/module.rs 1 40.0%
Totals Coverage Status
Change from base Build 16394070386: 1.2%
Covered Lines: 1115
Relevant Lines: 4138

💛 - Coveralls

@Xenira Xenira force-pushed the enum-support branch 11 times, most recently from c5da1a9 to b66f21d Compare July 9, 2025 17:15
@Xenira
Copy link
Collaborator Author

Xenira commented Jul 9, 2025

@ptondereau thoughts?

Want to finalise the api before tackling the test.

@Xenira Xenira requested a review from ptondereau July 9, 2025 19:14
@Xenira Xenira mentioned this pull request Jul 19, 2025
1 task
@Xenira Xenira mentioned this pull request Jul 19, 2025
1 task
@Xenira Xenira force-pushed the enum-support branch 4 times, most recently from 95c6282 to efcf063 Compare July 20, 2025 10:36
@Xenira Xenira marked this pull request as ready for review July 20, 2025 10:40
Copy link
Collaborator

@ptondereau ptondereau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good feature! Thanks for the implementation.
Leaved some nitpicks.

@Xenira Xenira merged commit 25f508f into master Jul 20, 2025
116 checks passed
@Xenira Xenira deleted the enum-support branch July 20, 2025 15:49
@joehoyle
Copy link
Collaborator

Great stuff thanks @Xenira

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.

Php enums
4 participants