-
Notifications
You must be signed in to change notification settings - Fork 187
Fix failing enum mapping for backed PHP enums #249
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
base: master
Are you sure you want to change the base?
Conversation
|
This looks like AI generated code. I don't accept code generated by an AI. |
What part of the actual code is AI generated? I am getting this issue: JsonMapper_Exception: JSON property "encryptAssertionsMode" must be an object, string givenand i tracked down the problem to the JsonMapper.php::299. I fixed and tested that i do not get the error report in my testing environment. Then i added a couple of tests that support this. Then i opened the PR. Simple as that. |
2c3c878 to
b850b5c
Compare
|
The issue description looks totally generated. |
@cweiske yes it is. This does not make the code neither AI generated, nor untested/unverified. |
|
Related Issue #247 |
d403a67 to
b850b5c
Compare
Please follow up on this issue's discussion and illustrate how you'd go forward when a setting is stating that no objects are being generated when scalar values are encountered. Also consider the mentioned issue with |
b850b5c to
9023cf7
Compare
| ) { | ||
| $array = $this->createInstance($type, false, $jvalue); | ||
| } else if (PHP_VERSION_ID >= 80100 && enum_exists($type)) { | ||
| $evalue = $type::tryFrom($jvalue); |
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.
This will crash if $type refers to a UnitEnum, which doesn't have tryFrom()
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.
Feels weird putting this code here too since the rest of these branches concern arrays and iterables
JsonMapper failed to map JSON scalar values into PHP 8.1+ backed enum-typed properties and incorrectly treated them as objects. This caused errors like:
JsonMapper_Exception: JSON property "exampleEnumMode" must be an object, string given.What changed
Before
After