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

The future of Common 3.0 #826

Open
Majkl578 opened this issue Dec 6, 2017 · 38 comments
Open

The future of Common 3.0 #826

Majkl578 opened this issue Dec 6, 2017 · 38 comments

Comments

@Majkl578
Copy link
Contributor

Majkl578 commented Dec 6, 2017

The proposal is pretty simple: have no Common 3.0, instead split Common into smaller packages. We've already had discussion about this and Common 3.0 seems pretty much like relic and multiple components have already been split to their own packages.

Current proposal:

Component Suggested action
Persistence Move to new package doctrine/persistence (rename namespace to Doctrine\Persistence)
Proxy To be dropped without replacement.
Reflection Not really sure about this one, either move to doctrine/reflection or drop it.
Util/ClassUtils Proxy-related methods are obsolete making the rest also pretty much obsolete - drop it
Util/Debug Drop it or move to doctrine/debug.
Util/Dumper Unsure about its usefulness (there already exist more advanced tools like Tracy or Symfony Dumper).
Util/Inflector Already moved out, only BC.
ClassLoader Already deprecated, drop it.
CommonException ~
Comparable I know no place where Comparable is used across Doctrine (is there any?) but it seems useful i.e. for ORM 3.0 - move it to doctrine/comparable.
EventArgs + EventManager + EventSubscriber We've already discussed replacing it by i.e. Symfony's EventDispatcher - drop it if suitable replacement is selected, doctrine/event-manager.
Lexer Already moved out, only BC.
NotifyPropertyChanged + PropertyChangedListener These sound useful and are used in ORM so move it to doctrine/property-change-notifier (what a name!) doctrine/persistence.
Version ~

Each new package would use PHP 7.2 (or even 7.1 where 7.2 has no benefit), follow CS and would be ported to typed code.

WDYT?

@Ocramius
Copy link
Member

Ocramius commented Dec 6, 2017

EventArgs + EventManager + EventSubscriber We've already discussed replacing it by i.e. Symfony's EventDispatcher - drop it if suitable replacement is selected, doctrine/event-manager.

Only if proven to be faster at runtime.

Lexer Already moved out, only BC.

Deprecate and use Hoa components

NotifyPropertyChanged + PropertyChangedListener These sound useful and are used in ORM so move it to doctrine/property-change-notifier (what a name!).

Move to ORM, rework as isolated layer if possible

Version ~

Drop it - relying on package versions should only be done via composer.json

@jmikola
Copy link
Member

jmikola commented Dec 6, 2017

NotifyPropertyChanged + PropertyChangedListener These sound useful and are used in ORM so move it to doctrine/property-change-notifier

Move to ORM, rework as isolated layer if possible

Would ODM need these as well?

@malarzm
Copy link
Member

malarzm commented Dec 6, 2017

NotifyPropertyChanged + PropertyChangedListener These sound useful and are used in ORM so move it to doctrine/property-change-notifier

Move to ORM, rework as isolated layer if possible

Would ODM need these as well?

We'd need to port these as well

@alcaeus
Copy link
Member

alcaeus commented Dec 7, 2017

I know no place where Comparable is used across Doctrine (is there any?) but it seems useful i.e. for ORM 3.0 - move it to doctrine/comparable.

We were thinking of using it to compare value objects instead of comparing them by reference in ODM 2.0. Extracting it to a separate package would make sense.

@alcaeus
Copy link
Member

alcaeus commented Dec 7, 2017

The proposal is pretty simple: have no Common 3.0, instead split Common into smaller packages.

Yes, please. doctrine/common should die. I've given the whole BC problem and the fact that upgrading one to 3.0 will conflict with a bunch of other stuff, so here's an idea on how to migrate to 3.0 versions of everything:

  1. Split code in individual packages, remove from doctrine/common
  2. update composer.json to require all these new packages (e.g. doctrine/comparable)
  3. Add autoload file to doctrine/common that triggers a deprecation notice for doctrine/common itself
  4. Release the whole contraption as 2.9.0: this essentially makes doctrine/common a metapackage that throws a deprecation notice, but keeps everything else intact
  5. Start updating our own dependents of doctrine/common to no longer require doctrine/common but individual packages
  6. Start releasing 3.0 versions with BC breaks of those individual packages

Reflection: Not really sure about this one, either move to doctrine/reflection or drop it.

What do we need it for? IIRC there are far better reflection libraries out there, so we might want to use those

Each new package would use PHP 7.2 (or even 7.1 where 7.2 has no benefit), follow CS and would be ported to typed code.

Ack on PHP versions, Ack on CS, not entirely sure about typed code. Many instances probably are fine, but there are some cases where we might not want to add type hints just yet. Take the following interface for example:

