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

Namespace move BC compatibility layer #71

Merged
merged 2 commits into from
Dec 10, 2019

Conversation

greg0ire
Copy link
Member

@greg0ire greg0ire commented Dec 6, 2019

This is just a draft, tell me what you think about the example, and I will squash my commits and apply it to all other classes.
Please tell me what should be done about the tests. I assumed they should use the new names, but tell me if you think previous tests with the old names should be kept in a Legacy subdirectory.

The corresponding commit on master is fed87eb

.' Use \Doctrine\Persistence\NotifyPropertyChanged instead.',
E_USER_DEPRECATED
);
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Are you ok with this or do you think line 20 should be enough?

Copy link
Member

Choose a reason for hiding this comment

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

If the DebugClassLoader already triggers a deprecation based on the @deprecated annotation we should skip this to avoid duplicate deprecation messages. Otherwise, I definitely want to keep these in.

// cc @nicolas-grekas

Copy link
Member

Choose a reason for hiding this comment

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

That practice on Symfony is to still add all possible runtime deprecations, because using the DebugClassLoader is optional, especially when using packages standalone.

Copy link
Member

@alcaeus alcaeus Dec 6, 2019

Choose a reason for hiding this comment

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

That clears it up. Thanks Nicolas!

@greg0ire I would suggest we add this deprecation message to all deprecated classes/interfaces.

@alcaeus
Copy link
Member

alcaeus commented Dec 6, 2019

Heads up, I’ll push a 1.3.x branch for this to target. We’ll add more compatibility layers in there for the BC breaks in 2.0.

@alcaeus alcaeus self-requested a review December 6, 2019 18:24
@alcaeus alcaeus changed the base branch from 1.2.x to 1.3.x December 6, 2019 20:16
lib/Doctrine/Common/NotifyPropertyChanged.php Outdated Show resolved Hide resolved
lib/Doctrine/Common/NotifyPropertyChanged.php Outdated Show resolved Hide resolved
.' Use \Doctrine\Persistence\NotifyPropertyChanged instead.',
E_USER_DEPRECATED
);
}
Copy link
Member

Choose a reason for hiding this comment

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

If the DebugClassLoader already triggers a deprecation based on the @deprecated annotation we should skip this to avoid duplicate deprecation messages. Otherwise, I definitely want to keep these in.

// cc @nicolas-grekas

@alcaeus alcaeus added this to the 1.3.0 milestone Dec 6, 2019
@greg0ire greg0ire force-pushed the namespace-move-bc-compat-layer branch 4 times, most recently from 9a2f323 to a40e414 Compare December 7, 2019 16:33
@greg0ire
Copy link
Member Author

greg0ire commented Dec 7, 2019

Travis fails because of Abstract / Exception on classes that are considered new for phpcs but actually aren't

@greg0ire greg0ire marked this pull request as ready for review December 7, 2019 16:37
@greg0ire
Copy link
Member Author

greg0ire commented Dec 7, 2019

I checked that tests that used all class names still work, you can do too by checkout out this PR, then running git checkout origin/1.3.x tests && vendor/bin/phpunit

@greg0ire greg0ire requested a review from alcaeus December 7, 2019 19:57
@greg0ire greg0ire force-pushed the namespace-move-bc-compat-layer branch 2 times, most recently from a38e3df to c494e68 Compare December 10, 2019 18:18
@greg0ire
Copy link
Member Author

greg0ire commented Dec 10, 2019

I fixed conflicts and reverted the move of PersistentObject… that class is not present on master, thanks @alcaeus for thinking of that!

@greg0ire greg0ire force-pushed the namespace-move-bc-compat-layer branch 2 times, most recently from 10a6d1f to 425d6c0 Compare December 10, 2019 18:35
This has already been done on master, let us do it again, but with a BC
layer.
@greg0ire greg0ire force-pushed the namespace-move-bc-compat-layer branch from 425d6c0 to 548f75f Compare December 10, 2019 18:43
@alcaeus
Copy link
Member

alcaeus commented Dec 10, 2019

@greg0ire feel free to add exceptions to phpcs.xml for the current naming errors. These should be taken care of separately - I don't feel comfortable shoving that into 2.0 at this point.

We are not sure yet how this classes will be dealt with.
@greg0ire
Copy link
Member Author

greg0ire commented Dec 10, 2019

Oh right, I assumed the phpcs was enabled on touched/new files only somehow. I pushed a separate commit. Tell me if you meant to have a separate PR

@alcaeus alcaeus merged commit 08e7fbd into doctrine:1.3.x Dec 10, 2019
@alcaeus
Copy link
Member

alcaeus commented Dec 10, 2019

Thanks @greg0ire!

@alcaeus alcaeus self-assigned this Dec 10, 2019
@greg0ire greg0ire deleted the namespace-move-bc-compat-layer branch December 10, 2019 21:07
@alcaeus alcaeus mentioned this pull request Dec 10, 2019
@nicolas-grekas
Copy link
Member

nicolas-grekas commented Dec 12, 2019

Tests on Symfony fail with deprecations after this change so I'm on a PR to fix them.
But it happens that's not possible: the deprecation layer in the PR doesn't work I think.

The issue is that class_alias doesn't work, because if a type hint uses the legacy one, no deprecation will be triggered - and the alias won't ever be loaded - but PHP will fail with a fatal error saying "incompatible type hint".

Fixing this would require loading the alias all the time (and thus removing the deprecation, which is fine if there is no better way...)

@alcaeus
Copy link
Member

alcaeus commented Dec 12, 2019

Thanks for the feedback! I’ll try to work on this today.

@nicolas-grekas
Copy link
Member

See symfony/symfony#34949

nicolas-grekas added a commit to symfony/symfony that referenced this pull request Dec 12, 2019
…ersistence (nicolas-grekas)

This PR was merged into the 3.4 branch.

Discussion
----------

[DoctrineBridge] try to fix deprecations from doctrine/persistence

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Follows doctrine/persistence#71
But the BC layer is not working yet, as highlighted by the `XXX` in the attached patch.
At least for the corresponding interfaces, doctrine/persistence should always alias the legacy name to the new one.

/cc @greg0ire @alcaeus FYI

Commits
-------

53a4711 [DoctrineBridge] try to fix deprecations from doctrine/persistence
@nicolas-grekas
Copy link
Member

Actually the aliases are always loaded, my bad. I made 3.4 green. Let's try with upper branches.

greg0ire added a commit to greg0ire/doctrine-orm that referenced this pull request Dec 12, 2019
A backwards-compatibility layer has been added to persistence to help
consumers move to the new namespacing. It is based on class aliases,
which means the type declaration changes should not be a BC-break: types
are the same.
See doctrine/persistence#71
greg0ire added a commit to greg0ire/doctrine-orm that referenced this pull request Dec 12, 2019
A backwards-compatibility layer has been added to persistence to help
consumers move to the new namespacing. It is based on class aliases,
which means the type declaration changes should not be a BC-break: types
are the same.
See doctrine/persistence#71
greg0ire added a commit to greg0ire/doctrine-orm that referenced this pull request Dec 12, 2019
A backwards-compatibility layer has been added to persistence to help
consumers move to the new namespacing. It is based on class aliases,
which means the type declaration changes should not be a BC-break: types
are the same.
See doctrine/persistence#71
greg0ire added a commit to greg0ire/doctrine-orm that referenced this pull request Dec 12, 2019
A backwards-compatibility layer has been added to persistence to help
consumers move to the new namespacing. It is based on class aliases,
which means the type declaration changes should not be a BC-break: types
are the same.
See doctrine/persistence#71
greg0ire added a commit to greg0ire/doctrine-orm that referenced this pull request Dec 12, 2019
A backwards-compatibility layer has been added to persistence to help
consumers move to the new namespacing. It is based on class aliases,
which means the type declaration changes should not be a BC-break: types
are the same.
See doctrine/persistence#71
greg0ire added a commit to greg0ire/doctrine-orm that referenced this pull request Dec 12, 2019
A backwards-compatibility layer has been added to persistence to help
consumers move to the new namespacing. It is based on class aliases,
which means the type declaration changes should not be a BC-break: types
are the same.
See doctrine/persistence#71
greg0ire added a commit to greg0ire/doctrine-orm that referenced this pull request Dec 12, 2019
A backwards-compatibility layer has been added to persistence to help
consumers move to the new namespacing. It is based on class aliases,
which means the type declaration changes should not be a BC-break: types
are the same.
See doctrine/persistence#71
greg0ire added a commit to greg0ire/doctrine-orm that referenced this pull request Dec 12, 2019
A backwards-compatibility layer has been added to persistence to help
consumers move to the new namespacing. It is based on class aliases,
which means the type declaration changes should not be a BC-break: types
are the same.
See doctrine/persistence#71
@Majkl578
Copy link
Contributor

Honestly this approach is disgusting as it totally breaks preloading.

@Majkl578
Copy link
Contributor

cc @Ocramius @lcobucci @beberlei @goetas This is serious with PHP 7.4 being out.

greg0ire added a commit to greg0ire/doctrine-orm that referenced this pull request Dec 12, 2019
A backwards-compatibility layer has been added to persistence to help
consumers move to the new namespacing. It is based on class aliases,
which means the type declaration changes should not be a BC-break: types
are the same.
See doctrine/persistence#71
greg0ire added a commit to greg0ire/doctrine-orm that referenced this pull request Dec 12, 2019
A backwards-compatibility layer has been added to persistence to help
consumers move to the new namespacing. It is based on class aliases,
which means the type declaration changes should not be a BC-break: types
are the same.
See doctrine/persistence#71
@doctrine doctrine locked and limited conversation to collaborators Dec 12, 2019
@alcaeus
Copy link
Member

alcaeus commented Dec 12, 2019

This is perfectly fine if our aim is to not break the entire ecosystem. If preloading breaks, you’re welcome to create a PR to fix it without removing the deprecation layer. Thanks.

Majkl578 referenced this pull request in php/php-src Dec 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants