Comments (2)
Thanks for the detailed info and taking the time to report the bug.
I can see how this is an issue in the PropertyMapper. It seems the later checks for single (scalar) value does not look at the value to see if it was an array and as a result eagerly assumes the first type (single string) is correct and applies a cast to string.
Would be able to create a PR with a unit test that shows the bug and a fix for the problem?
I could take a look but I'm running a bit behind on other things so it might take some time to get this fixed.
Alternatively as a (quick and dirty) workaround you could swap the phpdoc type declaration to string[]|string
this might doe the trick in order for you to continue.
from jsonmapper.
hi @DannyvdSluijs
for the current project I did of course the "switch". My php-cs-fixer is reverting it everytime ;-), so I was searching for a permanent solution.
I will see if I have some time to add at least a unit test for this bugfix
from jsonmapper.
Related Issues (20)
- Making own middleware - a bit unclear how to do so… HOT 8
- Cannot lookup property of namespace in parent class HOT 6
- Ensure that the JSON object is complete HOT 3
- Psalm is not happy about your example PHP class. HOT 2
- Namespace resolving is unable to resolve when using partial use combined with nested namespace in PHPdoc
- UnexpectedValueException : Value 'DateTime' is not part of the enum JsonMapper\Enums\ScalarType HOT 7
- Make it compatible with Laravel 9 HOT 4
- Undefined array key 0 with php 8.1 and readonly HOT 4
- withNativePhpClassesAdded does not honor null or nativeclass HOT 2
- Collection Mapping does not work with more than one item HOT 14
- Add enum support HOT 3
- Fatal error when mapper expects array of objects but json field is object HOT 3
- Private properties of parent classes are not taken into account when mapping data.
- Starting with v2.15.0 constructor for nested array of objects is not called HOT 1
- Update issue template to use forms
- TypeError: JsonMapper\Middleware\CaseConversion::getReplacementKey(): Argument #1 ($key) must be of type string, int given
- Node.js 12 actions are deprecated. Please update the following actions to use Node.js 16: actions/checkout@v2. For more information see: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/.
- Public properties comments are not taking into account when mapping. HOT 1
- Add Support for Enums HOT 7
- Add support to map from key/value object HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsonmapper.