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

[CodeQuality] Skip intersection property var type on ImproveDoctrineCollectionDocTypeInEntityRector #344

Closed
wants to merge 2 commits into from

Conversation

samsonasik
Copy link
Member

Closes #342

@samsonasik
Copy link
Member Author

All checks have passed 🎉 @TomasVotruba it is ready for review.

@bobvandevijver
Copy link
Contributor

This would only skip the rule, which is fine by me, but note that I also tried to create #343 which would also insert the correct Selectable annotation.

Comment on lines +14 to +18
/**
* @var Collection<int, CountryRef>&Selectable
*/
#[ORM\OneToMany(mappedBy: 'country', targetEntity: CountryRef::class, cascade: ['persist'])]
private Collection $countryRefs;
Copy link
Member

@TomasVotruba TomasVotruba Sep 1, 2024

Choose a reason for hiding this comment

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

While this fixes proposed issue, it doesn't make sense from PHP points of view.

This code should be updated as well:

private Collection $countryRefs;

Also, in the case of using matching() in many places, this would be correct:

private ArrayCollection $countryRefs;

But this is out of scope of this rule. I'd recommend to create custom rule to use ArrayCollection if possible. This is not a propper fix, as it creates ambiguous difference between PHP and docblock analysis.

Copy link
Contributor

Choose a reason for hiding this comment

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

It is not possible to use ArrayCollection as type. Depending on the state of the object, it is either ArrayCollection or PersistentCollection.

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.

The rule ImproveDoctrineCollectionDocTypeInEntityRector does not keep Intersection types
3 participants