interface Collection
{
    // ...
    public function get(int $index): object;
}

Makes sense, right? Except that without full co- and contravariance in PHP, I can't do this:

class SpecialCollection implements Collection
{
    // ...
    public function get(int $index): MyEntityClass {}
}

This is perfectly fine when Collection::get does not specify a return type, but fails when it does. I believe there are a few cases where we might want to hold back on strictly typing our interfaces to allow for stricter implementations.

@Majkl578
Copy link
Contributor Author

Majkl578 commented Dec 7, 2017

We were thinking of using it to compare value objects instead of comparing them by reference in ODM 2.0. Extracting it to a separate package would make sense.

Same idea is there for ORM 3.0 to compare DBAL values and Embeddables by value.

Add autoload file to doctrine/common that triggers a deprecation notice for doctrine/common itself

Also class aliases will be needed since we change namespace.

Start releasing 3.0 versions with BC breaks of those individual packages

For consistency with other packages that were already split earlier, we should start versioning at 1.0.

Reflection

What do we need it for?

I have found no reference for it. It was added as part of #154/#152 probably as a more memory effective variant based on PSR-0.

not entirely sure about typed code

Collection as it is designed now is all about mixed members, not object, so no object typehints there unless we decide it will be object-only.
Your example is otherwise valid, there is no variance along with object due to controversy and possible future scope. But honestly I know noone (or no project) that'd use custom collections to change return types (and you couldn't change parameter for i.e. Collection::contains(object $element) types anyway).
In general for such case (same applies more or less to EntityManager or ORM repositories), object is the only correct way and if you miss the opportunity to add it now, you can miss it for another X years while possibly having PHP variance for object natively (or not) in future 7.x release, who knows.

@alcaeus
Copy link
Member

alcaeus commented Dec 8, 2017

Also class aliases will be needed since we change namespace.

We haven't done so for inflector, lexer, collections, or other packages, which is why I didn't think of it.

and you couldn't change parameter [...] types anyway

You're right - this one is probably best solved using documentation (or generics in PHP)

@Majkl578
Copy link
Contributor Author

Majkl578 commented Dec 9, 2017

We haven't done so for ...

Hmm true, they are still in Doctrine\Common namespace... That should probably also change in major release of those packages + providing forward compat by adding class aliases in 1.x (something like PHPUnit did).

@alcaeus
Copy link
Member

alcaeus commented Dec 15, 2017

That should probably also change in major release of those packages + providing forward compat by adding class aliases in 1.x

FWIW, this is something that has been discussed for annotations 2.0, where it has triggered quite the discussion: doctrine/annotations#75 (comment). I'm split on this issue: on one hand, cleaning up namespaces would be nice, on the other hand it would make things way more complicated. I will however concede that we could ease the migration by providing a forward compat layer. That would allow people to better prepare for the new package versions.

@Majkl578
Copy link
Contributor Author

Majkl578 commented Dec 17, 2017

When it comes to changing package's namespace, I think most people are concerned about compatibility between both major versions - x.y & x+1.0. This shouldn't be hard to achieve with mentioned forward compatibility layer where we introduce new namespace and class aliases in x.y version and migrate classes in x+1.0. Something like PHPUnit did around version 4.
Then doing such migration is as easy as one regexp replace (sed/IDE) over whole code base.

@stof
Copy link
Member

stof commented Mar 7, 2018

Util/Debug Drop it or move to doctrine/debug.

I suggest dropping it. this Debug utility is shitty anyway, as dumping an uninitialized PersistentCollection will have the side effect of initializing it (and so dumping some variable to debug something will change the behavior of the code, which could then not have the bug you were debugging).
And the output format is not nice either. We should just recommend symfony/var-dumper instead.

@Majkl578
Copy link
Contributor Author

Update:

Currently with undecided fate (so still left without deprecation):

  • NotifyPropertyChanged + PropertyChangedListener
  • Comparable

Deprecations for the rest of remaining things via #845, targeting 2.9.0 which should be released in upcoming days.

symfony-splitter pushed a commit to symfony/doctrine-bridge that referenced this issue Jun 20, 2018
This PR was merged into the 4.2-dev branch.

Discussion
----------

Remove direct dependencies on doctrine/common

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | none
| License       | MIT
| Doc PR        | ?

