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

[Routing] Add type-hints RequestContext and Route classes. #32181

Merged
merged 1 commit into from
Jun 28, 2019

Conversation

derrabus
Copy link
Member

Q A
Branch? master
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #32179
License MIT
Doc PR N/A

This PR adds type-hints to RequestContext and the Route classes to give them a more php7-like feeling. Adding these type-hints on master should not be a breaking change because we require php 7.2 there, which allows downstream classes/interfaces to remove a type-hint from a method signature.

@derrabus derrabus force-pushed the improvement/route-type-hints branch 2 times, most recently from 6a69605 to cece78c Compare June 26, 2019 07:58
@derrabus derrabus mentioned this pull request Jun 26, 2019
57 tasks
@derrabus derrabus force-pushed the improvement/route-type-hints branch from cece78c to d321a1a Compare June 27, 2019 21:04
*/
public function mount($prefix, self $builder)
public function mount(string $prefix, self $builder)
Copy link
Member

@Tobion Tobion Jun 28, 2019

Choose a reason for hiding this comment

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

prefix is a string here but could also be null in

public function import($resource, ?string $prefix = '/', string $type = null)
which would currently break.
but the prefix handling in this class seems strange anyway. mount will make the prefix an empty string when prefix is / (the default). but in it checks for null. IMO the prefix should be initalized as string and then checked for '' instead.

but I would ask you to not add types in RouteCollectionBuilder because I proposed to deprecate it in #32240
this way we can merge this now and decide later if we need to worry about all those edge-cases

Tobion added a commit that referenced this pull request Jun 28, 2019
…rrabus)

This PR was merged into the 4.4 branch.

Discussion
----------

[Routing] Deprecate RouteCollection::addPrefix(null)

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | yes
| Tests pass?   | yes
| Fixed tickets | #32179
| License       | MIT
| Doc PR        | N/A

This PR deprecates the undocumented possibility to pass `null` as prefix to `RouteCollection::addPrefix()`. This allows us to add a `string` type-hint on the parameter in 5.0, see #32181 (comment)

/cc @Tobion

Commits
-------

2a88752 [Routing] Deprecate RouteCollection::addPrefix(null).
@nicolas-grekas nicolas-grekas added this to the 5.0 milestone Jun 28, 2019
@Tobion
Copy link
Member

Tobion commented Jun 28, 2019

Please rebase, remove deprecations and revert RouteCollectionBuilder

@derrabus derrabus force-pushed the improvement/route-type-hints branch from d321a1a to bb0725f Compare June 28, 2019 12:34
@derrabus derrabus force-pushed the improvement/route-type-hints branch from bb0725f to 614e824 Compare June 28, 2019 12:36
@derrabus
Copy link
Member Author

Done.

@Tobion
Copy link
Member

Tobion commented Jun 28, 2019

Thanks Alexander.

@Tobion Tobion merged commit 614e824 into symfony:master Jun 28, 2019
Tobion added a commit that referenced this pull request Jun 28, 2019
…s. (derrabus)

This PR was merged into the 5.0-dev branch.

Discussion
----------

[Routing] Add type-hints RequestContext and Route classes.

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

This PR adds type-hints to `RequestContext` and the Route classes to give them a more php7-like feeling. Adding these type-hints on master should not be a breaking change because we require php 7.2 there, which allows downstream classes/interfaces to remove a type-hint from a method signature.

Commits
-------

614e824 [Routing] Add type-hints RequestContext and Route classes.
@derrabus derrabus deleted the improvement/route-type-hints branch June 28, 2019 13:35
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.

None yet

4 participants