From da7daee407d92fc781a2ec38ead1986e4793dce2 Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Wed, 27 Jul 2016 17:16:19 -0400 Subject: [PATCH] Removing the Controller::getUser() deprecation --- UPGRADE-3.2.md | 2 -- UPGRADE-4.0.md | 3 --- src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md | 2 -- .../Bundle/FrameworkBundle/Controller/Controller.php | 5 ----- .../Tests/Controller/ControllerTest.php | 10 ---------- 5 files changed, 22 deletions(-) diff --git a/UPGRADE-3.2.md b/UPGRADE-3.2.md index b2060d1e9c4d4..3ba1057c6b532 100644 --- a/UPGRADE-3.2.md +++ b/UPGRADE-3.2.md @@ -27,8 +27,6 @@ FrameworkBundle * The `Resources/public/images/*` files have been removed. * The `Resources/public/css/*.css` files have been removed (they are now inlined in TwigBundle). - * The `Controller::getUser()` method has been deprecated and will be removed in - Symfony 4.0; typehint the security user object in the action instead. Console ------- diff --git a/UPGRADE-4.0.md b/UPGRADE-4.0.md index 93c93f8b2ba49..01dbb281976f8 100644 --- a/UPGRADE-4.0.md +++ b/UPGRADE-4.0.md @@ -124,9 +124,6 @@ FrameworkBundle `serializer.mapping.cache.apc` and `serializer.mapping.cache.doctrine.apc` have been removed. APCu should now be automatically used when available. - * The `Controller::getUser()` method has been removed in favor of the ability - to typehint the security user object in the action. - HttpFoundation --------------- diff --git a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md index 6d3a5b3e0986b..efee66b41cecf 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md +++ b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md @@ -11,8 +11,6 @@ CHANGELOG * Removed `symfony/asset` from the list of required dependencies in `composer.json` * The `Resources/public/images/*` files have been removed. * The `Resources/public/css/*.css` files have been removed (they are now inlined in TwigBundle). - * The `Controller::getUser()` method has been deprecated and will be removed in - Symfony 4.0; typehint the security user object in the action instead. * Added possibility to prioritize form type extensions with `'priority'` attribute on tags `form.type_extension` 3.1.0 diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php b/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php index 37396a3b6bd28..1dbf54b5adf9d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php @@ -22,7 +22,6 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\Security\Core\Exception\AccessDeniedException; -use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Security\Csrf\CsrfToken; use Symfony\Component\Form\Extension\Core\Type\FormType; use Symfony\Component\Form\Form; @@ -367,16 +366,12 @@ protected function getDoctrine() * * @return mixed * - * @deprecated as of 3.2 and will be removed in 4.0. You can typehint your method argument with Symfony\Component\Security\Core\User\UserInterface instead. - * * @throws \LogicException If SecurityBundle is not available * * @see TokenInterface::getUser() */ protected function getUser() { - @trigger_error(sprintf('%s() is deprecated as of 3.2 and will be removed in 4.0. You can typehint your method argument with %s instead.', __METHOD__, UserInterface::class), E_USER_DEPRECATED); - if (!$this->container->has('security.token_storage')) { throw new \LogicException('The SecurityBundle is not registered in your application.'); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php index 9711ab260a811..2821e7faf837e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php @@ -56,9 +56,6 @@ public function testForward() $this->assertEquals('xml--fr', $response->getContent()); } - /** - * @group legacy - */ public function testGetUser() { $user = new User('user', 'pass'); @@ -70,9 +67,6 @@ public function testGetUser() $this->assertSame($controller->getUser(), $user); } - /** - * @group legacy - */ public function testGetUserAnonymousUserConvertedToNull() { $token = new AnonymousToken('default', 'anon.'); @@ -83,9 +77,6 @@ public function testGetUserAnonymousUserConvertedToNull() $this->assertNull($controller->getUser()); } - /** - * @group legacy - */ public function testGetUserWithEmptyTokenStorage() { $controller = new TestController(); @@ -95,7 +86,6 @@ public function testGetUserWithEmptyTokenStorage() } /** - * @group legacy * @expectedException \LogicException * @expectedExceptionMessage The SecurityBundle is not registered in your application. */