Skip to content

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

Closed
wants to merge 1 commit into from
Closed

Update Request.php #11032

wants to merge 1 commit into from

Conversation

bocharsky-bw
Copy link
Contributor

Not work autocomplete for getFlashBag() method called from getSession()

Not work autocomplete for `getFlashBug()` method called from `getSession()`
@henrikbjorn
Copy link
Contributor

This is wrong, as Session is an implementation of SessionInterface, also because you can use a mocked SessionInterface object.

@jakzal
Copy link
Contributor

jakzal commented Jun 2, 2014

👎 for reasonons @henrikbjorn mentioned.

@bocharsky-bw
Copy link
Contributor Author

What about add getFlashBag() method to the SessionInterface?

   /**
    * Gets the flashbag interface.
    *
    * @return FlashBagInterface
    */
    public function getFlashBag();

@bocharsky-bw bocharsky-bw deleted the patch-1 branch June 2, 2014 09:02
@cordoval
Copy link
Contributor

cordoval commented Jun 2, 2014

why you closed this? what was your need? autocompletion? could you please explain?

@bocharsky-bw
Copy link
Contributor Author

@cordoval Yes, I want to use auto complete for getFlashBag() method, calling from $this->get('session') session service in my controllers

@henrikbjorn
Copy link
Contributor

@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.

@cordoval
Copy link
Contributor

cordoval commented Jun 2, 2014

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.

@bocharsky-bw
Copy link
Contributor Author

@cordoval Yes, thanks! I think docblock is the good solution in this case.

@bocharsky-bw
Copy link
Contributor Author

@henrikbjorn But there isn't auto complete when I try to get access to the getFlashBag() method from $request->getSession() object

@henrikbjorn
Copy link
Contributor

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

@cordoval
Copy link
Contributor

cordoval commented Jun 2, 2014

@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

@henrikbjorn
Copy link
Contributor

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.

@stof
Copy link
Member

stof commented Jun 3, 2014

@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

@cordoval
Copy link
Contributor

cordoval commented Jun 3, 2014

I see, thanks for the explanation @stof @henrikbjorn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants