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

Deprecation $this->get('request') #64

Open
smatejic opened this issue Oct 23, 2015 · 4 comments
Open

Deprecation $this->get('request') #64

smatejic opened this issue Oct 23, 2015 · 4 comments

Comments

@smatejic
Copy link

Running deprecator detects $this->getRequest() but i found some very old code that was using in Controller

$this->get('request')

which will be deprecated in 3.0

/**
* Gets a container service by its id.
*
* @param string $id The service id
*
* @return object The service
*/
public function get($id)
{
if ('request' === $id) {
@trigger_error('The "request" service is deprecated and will be removed in 3.0. Add a typehint for Symfony\Component\HttpFoundation\Request to your controller parameters to retrieve the request instead.', E_USER_DEPRECATED);
}

    return $this->container->get($id);
}

Deprecator needs to generate error here (it needs rule)

@MarvinKlemp
Copy link
Contributor

Thanks :) !

@ghost
Copy link

ghost commented Oct 26, 2015

I think this is a similar problematic as #66

@MarvinKlemp
Copy link
Contributor

The problem is that the detector only checks the return type of $container->get() but $container->get('request') returns a request object which is not deprecated

@xabbuh
Copy link
Member

xabbuh commented Oct 27, 2015

Having a service named request generally isn't deprecated (for example, you can use the component without the rest of the framework and have such a service in your project).

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

No branches or pull requests

3 participants