From 5aa4a3b64c132d115ebecfbda16acfcaa076c458 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 10 Nov 2015 11:42:06 +0100 Subject: [PATCH] Remove some more legacy code --- .../Security/User/EntityUserProvider.php | 6 +--- .../Resources/config/form_csrf.xml | 5 ---- .../Resources/config/validator.xml | 11 ------- .../Templating/Helper/RouterHelper.php | 18 ------------ .../EventListener/ValidationListenerTest.php | 29 +++---------------- .../Routing/RouteCollectionBuilder.php | 1 - src/Symfony/Component/Yaml/Inline.php | 5 +--- src/Symfony/Component/Yaml/Parser.php | 5 +--- .../Component/Yaml/Tests/InlineTest.php | 8 ++--- .../Component/Yaml/Tests/ParserTest.php | 16 ++-------- 10 files changed, 13 insertions(+), 91 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php b/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php index 692aae0127..aacdf3cb61 100644 --- a/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php +++ b/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php @@ -55,11 +55,7 @@ class EntityUserProvider implements UserProviderInterface $user = $this->repository->findOneBy(array($this->property => $username)); } else { if (!$this->repository instanceof UserLoaderInterface) { - if (!$this->repository instanceof UserProviderInterface) { - throw new \InvalidArgumentException(sprintf('The Doctrine repository "%s" must implement Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface.', get_class($this->repository))); - } - - @trigger_error('Implementing loadUserByUsername from Symfony\Component\Security\Core\User\UserProviderInterface is deprecated since version 2.8 and will be removed in 3.0. Implement the Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface instead.', E_USER_DEPRECATED); + throw new \InvalidArgumentException(sprintf('The Doctrine repository "%s" must implement Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface.', get_class($this->repository))); } $user = $this->repository->loadUserByUsername($username); diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/form_csrf.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/form_csrf.xml index c3e2558ae4..edc7bd412f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/form_csrf.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/form_csrf.xml @@ -5,11 +5,6 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> - - - The "%service_id%" service is deprecated since Symfony 2.4 and will be removed in 3.0. Use the "security.csrf.token_manager" service instead. - - diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.xml index 02c146408a..ac153f91b2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.xml @@ -32,17 +32,6 @@ %validator.mapping.cache.prefix% - - - - - %validator.mapping.cache.prefix% - - - - The "%service_id%" service is deprecated since Symfony 2.8 and will be removed in 3.0. - - diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/RouterHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/RouterHelper.php index 0445c79589..439910494f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/RouterHelper.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/RouterHelper.php @@ -33,24 +33,6 @@ class RouterHelper extends Helper $this->generator = $router; } - /** - * Generates a URL from the given parameters. - * - * @param string $name The name of the route - * @param mixed $parameters An array of parameters - * @param int $referenceType The type of reference (one of the constants in UrlGeneratorInterface) - * - * @return string The generated URL - * - * @see UrlGeneratorInterface - */ - public function generate($name, $parameters = array(), $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH) - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0. Use the "path" or "url" method instead.', E_USER_DEPRECATED); - - return $this->generator->generate($name, $parameters, $referenceType); - } - /** * Generates a URL reference (as an absolute or relative path) to the route with the given parameters. * diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/EventListener/ValidationListenerTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/EventListener/ValidationListenerTest.php index 570f26a83f..6859074c95 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/EventListener/ValidationListenerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/EventListener/ValidationListenerTest.php @@ -64,9 +64,9 @@ class ValidationListenerTest extends \PHPUnit_Framework_TestCase $this->params = array('foo' => 'bar'); } - private function getConstraintViolation($code = null, $constraint = null) + private function getConstraintViolation($code = null) { - return new ConstraintViolation($this->message, $this->messageTemplate, $this->params, null, 'prop.path', null, null, $code, $constraint); + return new ConstraintViolation($this->message, $this->messageTemplate, $this->params, null, 'prop.path', null, null, $code, new Form()); } private function getBuilder($name = 'name', $propertyPath = null, $dataClass = null) @@ -93,7 +93,7 @@ class ValidationListenerTest extends \PHPUnit_Framework_TestCase // More specific mapping tests can be found in ViolationMapperTest public function testMapViolation() { - $violation = $this->getConstraintViolation(null, new Form()); + $violation = $this->getConstraintViolation(); $form = $this->getForm('street'); $this->validator->expects($this->once()) @@ -109,28 +109,7 @@ class ValidationListenerTest extends \PHPUnit_Framework_TestCase public function testMapViolationAllowsNonSyncIfInvalid() { - $violation = $this->getConstraintViolation(Form::NOT_SYNCHRONIZED_ERROR, new Form()); - $form = $this->getForm('street'); - - $this->validator->expects($this->once()) - ->method('validate') - ->will($this->returnValue(array($violation))); - - $this->violationMapper->expects($this->once()) - ->method('mapViolation') - // pass true now - ->with($violation, $form, true); - - $this->listener->validateForm(new FormEvent($form, null)); - } - - public function testMapViolationAllowsNonSyncIfInvalidWithoutConstraintReference() - { - // constraint violations have no reference to the constraint if they are created by - // Symfony\Component\Validator\ExecutionContext - // which is deprecated in favor of - // Symfony\Component\Validator\Context\ExecutionContext - $violation = $this->getConstraintViolation(Form::NOT_SYNCHRONIZED_ERROR, null); + $violation = $this->getConstraintViolation(Form::NOT_SYNCHRONIZED_ERROR); $form = $this->getForm('street'); $this->validator->expects($this->once()) diff --git a/src/Symfony/Component/Routing/RouteCollectionBuilder.php b/src/Symfony/Component/Routing/RouteCollectionBuilder.php index 700ee37234..8c2c83aeb9 100644 --- a/src/Symfony/Component/Routing/RouteCollectionBuilder.php +++ b/src/Symfony/Component/Routing/RouteCollectionBuilder.php @@ -267,7 +267,6 @@ class RouteCollectionBuilder $route->setDefaults(array_merge($this->defaults, $route->getDefaults())); $route->setOptions(array_merge($this->options, $route->getOptions())); - // we're extra careful here to avoid re-setting deprecated _method and _scheme foreach ($this->requirements as $key => $val) { if (!$route->hasRequirement($key)) { $route->setRequirement($key, $val); diff --git a/src/Symfony/Component/Yaml/Inline.php b/src/Symfony/Component/Yaml/Inline.php index 65ee79e242..a08a37ec98 100644 --- a/src/Symfony/Component/Yaml/Inline.php +++ b/src/Symfony/Component/Yaml/Inline.php @@ -238,10 +238,7 @@ class Inline // a non-quoted string cannot start with @ or ` (reserved) nor with a scalar indicator (| or >) if ($output && ('@' === $output[0] || '`' === $output[0] || '|' === $output[0] || '>' === $output[0])) { - @trigger_error(sprintf('Not quoting a scalar starting with "%s" is deprecated since Symfony 2.8 and will throw a ParseException in 3.0.', $output[0]), E_USER_DEPRECATED); - - // to be thrown in 3.0 - // throw new ParseException(sprintf('The reserved indicator "%s" cannot start a plain scalar; you need to quote the scalar.', $output[0])); + throw new ParseException(sprintf('The reserved indicator "%s" cannot start a plain scalar; you need to quote the scalar.', $output[0])); } if ($evaluate) { diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index faa5821ef9..841b5ea35e 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -472,10 +472,7 @@ class Parser } if ('mapping' === $context && '"' !== $value[0] && "'" !== $value[0] && '[' !== $value[0] && '{' !== $value[0] && '!' !== $value[0] && false !== strpos($value, ': ')) { - @trigger_error(sprintf('Using a colon in an unquoted mapping value in line %d is deprecated since Symfony 2.8 and will throw a ParseException in 3.0.', $this->getRealCurrentLineNb() + 1), E_USER_DEPRECATED); - - // to be thrown in 3.0 - // throw new ParseException('A colon cannot be used in an unquoted mapping value.'); + throw new ParseException('A colon cannot be used in an unquoted mapping value.'); } try { diff --git a/src/Symfony/Component/Yaml/Tests/InlineTest.php b/src/Symfony/Component/Yaml/Tests/InlineTest.php index e98e05bbbd..ab541dade2 100644 --- a/src/Symfony/Component/Yaml/Tests/InlineTest.php +++ b/src/Symfony/Component/Yaml/Tests/InlineTest.php @@ -189,9 +189,9 @@ class InlineTest extends \PHPUnit_Framework_TestCase } /** - * @group legacy * @dataProvider getReservedIndicators - * throws \Symfony\Component\Yaml\Exception\ParseException in 3.0 + * @expectedException Symfony\Component\Yaml\Exception\ParseException + * @expectedExceptionMessage cannot start a plain scalar; you need to quote the scalar. */ public function testParseUnquotedScalarStartingWithReservedIndicator($indicator) { @@ -204,9 +204,9 @@ class InlineTest extends \PHPUnit_Framework_TestCase } /** - * @group legacy * @dataProvider getScalarIndicators - * throws \Symfony\Component\Yaml\Exception\ParseException in 3.0 + * @expectedException Symfony\Component\Yaml\Exception\ParseException + * @expectedExceptionMessage cannot start a plain scalar; you need to quote the scalar. */ public function testParseUnquotedScalarStartingWithScalarIndicator($indicator) { diff --git a/src/Symfony/Component/Yaml/Tests/ParserTest.php b/src/Symfony/Component/Yaml/Tests/ParserTest.php index e4c02d77b7..aa8650e0ca 100644 --- a/src/Symfony/Component/Yaml/Tests/ParserTest.php +++ b/src/Symfony/Component/Yaml/Tests/ParserTest.php @@ -785,8 +785,8 @@ EOF; } /** - * @group legacy - * throw ParseException in Symfony 3.0 + * @expectedException Symfony\Component\Yaml\Exception\ParseException + * @expectedExceptionMessage A colon cannot be used in an unquoted mapping value. */ public function testColonInMappingValueException() { @@ -794,19 +794,7 @@ EOF; foo: bar: baz EOF; - $deprecations = array(); - set_error_handler(function ($type, $msg) use (&$deprecations) { - if (E_USER_DEPRECATED === $type) { - $deprecations[] = $msg; - } - }); - $this->parser->parse($yaml); - - $this->assertCount(1, $deprecations); - $this->assertContains('Using a colon in an unquoted mapping value in line 1 is deprecated since Symfony 2.8 and will throw a ParseException in 3.0.', $deprecations[0]); - - restore_error_handler(); } }