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 exporting Enums when using PHP8.1+ #23

Merged
merged 1 commit into from
Jun 15, 2022
Merged

Add support for exporting Enums when using PHP8.1+ #23

merged 1 commit into from
Jun 15, 2022

Conversation

Jacobs63
Copy link

This enables support for exporting Enums when using PHP8.1+

Enums are considered objects which cannot be instantiated, this caused a fatal error when using the var exporter:

      Error::("Cannot instantiate enum XY")

This pull requests enables support for exporting Enums, disabling exporting of Enums & keeps support for previous PHP versions without breaking changes.

@BenMorel
Copy link
Member

Hi, thank you for your PR! Can you please add a test?

@Jacobs63
Copy link
Author

Hi, thank you for your PR! Can you please add a test?

Working on it, however, since Enums are not supported on PHP < 8.1.0 I'm sort of struggling on what to assert on the test, as trying to get a reflection of the Enum itself throws a syntax error, since the enum keyword is unrecognized.
Any tips?

@Jacobs63
Copy link
Author

I have added the Enum test on PHP 8.1+ and currently skipped the test on lower versions, as instantiating the test itself throws an exception due to invalid keyword.

@BenMorel BenMorel merged commit d1c6b6e into brick:master Jun 15, 2022
@BenMorel
Copy link
Member

Thank you, @Jacobs63! I fixed Psalm issues and squashed your commits.

@BenMorel
Copy link
Member

Released as 0.3.6.

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.

2 participants