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

Support other subclasses of EntityManagerInterface too #180

Closed
wants to merge 1 commit into from

Conversation

NoelLH
Copy link
Contributor

@NoelLH NoelLH commented Mar 4, 2022

Description

Support any EntityManagerInterface in new generateId() methods, and also in existing generate()s.

Also require PHP 7.4+ and expand use of type constraints.

I suggest this targets a new major release.

Motivation and context

Detailed in thebiggive/matchbot#338

How has this been tested?

Unit tests run and added to. Fork used in thebiggive/matchbot#338 both with real local calls and unit tests.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

I believe this is backwards incompatible only insofar as PHP version support, so I have not made any documentation changes or identified any that are needed.

PR checklist

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING.md document.
  • I have added tests to cover my changes.

Also require PHP 7.4+ and expand use of type constraints
@NoelLH NoelLH requested a review from ramsey as a code owner March 4, 2022 15:35
Copy link
Owner

@ramsey ramsey left a comment

Choose a reason for hiding this comment

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

In general, I want to accept these changes, but I think it will require a major version bump, due to the BC break.

* @param Entity $entity
*
* @return UuidInterface
*
* @throws Exception
*/
public function generate(EntityManager $em, $entity)
public function generateId(EntityManagerInterface $em, $entity): UuidInterface
Copy link
Owner

Choose a reason for hiding this comment

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

This introduces a BC break, right? If anyone extends UuidGenerator and overrides this method, making this change will result in an error like:

Fatal error: Declaration of Foo::generate(EntityManager $em, $entity) must be compatible with Ramsey\Uuid\Doctrine\UuidGenerator::generate(EntityManagerInterface $em, $entity): UuidInterface

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ramsey Yes, sorry I wasn't clear. This is what I was trying to get at with:

I suggest this targets a new major release.

I would also expect the bump in minimum PHP version to necessitate a new major version as that's also a BC break, hence my thinking that the two changes could go hand in hand.

Copy link

Choose a reason for hiding this comment

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

A bump in minimum PHP version shouldn't be considered a BC break IMHO. The reasoning is explained under "Why dropping PHP support in a minor version is not a BC break" at https://www.doctrine-project.org/2017/07/25/php-7.1-requirement-and-composer.html

ramsey pushed a commit that referenced this pull request Dec 20, 2022
Also require PHP 7.4+ and expand use of type constraints
@ramsey
Copy link
Owner

ramsey commented Dec 20, 2022

Thank you for contributing! 🎉

I committed this in 53955b7

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.

None yet

3 participants