10000 [Routing] Construct Route annotations using named arguments by derrabus · Pull Request #40266 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Routing] Construct Route annotations using named arguments #40266

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
Feb 25, 2021

Conversation

derrabus
Copy link
Member
@derrabus derrabus commented Feb 21, 2021
Q A
Branch? 5.x
Bug fix? no
New feature? no
Deprecations? yes
Tickets N/A
License MIT
Doc PR Not needed

This PR proposes to bump the doctrine/annotations library to 1.12 to gain access to its emulation layer for named arguments. Furthermore, constructing a Route annotation the old way by passing an array of parameters is deprecated.

Reasons for this change

The constructors of our annotation classes have become unnecessarily complicated because we have to support two ways of calling them:

  • An array of parameters, passed as first argument, because that's the default behavior doctrine/annotations.
  • A set of named arguments because that's how PHP 8 attributes work.

Since we can now tell the Doctrine annotation reader to use named arguments as well, we can simplify the constructors of our annotations significantly.

Drawback

After this change, there is no easy way anymore to construct instances of the Route annotation class directly on PHP 7. The PR has been built under the assumption that instances of this class are usually created using either Doctrine annotations or a PHP 8 attribute. Thus, most applications should be unaffected by this change.

@carsonbot
Copy link

Hey!

I did a quick review of this PR, I think most things looks good.

I think @mtarld has recently worked with this code. Maybe they can help review this?

Cheers!

Carsonbot

Copy link
Member
@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

(rebase needed)

@derrabus derrabus force-pushed the improvement/deprecate-route-data branch 2 times, most recently from 8b1a3aa to d70dcc9 Compare February 22, 2021 09:10
@derrabus derrabus force-pushed the improvement/deprecate-route-data branch from d70dcc9 to 29b0f96 Compare February 24, 2021 13:30
@fabpot
Copy link
Member
fabpot commented Feb 25, 2021

Thank you @derrabus.

@fabpot fabpot merged commit d54a122 into symfony:5.x Feb 25, 2021
@derrabus derrabus deleted the improvement/deprecate-route-data branch February 25, 2021 07:50
fabpot added a commit that referenced this pull request Apr 8, 2021
…ts (derrabus)

This PR was merged into the 5.3-dev branch.

Discussion
----------

[Serializer] Construct annotations using named arguments

| Q             | A
| ------------- | ---
| Branch?       | 5.x
| Bug fix?      | no
| New feature?  | no
| Deprecations? | yes
| Tickets       | N/A
| License       | MIT
| Doc PR        | Not needed

This is the same as #40266, but applied to the serializer annotations.

This PR proposes to bump the `doctrine/annotations` library to 1.12 to gain access to its emulation layer for named arguments. Furthermore, constructing any of the serializer's annotation classes the old way by passing an array of parameters is deprecated.

### Reasons for this change

The constructors of our annotation classes have become unnecessarily complicated because we have to support two ways of calling them:
* An array of parameters, passed as first argument, because that's the default behavior `doctrine/annotations`.
* A set of named arguments because that's how PHP 8 attributes work.

Since we can now tell the Doctrine annotation reader to use named arguments as well, we can simplify the constructors of our annotations significantly.

### Drawback

After this change, there is no easy way anymore to construct instances of most of the annotation classes directly on PHP 7. The PR has been built under the assumption that instances of this class are usually created using either Doctrine annotations or a PHP 8 attribute. Thus, most applications should be unaffected by this change.

Commits
-------

c116662 [Serializer] Construct annotations using named arguments
@l-vo l-vo mentioned this pull request 8000 Apr 11, 2021
@fabpot fabpot mentioned this pull request Apr 18, 2021
derrabus added a commit that referenced this pull request May 2, 2021
This PR was merged into the 5.3-dev branch.

Discussion
----------

[Routing] Fix localized paths

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

Related to #40266, localized paths does not work anymore. This PR aims to fix that and add a rework on the tests (using real annotations/attributes instead of guessing the parsing that may lead to errors).

Commits
-------

9bf4a24 [Routing] Fix localized paths
hultberg pushed a commit to hultberg/symfony that referenced this pull request Sep 17, 2021
…arguments (derrabus)

This PR was merged into the 5.3-dev branch.

Discussion
----------

[Serializer] Construct annotations using named arguments

| Q             | A
| ------------- | ---
| Branch?       | 5.x
| Bug fix?      | no
| New feature?  | no
| Deprecations? | yes
| Tickets       | N/A
| License       | MIT
| Doc PR        | Not needed

This is the same as symfony#40266, but applied to the serializer annotations.

This PR proposes to bump the `doctrine/annotations` library to 1.12 to gain access to its emulation layer for named arguments. Furthermore, constructing any of the serializer's annotation classes the old way by passing an array of parameters is deprecated.

### Reasons for this change

The constructors of our annotation classes have become unnecessarily complicated because we have to support two ways of calling them:
* An array of parameters, passed as first argument, because that's the default behavior `doctrine/annotations`.
* A set of named arguments because that's how PHP 8 attributes work.

Since we can now tell the Doctrine annotation reader to use named arguments as well, we can simplify the constructors of our annotations significantly.

### Drawback

After this change, there is no easy way anymore to construct instances of most of the annotation classes directly on PHP 7. The PR has been built under the assumption that instances of this class are usually created using either Doctrine annotations or a PHP 8 attribute. Thus, most applications should be unaffected by this change.

Commits
-------

c116662 [Serializer] Construct annotations using named arguments
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.

5 participants
0