-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Update Request.php #11032
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
Update Request.php #11032
Conversation
Not work autocomplete for `getFlashBug()` method called from `getSession()`
This is wrong, as Session is an implementation of SessionInterface, also because you can use a mocked SessionInterface object. |
👎 for reasonons @henrikbjorn mentioned. |
What about add
|
why you closed this? what was your need? autocompletion? could you please explain? |
@cordoval Yes, I want to use auto complete for |
@bocharsky-bw the right way is to typehint your controller action with Request and use $request->getSession() instead, Request and Session should not be accessed through the container. |
it is not a good reason, i just advise to type hint it with a docblock in situ /** @var $x \FQCN_HERE */
$x = $this->get('session');
$x-> You can also do the same with the request_stack considering moving a method to an interface though for the right reason it is I believe considered in the BC promise documentation in Symfony docu. |
@cordoval Yes, thanks! I think docblock is the good solution in this case. |
@henrikbjorn But there isn't auto complete when I try to get access to the |
That is because getFlashBag() is not part of the SessionInterface, the reason for this is that the flash handling was redone and to keep BC new methods cannot be added to the interface before 3.0 |
@henrikbjorn is adding a new method to the interface always a break? I thought renaming methods other name could still keep BC. Please correct me if I am wrong |
Its a BC because the previous versions released does not have that method, so if i implemented the interface in an old version and the interface changes, my implementation will be broken. |
@cordoval Adding concrete methods is BC. Adding abstract methods is a BC rbeak as it forces child classes to be updated to implement them. Methods of an interface are always abstract |
I see, thanks for the explanation @stof @henrikbjorn |
Not work autocomplete for
getFlashBag()
method called fromgetSession()