-
-
Notifications
You must be signed in to change notification settings - Fork 83
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 initial use cases for Enum generation #109
Add initial use cases for Enum generation #109
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bulk of the static analysis errors are due to the engine needing to infer types, and not being able to do so. The way to correct that is to verify them before doing an operation. For values in arrays, check that the array key exists, and then that the value conforms to what is required, before performing an operation. In other cases, just make sure that the typehints provided are correct, particularly in annotations. If needed, uses webmozart/assert to do the validations.
Thanks @weierophinney for the initial review. I'll keep your feedback in account as I work further in the PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few minor suggestions, mainly for readability. After making them, I think you can go ahead and remove the draft status, and @Ocramius can do final review.
@weierophinney Thank you for the suggestions. I marked the PR as ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting close now! Thanks for all the work you're doing on this!
Supports generating Enums that are pure or have backed values. Signed-off-by: Agustin Gomes <me@agustingomes.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Will wait for @Ocramius to do final review, however.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall excellent:
- the fact that implementations are
@internal
gives us space to improve later - everything else is simple and to the point
I'll proceed to merge, and will factor in the last comments by @michaelpetri ( #109 (review) )
Ref: #109 (review) In this change: * we remove the `polyfill/test` directory: we will use `<<<'PHP'` blocks directly in the test sources, in order to generate the classes that we need to verify enumerable type code generation * we replace `PHP_VERSION_ID`-based checks with PHPUnit's built-in `@requires PHP > 8.1` and similar * fixed some docblocks in tests * re-generated psalm baseline to reflect the fact that multiple issues were solved
🚢 Thanks @agustingomes @michaelpetri @weierophinney! Gonna cut a release after dependency upgrades |
Description
This PR Enables the creation of Enum objects for the following use cases:
Fixes #100