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

[2.1] Deprecate AbstractIdGenerator #2011

Merged
merged 1 commit into from May 4, 2020

Conversation

malarzm
Copy link
Member

@malarzm malarzm commented Apr 15, 2019

There's no reason to provide an abstract class instead of an interface. Since this is a BC break I propose we do this for 2.0 although I'm eager to deprecate the class in 1.3 and remove the abstract in 2.0 already :)

@malarzm malarzm requested a review from alcaeus April 15, 2019 19:16
* @return mixed
*/
abstract public function generate(DocumentManager $dm, object $document);

Copy link
Member Author

Choose a reason for hiding this comment

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

I was thinking about adding a __construct emitting E_USER_DEPRECATED but chances are that if somebody has overridden the constructor, the parent's one might be not called

Copy link
Member

Choose a reason for hiding this comment

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

Since we don't have a constructor to hook into, you may also trigger the deprecation on top of the file. It will alert people that they're using deprecated functionality, even though it won't point out every single occurrence where this is used.

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure if it's a problem, but since our generators are extending the abstract they'll also generate a deprecation notice. And we can't remove it from the inheritance chain as that'd be a BC break too :/

Copy link
Member

Choose a reason for hiding this comment

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

Ah, yeah. Difficult one, that 🤔

Copy link
Member

@alcaeus alcaeus left a comment

Choose a reason for hiding this comment

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

Looks good - I agree that deprecating in 2.0 is better than rushing this into 1.3.

@alcaeus alcaeus added this to To Do in ODM 2.0 via automation Apr 16, 2019
@alcaeus
Copy link
Member

alcaeus commented Apr 16, 2019

One minor thing: this needs to be mentioned in the upgrade notes.

@alcaeus alcaeus moved this from To Do to In progress in ODM 2.0 Apr 17, 2019
@alcaeus alcaeus added this to 2.0 in Roadmap Apr 17, 2019
@alcaeus alcaeus removed this from In progress in ODM 2.0 Apr 23, 2019
@alcaeus alcaeus moved this from 2.0 to 2.1 in Roadmap Apr 23, 2019
@alcaeus alcaeus changed the title Deprecate AbstractIdGenerator [2.1] Deprecate AbstractIdGenerator Apr 23, 2019
@alcaeus
Copy link
Member

alcaeus commented Apr 23, 2019

Pushed back to 2.1 to not deprecate stuff in a 2.0 release 😉

@alcaeus alcaeus added this to In progress in ODM 2.1 via automation Oct 8, 2019
/**
* AbstractIdGenerator
* @deprecated AbstractIdGenerator was deprecated in 2.0 and will be removed in 3.0. Implement IdGenerator interface instead.
Copy link
Member

@alcaeus alcaeus Apr 22, 2020

Choose a reason for hiding this comment

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

Needs to be updated for 2.1:

Suggested change
* @deprecated AbstractIdGenerator was deprecated in 2.0 and will be removed in 3.0. Implement IdGenerator interface instead.
* @deprecated AbstractIdGenerator was deprecated in doctrine/mongodb-odm 2.1 and will be removed in 3.0. Implement IdGenerator interface instead.

@@ -1370,7 +1370,7 @@ public function isCollectionValuedEmbed(string $fieldName) : bool
/**
* Sets the ID generator used to generate IDs for instances of this class.
*/
public function setIdGenerator(AbstractIdGenerator $generator) : void
public function setIdGenerator(IdGenerator $generator) : void
Copy link
Member

Choose a reason for hiding this comment

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

This is a BC break since ClassMetadata is not final - not sure how to best solve this at this time :|

Copy link
Member

Choose a reason for hiding this comment

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

To add a quick note, I think the impact of the BC break is small enough to risk doing this. I would also make the class @final to indicate that people really shouldn't be messing with it. We can then consider making it final in 3.0.

ODM 2.1 automation moved this from In progress to Review in progress Apr 22, 2020
@malarzm malarzm requested a review from alcaeus May 1, 2020 14:29
ODM 2.1 automation moved this from Review in progress to Reviewer approved May 4, 2020
@alcaeus alcaeus merged commit bc5e595 into doctrine:master May 4, 2020
ODM 2.1 automation moved this from Reviewer approved to Done May 4, 2020
@alcaeus alcaeus added this to the 2.1.0 milestone May 4, 2020
@alcaeus alcaeus self-assigned this May 4, 2020
@malarzm malarzm deleted the id-generator-interface branch May 28, 2020 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
ODM 2.1
  
Done
Roadmap
2.1 (unsupported)
Development

Successfully merging this pull request may close these issues.

None yet

2 participants