Doctrine has recently separated multiple components from doctrine/common:
* [doctrine/event-manager](https://github.com/doctrine/event-manager) [[release notes](https://github.com/doctrine/event-manager/releases/tag/v1.0.0) | [split PR](doctrine/common#842)]
* [doctrine/persistence](https://github.com/doctrine/persistence) [[release notes](https://github.com/doctrine/persistence/releases/tag/v1.0.0) | [split PR](doctrine/common#845)]
* [doctrine/reflection](https://github.com/doctrine/reflection) [[release notes](https://github.com/doctrine/reflection/releases/tag/v1.0.0) | [split PR](doctrine/common#845)]

All of the packages are 100% backward compatible with their counterparts in Common 2.8.

This is a major step to slowly start with [phasing out doctrine/common package](doctrine/common#826) before ORM 3.0 / DBAL 3.0 / ODM 3.0.
Common 2.9.0 will also be composed from these new packages.

Most of the remaining parts in doctrine/common are likely to be deprecated (or already are), please see & discuss in [the PR over in doctrine/common repository](doctrine/common#845).

This PR therefore aims to remove the direct doctrine/common dependency from Symfony, replacing it by specific Doctrine components.

Commits
-------

b0fa398187 Remove direct dependencies on doctrine/common
fabpot added a commit to symfony/symfony that referenced this issue Jun 20, 2018
This PR was merged into the 4.2-dev branch.

Discussion
----------

Remove direct dependencies on doctrine/common

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | none
| License       | MIT
| Doc PR        | ?

Doctrine has recently separated multiple components from doctrine/common:
* [doctrine/event-manager](https://github.com/doctrine/event-manager) [[release notes](https://github.com/doctrine/event-manager/releases/tag/v1.0.0) | [split PR](doctrine/common#842)]
* [doctrine/persistence](https://github.com/doctrine/persistence) [[release notes](https://github.com/doctrine/persistence/releases/tag/v1.0.0) | [split PR](doctrine/common#845)]
* [doctrine/reflection](https://github.com/doctrine/reflection) [[release notes](https://github.com/doctrine/reflection/releases/tag/v1.0.0) | [split PR](doctrine/common#845)]

All of the packages are 100% backward compatible with their counterparts in Common 2.8.

This is a major step to slowly start with [phasing out doctrine/common package](doctrine/common#826) before ORM 3.0 / DBAL 3.0 / ODM 3.0.
Common 2.9.0 will also be composed from these new packages.

Most of the remaining parts in doctrine/common are likely to be deprecated (or already are), please see & discuss in [the PR over in doctrine/common repository](doctrine/common#845).

This PR therefore aims to remove the direct doctrine/common dependency from Symfony, replacing it by specific Doctrine components.

Commits
-------

b0fa398 Remove direct dependencies on doctrine/common
@Majkl578
Copy link
Contributor Author

https://www.doctrine-project.org/2018/07/12/common-2-9-and-dbal-2-8-and-orm-2-6-2.html

@pamil
Copy link

pamil commented Jul 13, 2018

Great job, happy to see so much progress towards 3.0! 🎉

@sterichards
Copy link

sterichards commented Oct 2, 2018

Is there a checklist available to describe the steps to be taken?

Obviously remove doctrine/common....

Which Doctrine packages should be installed to cover the removal of doctrine/common?

Am I correct in presuming:

  • doctrine/persistence
  • doctrine/event-manager
  • doctrine/reflection

?

@Ocramius
Copy link
Member

Ocramius commented Oct 2, 2018

@sterichards doctrine/common would provide the list inside composer.json (it already does for some moved out packages)

@sterichards
Copy link

sterichards commented Oct 2, 2018

@Ocramius In that case, it would be:

  • "doctrine/inflector"
  • "doctrine/cache"
  • "doctrine/collections"
  • "doctrine/lexer"
  • "doctrine/annotations"
    - "doctrine/event-manager"
    - "doctrine/reflection"
    - "doctrine/persistence"

@Majkl578
Copy link
Contributor Author

Majkl578 commented Oct 2, 2018

Except the last three, the other were moved out years ago. Please see the release notes for 2.9.0 where the recent changes are described.

@sterichards
Copy link

sterichards commented Oct 2, 2018

Removing doctrine/common is looking more and more difficult as nearly every latest stable doctrine package requires doctrine/common

As an example - https://packagist.org/packages/doctrine/data-fixtures#v1.3.1:

Requires:

  • doctrine/common: ~2.2

@Ocramius
Copy link
Member

Ocramius commented Oct 2, 2018

@sterichards we'd just migrate each of our own downstream package: we're not breaking BC anyway, so relying on doctrine/common is fine for now

@Majkl578
Copy link
Contributor Author

Majkl578 commented Oct 2, 2018

Removing doctrine/common is looking more and more difficult

The ultimate aim is not to drop doctrine/common in all consumers now, but to phase it out gradually. First major step was separating components that will outlive Common. Right now DBAL already benefits from this change (see doctrine/dbal#3181). It's more tricky in other pacakges - i.e. ORM uses ProxyGenerator and NotifyPropertyChanged so it can't drop doctrine/common in 2.x, only ORM 3.0.

TL;DR: In long-term it's preferable if can make your application depend on specific packages instead of doctrine/common (your dependencies may still draw doctrine/common in, but that wouldn't be your problem anymore - new packages are co-installable with doctrine/common 2.9+). Otherwise doctrine/common is still here and not abandoned, and it won't (can't) be at least until ORM 3.0.

@sterichards
Copy link

Makes sense

I was looking for an approach that would eliminate deprecated warnings, which is what lead me to this issue ticket initially

@fmonts
Copy link

fmonts commented Oct 2, 2018

Makes sense

I was looking for an approach that would eliminate deprecated warnings, which is what lead me to this issue ticket initially

Agree, please remove the deprecation warning since it's quite annoying and it's a false positive, it's not something the developer of a Symfony app is supposed to fix

@Ocramius
Copy link
Member

Ocramius commented Oct 2, 2018

@Majkl578
Copy link
Contributor Author

Majkl578 commented Oct 2, 2018

I was looking for an approach that would eliminate deprecated warnings

please remove the deprecation warning since it's quite annoying and it's a false positive

Which warning(s) exactly? Most people notice the issue coming from ORM (doctrine/orm#7306 that will be fixed in ORM 2.6.3 once released.

@sterichards
Copy link

sterichards commented Oct 2, 2018

I see the deprecated warning when running PHPUnit

It's no hassle to me if it's going to be resolved in a future version and isn't causing any lack of functionality at the moment

@sterichards
Copy link

If anybody else comes across this thread, there is a method for suppressing deprecation notices in PHPUnit - https://stackoverflow.com/questions/35897550/remove-remaining-deprecation-notices-232-in-symfony-2-8

@fmonts
Copy link

fmonts commented Nov 21, 2018

I was looking for an approach that would eliminate deprecated warnings

please remove the deprecation warning since it's quite annoying and it's a false positive

Which warning(s) exactly? Most people notice the issue coming from ORM (doctrine/doctrine2#7306 that will be fixed in ORM 2.6.3 once released.

Why it hasn't been released yet? How long will it take to have a release? It's been many months now...

@fmonts
Copy link

fmonts commented Nov 21, 2018

lol, it was released yesterday :)

good job, the deprecation warning is finally gone

@TerjeBr
Copy link

TerjeBr commented Mar 13, 2019

What about Doctrine\Common\Util\ClassUtils::getRealClass(string $class) ?
Where is that function going to live? Or what is the replacement?

@TerjeBr
Copy link

TerjeBr commented Mar 13, 2019

@Ocramius you should put that in the deprecation warning then. It is not an obvious place (at least for me) to look for a replacement.

Why do you call it an inflector anyway? I only assicated inflection with grammar and verbs/substantives being inflected.

@Ocramius
Copy link
Member

@TerjeBr feel free to send suggestions to the upstream repository - I'm in no way good at naming, specifically not in a language that isn't my native one.

@TerjeBr
Copy link

TerjeBr commented Mar 13, 2019

@Ocramius The naming of the class is one thing. But my main point was that the new class should be mentioned in the deprecation warning. It is not nice to get deprecations, and then have no idea where to find the new implementation.

@Majkl578
Copy link
Contributor Author

@TerjeBr There are two issues here:

  • First, Doctrine\Common\Proxy is being deprecated, and while ProxyManager is suggested replacement for consumers, you can't just swap the ClassUtils with ClassNameInflector without changing the actual proxy layer.
  • Second, your issue is rather with subsequent deprecation in ORM/ODM where the same as above applies, you will be able to use ClasNameInflector in ORM 3.0 but not in 2.x.

@TerjeBr
Copy link

TerjeBr commented Mar 13, 2019

The reason you have deprecation warnings, is so that applications can change to not depend on the deprecated code that is scheduled to be removed later. But what is the purpose of having deprecation warnings if there is nothing to change to? If I understand you right there is no alternative to Doctrine\Common\Util\ClassUtils::getRealClass(string $class) in doctrine 2.x, right?

This means that as long as my application remain on the latest 2.x version, we are stuck with those deprecation warnings? That is just insane. It will also do a huge disservice to the cummunity, as it just motivates people to ignore deprecation warnings all together.

@Ocramius
Copy link
Member

Well, yeah, this is an endpoint where we don't have a clear migration path at the moment. If you want, you can make ClassUtils::getRealClass() proxy through to the new API in 3.x, and then we can drop it in 4.x.

Can you please fork off the discussion to a new issue though?

@TerjeBr
Copy link

TerjeBr commented Mar 13, 2019

Ok, moving this discussion to #867

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants