Fix failing enum mapping for backed PHP enums#249
Fix failing enum mapping for backed PHP enums#249ioigoume wants to merge 1 commit intocweiske:masterfrom
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.
This will crash if $type refers to a UnitEnum, which doesn't have tryFrom()
There was a problem hiding this comment.
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