You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently JMS Serializer can resolve type declaration from properties (PHP 7.4), yet can not resolve the type, when type is collection (array of specific classes).
The type however is available for us in most of the time in form of the docblock @var.
Steps required to reproduce the problem
Right now, in order to describe the collection we need to do it like this:
We duplicate the type in the form of the @var and as well @JMS\Type
IDE refactoring tools are not able to find and replace, when the class name is changed
We can resolve types from property declaration without any additional configuration, however not when it's collection.
In PHP we are having convention to describe collections as @var docblock and mark it with suffix [].
This is respected by IDE, works with refactoring tools and is widely used in the community in order to describe the collection.
What I would propose is to fallback to the docblock, when declared type is array.
Previous code would looks like this:
/** * @var Message[] */private array $messages;
Expected Result
Transforming Message[] into the form respected by JMS array<Application\Message>
Actual Result
Require annotation in order to work
I have built such feature on top of JMS Serializer in integration with my framework.
However I think such feature could be really nice addition build into JMS Serializer directly.
I am willing to prepare implementation for that, if you will find it useful. :)
The text was updated successfully, but these errors were encountered:
Currently JMS Serializer can resolve type declaration from properties (PHP 7.4), yet can not resolve the type, when type is collection (array of specific classes).
The type however is available for us in most of the time in form of the docblock
@var
.Steps required to reproduce the problem
Right now, in order to describe the collection we need to do it like this:
Unfortunately this solution has disadvantages.
@var
and as well@JMS\Type
In PHP we are having convention to describe collections as
@var
docblock and mark it with suffix[]
.This is respected by IDE, works with refactoring tools and is widely used in the community in order to describe the collection.
What I would propose is to fallback to the docblock, when declared type is array.
Previous code would looks like this:
Expected Result
Transforming Message[] into the form respected by JMS array<Application\Message>
Actual Result
Require annotation in order to work
I have built such feature on top of JMS Serializer in integration with my framework.
However I think such feature could be really nice addition build into JMS Serializer directly.
I am willing to prepare implementation for that, if you will find it useful. :)
The text was updated successfully, but these errors were encountered: