Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[PropertyInfo] Mentioned the phpDoc collection type #11866

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

Merged
merged 1 commit into from
Jul 12, 2019

Conversation

javiereguiluz
Copy link
Member

This fixes #10338.

@javiereguiluz
Copy link
Member Author

@popy-dev I know that you implemented this feature a long ago (thanks for that!) but, could you please review if this proposed change is correct? Thanks.


.. versionadded:: 4.2

The support of phpDocumentor collection types was introduced in Symfony 4.2.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a link to the phpDocumentor library?

@popy-dev
Copy link

popy-dev commented Jul 3, 2019

Hi @javiereguiluz

It seems fine to me. Maybe you could give more "open" example (the Iterator class can, in fact, be any class, and collection values also), but I guess that's nitpicking :)

@javiereguiluz
Copy link
Member Author

@popy-dev thanks for reviewing!

I have some problems trying to fully understand this feature so ... could you please show me some valid examples that don't use the Iterator class? Thanks!

@popy-dev
Copy link

popy-dev commented Jul 5, 2019

I have some problems trying to fully understand this feature

The idea is to be able to give more details about a property type. If you have an array of Items, you can use the @var Item[] notation to give more information than just @var array. But this notation does not covers the case of nexted arrays, neither the case of Traversable objects. That's what the notation @var Class<key,value>covers. It's expected that "Class" implements the Traversable interface, so it could be any class implementing Iterator, or IteratorAggregate, or it could be a Generator. And as it's mostly a matter of convention, one could argue that it does not even need to be a Traversable. I hope I'm clearer than it looks :D

As an actual example, if you're familiar with doctrine collection, you could annotate a OneToMany collection with :

/**
 * @var Doctrine\Common\Collections\Collection<App\Entity\Item>
 */
protected $items;

@javiereguiluz
Copy link
Member Author

@popy-dev thanks a lot for your great and detailed explanation. I can fully understand this now and I've updated the explanation to show better examples. Thanks!

@javiereguiluz javiereguiluz merged commit e03b128 into symfony:4.2 Jul 12, 2019
javiereguiluz added a commit that referenced this pull request Jul 12, 2019
…iereguiluz)

This PR was squashed before being merged into the 4.2 branch (closes #11866).

Discussion
----------

[PropertyInfo] Mentioned the phpDoc collection type

This fixes #10338.

Commits
-------

e03b128 [PropertyInfo] Mentioned the phpDoc collection type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants