Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[FrameworkBundle] Make Controller helpers final#24407

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:3.4fromnicolas-grekas:final-controller
Oct 3, 2017

Conversation

@nicolas-grekas
Copy link
Member

QA
Branch?3.4
Bug fix?no
New feature?no
BC breaks?no
Deprecations?yes
Tests pass?yes
Fixed tickets-
LicenseMIT
Doc PR-

I propose to make all ControllerTrait methods final so we can add type hints.
I also propose to add ControllerTrait::has/get so that AbstractController also has the methods.
This will help move from Controller to AbstractController.

linaori and sroze reacted with thumbs up emoji
@fabpot
Copy link
Member

Thank you@nicolas-grekas.

@fabpotfabpot merged commitbbc52a1 intosymfony:3.4Oct 3, 2017
fabpot added a commit that referenced this pull requestOct 3, 2017
…-grekas)This PR was merged into the 3.4 branch.Discussion----------[FrameworkBundle] Make Controller helpers final| Q             | A| ------------- | ---| Branch?       | 3.4| Bug fix?      | no| New feature?  | no| BC breaks?    | no| Deprecations? | yes| Tests pass?   | yes| Fixed tickets | -| License       | MIT| Doc PR        | -I propose to make all ControllerTrait methods final so we can add type hints.I also propose to add ControllerTrait::has/get so that AbstractController also has the methods.This will help move from Controller to AbstractController.Commits-------bbc52a1 [FrameworkBundle] Make Controller helpers final
@nicolas-grekasnicolas-grekas deleted the final-controller branchOctober 3, 2017 20:08
@ossinkine
Copy link
Contributor

@nicolas-grekas Could you please explain what is the sense of making this methods final?

@nicolas-grekas
Copy link
MemberAuthor

@ossinkine see PR description. Why would you need to extend them?

@ossinkine
Copy link
Contributor

@nicolas-grekas PR description just says you propose to make them final but does not say why.
For example, I want to overriderender method in abstract controller to transparently set default parameters or set custom header to response:

abstractclass MyControllerextends Controller{publicfunctionrender($view,array$parameters = [],Response$response =null)    {$parameters =array_merge(['foo' =>'bar'],$parameters);returnparent::render($view,$parameters,$response);    }}

So children controllers continue to userender method.

By the same logic, other methods can be overridden

TeLiXj reacted with thumbs up emoji

@nicolas-grekas
Copy link
MemberAuthor

@ossinkine after#24722, the method will have a new signature (type-hints, as stated in the above description), so that if your code extends the methods, it will break. That's why.

@ossinkine
Copy link
Contributor

@nicolas-grekas I understand the new signature breaks BC and I've have to fix my code. But why I can't override the methods in future when my method signature is fixed?
I will need to create one more method likerenderWithDefaultParameters, right?

Koc reacted with thumbs up emoji

@TeLiXj
Copy link
Contributor

I'm surprised after try 3.4 beta 2 and discover this like ossinkine.
IMHO add type-hints in the future couldn't be a reason to mark this method as final. In the next version we can fix our signature to adapt to parent type-hints.

Koc reacted with thumbs up emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot approved these changes

@xabbuhxabbuhxabbuh approved these changes

@chalasrchalasrchalasr approved these changes

+1 more reviewer

@ogizanagiogizanagiogizanagi approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

3.4

Development

Successfully merging this pull request may close these issues.

8 participants

@nicolas-grekas@fabpot@ossinkine@TeLiXj@xabbuh@ogizanagi@chalasr@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp