Skip to content
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

Add collection syntax support for iterable #80

Merged
merged 1 commit into from
Oct 7, 2019

Conversation

julienfalque
Copy link
Contributor

@julienfalque julienfalque commented Oct 4, 2019

This PR adds support for parsing iterable using the collection syntax such as iterable<int,string>.

@jaapio
Copy link
Member

jaapio commented Oct 5, 2019

Thanks for your contribution.

Could you please explain why you want to have this syntax? This is a bc break would a new type help to solve the problem you are facing?

@julienfalque
Copy link
Contributor Author

I need this syntax to be able to document *ToMany fields in some Doctrine entities. I don't want the entities to have any knownledge about Doctrine so instead of this:

/**
 * @var array|Collection
 */
private $items;

I prefer this:

/**
 * @var iterable
 */
private $items;

Then I add the item type to improve static analysis with e.g. PHPStan:

/**
 * @var iterable<SomeEntity>
 */
private $items;

Though this currently fails on a project that relies on this library to fetch properties metadata because the library throws an exception when trying to parse the expression.

Which part of these changes do you consider a BC break?

@jaapio
Copy link
Member

jaapio commented Oct 7, 2019

I must have missed the default failback of the mixed type while reviewing this. Thanks this looks good. I will merge this one.

@jaapio jaapio merged commit 5ad886e into phpDocumentor:master Oct 7, 2019
@julienfalque
Copy link
Contributor Author

Thank you :)

@julienfalque julienfalque deleted the iterable-collection branch October 7, 2019 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants