Skip to content

[DoctrineBridge] Loosened CollectionToArrayTransformer::transform() to accept ReadableCollection #57935

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
Aug 13, 2024

Conversation

timdev
Copy link
Contributor

@timdev timdev commented Aug 6, 2024

Since 1.8.0 doctrine/collections ships ReadableCollection, which the Collection interface extends. This commit relaxes the behavior of CollectionToArrayTransformer::transform(), allowing it to tranform instances of ReadableCollection.

Q A
Branch? 7.2
Bug fix? no
New feature? yes
Deprecations? no
Issues
License MIT

Since 1.8.0 doctrine/collections ships ReadableCollection, which the Collection interface extends. This commit relaxes the behavior of CollectionToArrayTransformer::transform(), allowing it to transform instances of ReadableCollection.

This change does not break BC, but does make doctrine/collections a non-dev dependency in order to require at least 1.8.0 of that library (previously, the lower-bound version was implicitly ^1.5 via doctrine/o[rd]m. This is one of several reasons why I'm considering this an addition and not a bugfix. Symfony maintainers are, of course, welcome to backport this patch to earlier versions of the framework at their discretion.

I've omitted a test here, since the signal:noise ratio would be poor due the the necessary inclusion of a boilerplate ReadableCollection implementation. I'm happy to add one if desired, however.

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has a contribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (see https://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (see https://symfony.com/releases)
  • Features and deprecations must be submitted against the 7.2 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

Copy link
Member

@wouterj wouterj left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

I think it's worth adding a test for this interface to (in the CollectionToArrayTransformerTest class).

Copy link
Member

@derrabus derrabus left a comment

Choose a reason for hiding this comment

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

Please add a test that covers your change.

@timdev timdev force-pushed the feat/allow-readablecollection branch 4 times, most recently from cf7ff3a to 9ff3541 Compare August 7, 2024 00:42
@timdev timdev force-pushed the feat/allow-readablecollection branch from 9ff3541 to fba7361 Compare August 7, 2024 00:48
@timdev timdev force-pushed the feat/allow-readablecollection branch from fba7361 to 5bc90a1 Compare August 7, 2024 18:53
Copy link
Member

@xabbuh xabbuh left a comment

Choose a reason for hiding this comment

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

with a few CS changes

Copy link
Member

@wouterj wouterj left a comment

Choose a reason for hiding this comment

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

Thanks for the quick actions, @timdev !

@stof
Copy link
Member

stof commented Aug 8, 2024

This change does not break BC, but does make doctrine/collections a non-dev dependency in order to require at least 1.8.0 of that library (

The right solution for that could be a conflict rule instead.

Copy link
Member

@derrabus derrabus left a comment

Choose a reason for hiding this comment

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

👍🏻 Once @xabbuh's remarks have been addressed.

@timdev timdev force-pushed the feat/allow-readablecollection branch from 5bc90a1 to 5c705d5 Compare August 8, 2024 16:01
@timdev
Copy link
Contributor Author

timdev commented Aug 8, 2024

Updated with @xabbuh's fixes.

…o accept ReadableCollection

Since 1.8.0 doctrine/collections ships ReadableCollection, which the
Collection interface extends. This commit relaxes the behavior of
CollectionToArrayTransformer::transform(), allowing it to transform
instances of ReadableCollection.
@nicolas-grekas nicolas-grekas force-pushed the feat/allow-readablecollection branch from 5c705d5 to a13f0ac Compare August 13, 2024 10:16
@nicolas-grekas
Copy link
Member

Thank you @timdev.

@nicolas-grekas nicolas-grekas merged commit da5e8a3 into symfony:7.2 Aug 13, 2024
1 check passed
@fabpot fabpot mentioned this pull request Oct 27, 2024
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.

8 participants