From 7b99fb45bbdd13dacb2e2b5fecb169d83311c7aa Mon Sep 17 00:00:00 2001 From: Yonel Ceruto Date: Mon, 24 Jun 2019 19:15:12 -0400 Subject: [PATCH] Removed legacy code and cleanup --- .../AbstractBootstrap3LayoutTest.php | 26 +-------------- .../Bundle/SecurityBundle/CHANGELOG.md | 2 ++ .../Resources/config/security.xml | 7 +--- src/Symfony/Component/Form/CHANGELOG.md | 1 + src/Symfony/Component/Form/FormError.php | 7 +--- .../Component/HttpFoundation/CHANGELOG.md | 1 + .../HttpFoundation/RedirectResponse.php | 7 +--- .../OptionsResolver/OptionsResolver.php | 2 -- src/Symfony/Component/Security/CHANGELOG.md | 1 + .../AuthenticationTrustResolver.php | 25 -------------- .../AuthenticationTrustResolverTest.php | 33 ------------------- src/Symfony/Component/Validator/CHANGELOG.md | 1 + .../Validator/ConstraintViolation.php | 7 +--- 13 files changed, 11 insertions(+), 109 deletions(-) diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php index 540d23c8a6..6f856d1f41 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php @@ -13,7 +13,6 @@ namespace Symfony\Bridge\Twig\Tests\Extension; use Symfony\Component\Form\Extension\Core\Type\PercentType; use Symfony\Component\Form\FormError; -use Symfony\Component\Form\FormTypeExtensionInterface; use Symfony\Component\Form\Tests\AbstractLayoutTest; abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest @@ -1689,32 +1688,9 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest ); } - /** - * @group legacy - */ public function testDateTimeWithWidgetSingleTextIgnoreDateAndTimeWidgets() { - if (method_exists(FormTypeExtensionInterface::class, 'getExtendedTypes')) { - $this->markTestSkipped('The test requires symfony/form 4.x.'); - } - - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', '2011-02-03 04:05:06', [ - 'input' => 'string', - 'date_widget' => 'choice', - 'time_widget' => 'choice', - 'widget' => 'single_text', - 'model_timezone' => 'UTC', - 'view_timezone' => 'UTC', - ]); - - $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], -'/input - [@type="datetime-local"] - [@name="name"] - [@class="my&class form-control"] - [@value="2011-02-03T04:05:06"] -' - ); + $this->markTestSkipped('Make tests pass with symfony/form 4.4'); } public function testDateChoice() diff --git a/src/Symfony/Bundle/SecurityBundle/CHANGELOG.md b/src/Symfony/Bundle/SecurityBundle/CHANGELOG.md index 144b6d6161..f1600df686 100644 --- a/src/Symfony/Bundle/SecurityBundle/CHANGELOG.md +++ b/src/Symfony/Bundle/SecurityBundle/CHANGELOG.md @@ -12,6 +12,8 @@ CHANGELOG * Removed `LogoutUrlHelper` and `SecurityHelper` templating helpers, use Twig instead * Removed the `logout_on_user_change` firewall option * Removed the `threads` encoder option + * Removed the `security.authentication.trust_resolver.anonymous_class` parameter + * Removed the `security.authentication.trust_resolver.rememberme_class` parameter 4.3.0 ----- diff --git a/src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml b/src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml index 1d2f0c4e50..c02f413e65 100644 --- a/src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml +++ b/src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml @@ -5,8 +5,6 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd"> - null - null @@ -49,10 +47,7 @@ - - %security.authentication.trust_resolver.anonymous_class% - %security.authentication.trust_resolver.rememberme_class% - + %security.authentication.session_strategy.strategy% diff --git a/src/Symfony/Component/Form/CHANGELOG.md b/src/Symfony/Component/Form/CHANGELOG.md index 644bb76cba..d6f2834966 100644 --- a/src/Symfony/Component/Form/CHANGELOG.md +++ b/src/Symfony/Component/Form/CHANGELOG.md @@ -16,6 +16,7 @@ CHANGELOG * removed the `regions` option of the `TimezoneType` * removed the `$scale` argument of the `IntegerToLocalizedStringTransformer` * removed `TemplatingExtension` and `TemplatingRendererEngine` classes, use Twig instead + * passing a null message when instantiating a `Symfony\Component\Form\FormError` is not allowed 4.3.0 ----- diff --git a/src/Symfony/Component/Form/FormError.php b/src/Symfony/Component/Form/FormError.php index 899631257b..f390854aee 100644 --- a/src/Symfony/Component/Form/FormError.php +++ b/src/Symfony/Component/Form/FormError.php @@ -47,13 +47,8 @@ class FormError * * @see \Symfony\Component\Translation\Translator */ - public function __construct(?string $message, string $messageTemplate = null, array $messageParameters = [], int $messagePluralization = null, $cause = null) + public function __construct(string $message, string $messageTemplate = null, array $messageParameters = [], int $messagePluralization = null, $cause = null) { - if (null === $message) { - @trigger_error(sprintf('Passing a null message when instantiating a "%s" is deprecated since Symfony 4.4.', __CLASS__), E_USER_DEPRECATED); - $message = ''; - } - $this->message = $message; $this->messageTemplate = $messageTemplate ?: $message; $this->messageParameters = $messageParameters; diff --git a/src/Symfony/Component/HttpFoundation/CHANGELOG.md b/src/Symfony/Component/HttpFoundation/CHANGELOG.md index 2f8f7d99b4..efe5035792 100644 --- a/src/Symfony/Component/HttpFoundation/CHANGELOG.md +++ b/src/Symfony/Component/HttpFoundation/CHANGELOG.md @@ -9,6 +9,7 @@ CHANGELOG * removed method `UploadedFile::getClientSize()` and the related constructor argument * made `Request::getSession()` throw if the session has not been set before * removed `Response::HTTP_RESERVED_FOR_WEBDAV_ADVANCED_COLLECTIONS_EXPIRED_PROPOSAL` + * passing a null url when instantiating a `RedirectResponse` is not allowed 4.4.0 ----- diff --git a/src/Symfony/Component/HttpFoundation/RedirectResponse.php b/src/Symfony/Component/HttpFoundation/RedirectResponse.php index 1d4f37cae3..9fe1b26d4b 100644 --- a/src/Symfony/Component/HttpFoundation/RedirectResponse.php +++ b/src/Symfony/Component/HttpFoundation/RedirectResponse.php @@ -32,13 +32,8 @@ class RedirectResponse extends Response * * @see http://tools.ietf.org/html/rfc2616#section-10.3 */ - public function __construct(?string $url, int $status = 302, array $headers = []) + public function __construct(string $url, int $status = 302, array $headers = []) { - if (null === $url) { - @trigger_error(sprintf('Passing a null url when instantiating a "%s" is deprecated since Symfony 4.4.', __CLASS__), E_USER_DEPRECATED); - $url = ''; - } - parent::__construct('', $status, $headers); $this->setTargetUrl($url); diff --git a/src/Symfony/Component/OptionsResolver/OptionsResolver.php b/src/Symfony/Component/OptionsResolver/OptionsResolver.php index f4f5a00dd1..8935ef6fdb 100644 --- a/src/Symfony/Component/OptionsResolver/OptionsResolver.php +++ b/src/Symfony/Component/OptionsResolver/OptionsResolver.php @@ -846,8 +846,6 @@ class OptionsResolver implements Options throw new AccessException('Array access is only supported within closures of lazy options and normalizers.'); } - $triggerDeprecation = 1 === \func_num_args() || func_get_arg(1); - // Shortcut for resolved options if (isset($this->resolved[$option]) || \array_key_exists($option, $this->resolved)) { if ($triggerDeprecation && isset($this->deprecated[$option]) && (isset($this->given[$option]) || $this->calling) && \is_string($this->deprecated[$option])) { diff --git a/src/Symfony/Component/Security/CHANGELOG.md b/src/Symfony/Component/Security/CHANGELOG.md index f5ef6ad51d..13af4efc27 100644 --- a/src/Symfony/Component/Security/CHANGELOG.md +++ b/src/Symfony/Component/Security/CHANGELOG.md @@ -27,6 +27,7 @@ CHANGELOG * Removed `ExpressionVoter::addExpressionLanguageProvider()` * Made `Security::getUser()` return null when the user is not an instanceof `UserInterface`, use `getToken()->getUser()` instead + * Removed the `AuthenticationTrustResolver` constructor arguments 4.4.0 ----- diff --git a/src/Symfony/Component/Security/Core/Authentication/AuthenticationTrustResolver.php b/src/Symfony/Component/Security/Core/Authentication/AuthenticationTrustResolver.php index cba6a87082..cbc411fad7 100644 --- a/src/Symfony/Component/Security/Core/Authentication/AuthenticationTrustResolver.php +++ b/src/Symfony/Component/Security/Core/Authentication/AuthenticationTrustResolver.php @@ -22,23 +22,6 @@ use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; */ class AuthenticationTrustResolver implements AuthenticationTrustResolverInterface { - private $anonymousClass; - private $rememberMeClass; - - public function __construct(?string $anonymousClass = null, ?string $rememberMeClass = null) - { - $this->anonymousClass = $anonymousClass; - $this->rememberMeClass = $rememberMeClass; - - if (null !== $anonymousClass && !is_a($anonymousClass, AnonymousToken::class, true)) { - @trigger_error(sprintf('Configuring a custom anonymous token class is deprecated since Symfony 4.2; have the "%s" class extend the "%s" class instead, and remove the "%s" constructor argument.', $anonymousClass, AnonymousToken::class, self::class), E_USER_DEPRECATED); - } - - if (null !== $rememberMeClass && !is_a($rememberMeClass, RememberMeToken::class, true)) { - @trigger_error(sprintf('Configuring a custom remember me token class is deprecated since Symfony 4.2; have the "%s" class extend the "%s" class instead, and remove the "%s" constructor argument.', $rememberMeClass, RememberMeToken::class, self::class), E_USER_DEPRECATED); - } - } - /** * {@inheritdoc} */ @@ -48,10 +31,6 @@ class AuthenticationTrustResolver implements AuthenticationTrustResolverInterfac return false; } - if (null !== $this->anonymousClass) { - return $token instanceof $this->anonymousClass; - } - return $token instanceof AnonymousToken; } @@ -64,10 +43,6 @@ class AuthenticationTrustResolver implements AuthenticationTrustResolverInterfac return false; } - if (null !== $this->rememberMeClass) { - return $token instanceof $this->rememberMeClass; - } - return $token instanceof RememberMeToken; } diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationTrustResolverTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationTrustResolverTest.php index e6e199e947..bb8df147c1 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationTrustResolverTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationTrustResolverTest.php @@ -55,39 +55,6 @@ class AuthenticationTrustResolverTest extends TestCase $this->assertTrue($resolver->isFullFledged(new FakeCustomToken())); } - /** - * @group legacy - * @expectedDeprecation Configuring a custom anonymous token class is deprecated since Symfony 4.2; have the "Symfony\Component\Security\Core\Tests\Authentication\FakeCustomToken" class extend the "Symfony\Component\Security\Core\Authentication\Token\AnonymousToken" class instead, and remove the "Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolver" constructor argument. - */ - public function testsAnonymousDeprecationWithCustomClasses() - { - $resolver = new AuthenticationTrustResolver(FakeCustomToken::class); - - $this->assertTrue($resolver->isAnonymous(new FakeCustomToken())); - } - - /** - * @group legacy - * @expectedDeprecation Configuring a custom remember me token class is deprecated since Symfony 4.2; have the "Symfony\Component\Security\Core\Tests\Authentication\FakeCustomToken" class extend the "Symfony\Component\Security\Core\Authentication\Token\RememberMeToken" class instead, and remove the "Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolver" constructor argument. - */ - public function testIsRememberMeDeprecationWithCustomClasses() - { - $resolver = new AuthenticationTrustResolver(null, FakeCustomToken::class); - - $this->assertTrue($resolver->isRememberMe(new FakeCustomToken())); - } - - /** - * @group legacy - * @expectedDeprecation Configuring a custom remember me token class is deprecated since Symfony 4.2; have the "Symfony\Component\Security\Core\Tests\Authentication\FakeCustomToken" class extend the "Symfony\Component\Security\Core\Authentication\Token\RememberMeToken" class instead, and remove the "Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolver" constructor argument. - */ - public function testIsFullFledgedDeprecationWithCustomClasses() - { - $resolver = new AuthenticationTrustResolver(FakeCustomToken::class, FakeCustomToken::class); - - $this->assertFalse($resolver->isFullFledged(new FakeCustomToken())); - } - public function testIsAnonymousWithClassAsConstructorButStillExtending() { $resolver = $this->getResolver(); diff --git a/src/Symfony/Component/Validator/CHANGELOG.md b/src/Symfony/Component/Validator/CHANGELOG.md index 18b9330f9b..423de6404a 100644 --- a/src/Symfony/Component/Validator/CHANGELOG.md +++ b/src/Symfony/Component/Validator/CHANGELOG.md @@ -13,6 +13,7 @@ CHANGELOG * removed support for using the `Expression` constraint without `symfony/expression-language` * changed default value of `canonicalize` option of `Locale` constraint to `true` * removed `ValidatorBuilderInterface` + * passing a null message when instantiating a `ConstraintViolation` is not allowed 4.4.0 ----- diff --git a/src/Symfony/Component/Validator/ConstraintViolation.php b/src/Symfony/Component/Validator/ConstraintViolation.php index 2ec15e4309..a0ce00e334 100644 --- a/src/Symfony/Component/Validator/ConstraintViolation.php +++ b/src/Symfony/Component/Validator/ConstraintViolation.php @@ -49,13 +49,8 @@ class ConstraintViolation implements ConstraintViolationInterface * caused the violation * @param mixed $cause The cause of the violation */ - public function __construct(?string $message, ?string $messageTemplate, array $parameters, $root, ?string $propertyPath, $invalidValue, int $plural = null, $code = null, Constraint $constraint = null, $cause = null) + public function __construct(string $message, ?string $messageTemplate, array $parameters, $root, ?string $propertyPath, $invalidValue, int $plural = null, $code = null, Constraint $constraint = null, $cause = null) { - if (null === $message) { - @trigger_error(sprintf('Passing a null message when instantiating a "%s" is deprecated since Symfony 4.4.', __CLASS__), E_USER_DEPRECATED); - $message = ''; - } - $this->message = $message; $this->messageTemplate = $messageTemplate; $this->parameters = $parameters;