Better merging of collection types#40
Conversation
A code of conduct is good for every inclusive open source project. This one is standard.
Added a code of conduct
Initial import
cleanup naming and tweak version handling
Running checks and tests on CI now
use phpstan shim instead of having all phpstan code in vendors
This will hopefully make the step towards contributing a bit easier :)
Add phpunit, cs-fixer and travis config
Added a CONTRIBUTING file
fix test setup and support jms readonly annotation
support jms 1 and 2
Directly add doctrine/annotations dependency
use latest cs fixer
There was a problem hiding this comment.
thanks for this improvement. it makes a lot of sense to me.
i realize that the PropertyTypeArray is a bit of a misnomer, we should have called it PropertyTypeIterable to go with PHP iterable type... would that make sense to you?
as we do a BC break anyways, we could maybe also cleanup the name.
can you please add some tests for this? and a changelog entry?
i created the 2.x branch. can you please target that version.
dbu
left a comment
There was a problem hiding this comment.
thanks a lot! i think this is about ready. i suggest to be forward compatible with our version 2, at least for the new PropertyTypeIterable.
please also add a note to the changelog. i think in the readme doc there is no explanation needed.
i created the 2.x milestone, please add to it.
…erve old class name for BC only
b4971e0 to
cc05f03
Compare
…e merge; squash php-cs fixes
cc05f03 to
4afb6a1
Compare
| * - we're not merging a plain array PropertyTypeIterable into a hashmap one, | ||
| * - and the collection classes of each are either not present on both sides, or are the same, or parent-child of one another | ||
| */ | ||
| class PropertyTypeIterable extends AbstractPropertyType |
There was a problem hiding this comment.
we should make this class final. if inverse what extends what we can do that, and have the deprecated class no longer be technically final.
4afb6a1 to
e9359cf
Compare
|
It seems that force-pushing on my branch closed down my PR, I'll soon reopen it when my git directory is in order |
|
it looks like what you did recreated every single commit since the very fist commit :-O i think what i'd do is to create a fresh branch from 1.x and then cherry-pick the relevant commits. and create a new merge request. |
|
This is reopened in #42 |
When a model has a collection type-hinted with
Collection, and the JMS serializer annotations has the actual information about the collections contents (@Serializer\Type("ArrayCollection<...>")), the model parsing fails with the errorCan't merge type Liip\MetadataParser\Metadata\PropertyTypeClass with Liip\MetadataParser\Metadata\PropertyTypeArray, they must be the same or unknown.This happens when the
ReflectionParserpasses before theJMSParser, due to the two property type metadatasPropertyTypeClass<Collection>andPropertyTypeArray<ArrayCollection<...>>not being compatible. Using JMS alone, this does work, and logically speaking, the PropertyTypeArray in the example can be understood to be a specialisation of the PropertyTypeClass.This Pull Request proposes a specialized case to merge
Collections from PropertyTypeClass intoPropertyTypeArrays that are Collections too, using their most derived common base class (hopefully, both sides have the same collection type).Here is a test script to explain my idea
P.S.: I'll be adding proper auomated tests shortlyTests have been added to cover as many cases as I could think of.