deprecation-detector icon indicating copy to clipboard operation
deprecation-detector copied to clipboard

Deprecation $this->get('request')

Open smatejic opened this issue 9 years ago • 4 comments

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)

smatejic avatar Oct 23 '15 15:10 smatejic

Thanks :) !

MarvinKlemp avatar Oct 24 '15 13:10 MarvinKlemp

I think this is a similar problematic as #66

ghost avatar Oct 26 '15 16:10 ghost

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

MarvinKlemp avatar Oct 26 '15 16:10 MarvinKlemp

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

xabbuh avatar Oct 27 '15 21:10 xabbuh