Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 43c0565

Browse files
committed
bug #13338 Validator deprecation fixes (fabpot)
This PR was merged into the 2.7 branch. Discussion ---------- Validator deprecation fixes | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a Commits ------- a34220e [Validator] always use the lazy loading metadata factory 818ca58 [Validator] removed usage of deprecated getMessageParameters() and getMessagePluralization() in unit tests c6f1f69 [Validator] fixed deprecation notices for BuildViolation() calls in constraints fb3f9d2 [Validator] fixed usage of deprecate Validator features 91606b5 [Validator] removed obsolete code 5aa44ee removed the Validator BC layer for PHP < 5.3.9 a4139c0 removed code for PHP < 5.3.9 6dc8979 bumped min PHP version to 5.3.9
2 parents 9a6f52e + a34220e commit 43c0565

File tree

170 files changed

+1328
-2197
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

170 files changed

+1328
-2197
lines changed

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@ language: php
22

33
matrix:
44
include:
5-
- php: 5.3.3
65
- php: 5.3
76
- php: 5.4
87
- php: 5.5
98
- php: 5.6
10-
- php: 5.3.3
9+
- php: 5.3
1110
env: components=low
1211
- php: 5.6
1312
env: components=high

autoload.php.dist

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ class DeprecationErrorHandler
4444
$class = isset($trace[$i]['object']) ? get_class($trace[$i]['object']) : $trace[$i]['class'];
4545
$method = $trace[$i]['function'];
4646

47-
$type = 0 === strpos($method, 'testLegacy') || 0 === strpos($method, 'provideLegacy') || strpos($class, '\Legacy') ? 'legacy' : 'remaining';
47+
$type =
48+
0 === strpos($method, 'testLegacy')
49+
|| 0 === strpos($method, 'provideLegacy')
50+
|| strpos($class, '\Legacy')
51+
? 'legacy' : 'remaining';
4852

4953
if ('legacy' === $type && 0 === (error_reporting() & E_USER_DEPRECATED)) {
5054
@++$deprecations[$type]['Silenced']['count'];

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
}
1717
],
1818
"require": {
19-
"php": ">=5.3.3",
19+
"php": ">=5.3.9",
2020
"doctrine/common": "~2.3",
2121
"twig/twig": "~1.12,>=1.12.3",
2222
"psr/log": "~1.0"

src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/LegacyUniqueEntityValidator2Dot4ApiTest.php

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bridge\Doctrine\Validator\Constraints;
1313

1414
use Doctrine\Common\Persistence\ManagerRegistry;
15+
use Symfony\Component\Validator\Context\ExecutionContextInterface;
1516
use Symfony\Component\Validator\Constraint;
1617
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
1718
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
@@ -133,9 +134,16 @@ public function validate($entity, Constraint $constraint)
133134

134135
$errorPath = null !== $constraint->errorPath ? $constraint->errorPath : $fields[0];
135136

136-
$this->buildViolation($constraint->message)
137-
->atPath($errorPath)
138-
->setInvalidValue($criteria[$fields[0]])
139-
->addViolation();
137+
if ($this->context instanceof ExecutionContextInterface) {
138+
$this->context->buildViolation($constraint->message)
139+
->atPath($errorPath)
140+
->setInvalidValue($criteria[$fields[0]])
141+
->addViolation();
142+
} else {
143+
$this->buildViolation($constraint->message)
144+
->atPath($errorPath)
145+
->setInvalidValue($criteria[$fields[0]])
146+
->addViolation();
147+
}
140148
}
141149
}

src/Symfony/Bridge/Doctrine/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
}
1717
],
1818
"require": {
19-
"php": ">=5.3.3",
19+
"php": ">=5.3.9",
2020
"doctrine/common": "~2.3"
2121
},
2222
"require-dev": {

src/Symfony/Bridge/Monolog/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
}
1717
],
1818
"require": {
19-
"php": ">=5.3.3",
19+
"php": ">=5.3.9",
2020
"monolog/monolog": "~1.11"
2121
},
2222
"require-dev": {

src/Symfony/Bridge/Propel1/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
}
1717
],
1818
"require": {
19-
"php": ">=5.3.3",
19+
"php": ">=5.3.9",
2020
"symfony/http-foundation": "~2.0,>=2.0.5|~3.0.0",
2121
"symfony/http-kernel": "~2.0,>=2.0.5|~3.0.0",
2222
"symfony/form": "~2.3,>=2.3.8|~3.0.0",

src/Symfony/Bridge/ProxyManager/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
}
1717
],
1818
"require": {
19-
"php": ">=5.3.3",
19+
"php": ">=5.3.9",
2020
"symfony/dependency-injection": "~2.3|~3.0.0",
2121
"ocramius/proxy-manager": "~0.4|~1.0"
2222
},

src/Symfony/Bridge/Swiftmailer/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
}
1717
],
1818
"require": {
19-
"php": ">=5.3.3",
19+
"php": ">=5.3.9",
2020
"swiftmailer/swiftmailer": ">=4.2.0,<6.0-dev"
2121
},
2222
"suggest": {

src/Symfony/Bridge/Twig/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
}
1717
],
1818
"require": {
19-
"php": ">=5.3.3",
19+
"php": ">=5.3.9",
2020
"symfony/security-csrf": "~2.6|~3.0.0",
2121
"twig/twig": "~1.13,>=1.13.1"
2222
},

src/Symfony/Bundle/DebugBundle/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
}
1717
],
1818
"require": {
19-
"php": ">=5.3.3",
19+
"php": ">=5.3.9",
2020
"symfony/http-kernel": "~2.6|~3.0.0",
2121
"symfony/twig-bridge": "~2.6|~3.0.0",
2222
"symfony/var-dumper": "~2.6|~3.0.0"

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -503,9 +503,7 @@ private function addValidationSection(ArrayNodeDefinition $rootNode)
503503
// API version already during container configuration
504504
// (to adjust service classes etc.)
505505
// See https://github.com/symfony/symfony/issues/11580
506-
$v['validation']['api'] = PHP_VERSION_ID < 50309
507-
? '2.4'
508-
: '2.5-bc';
506+
$v['validation']['api'] = '2.5-bc';
509507

510508
return $v;
511509
})

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -744,19 +744,13 @@ private function registerValidationConfiguration(array $config, ContainerBuilder
744744
$validatorBuilder->addMethodCall('setMetadataCache', array(new Reference($config['cache'])));
745745
}
746746

747-
switch ($config['api']) {
748-
case '2.4':
749-
$api = Validation::API_VERSION_2_4;
750-
break;
751-
case '2.5':
752-
$api = Validation::API_VERSION_2_5;
753-
// the validation class needs to be changed only for the 2.5 api since the deprecated interface is
754-
// set as the default interface
755-
$container->setParameter('validator.class', 'Symfony\Component\Validator\Validator\ValidatorInterface');
756-
break;
757-
default:
758-
$api = Validation::API_VERSION_2_5_BC;
759-
break;
747+
if ('2.5' === $config['api']) {
748+
$api = Validation::API_VERSION_2_5;
749+
} else {
750+
// 2.4 is now the same as 2.5 BC
751+
$api = Validation::API_VERSION_2_5_BC;
752+
// the validation class needs to be changed for BC
753+
$container->setParameter('validator.class', 'Symfony\Component\Validator\ValidatorInterface');
760754
}
761755

762756
$validatorBuilder->addMethodCall('setApiVersion', array($api));

src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
66

77
<parameters>
8-
<parameter key="validator.class">Symfony\Component\Validator\ValidatorInterface</parameter>
8+
<parameter key="validator.class">Symfony\Component\Validator\Validator\ValidatorInterface</parameter>
99
<parameter key="validator.builder.class">Symfony\Component\Validator\ValidatorBuilderInterface</parameter>
1010
<parameter key="validator.builder.factory.class">Symfony\Component\Validator\Validation</parameter>
1111
<parameter key="validator.mapping.cache.apc.class">Symfony\Component\Validator\Mapping\Cache\ApcCache</parameter>

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ protected static function getBundleDefaultConfig()
131131
'static_method' => array('loadValidatorMetadata'),
132132
'translation_domain' => 'validators',
133133
'strict_email' => false,
134-
'api' => PHP_VERSION_ID < 50309 ? '2.4' : '2.5-bc',
134+
'api' => '2.5-bc',
135135
),
136136
'annotations' => array(
137137
'cache' => 'file',

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_2_4_api.php

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_2_4_api.xml

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_2_4_api.yml

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -294,12 +294,7 @@ public function testValidation()
294294
$this->assertSame('setMetadataCache', $calls[5][0]);
295295
$this->assertEquals(array(new Reference('validator.mapping.cache.apc')), $calls[5][1]);
296296
$this->assertSame('setApiVersion', $calls[6][0]);
297-
298-
if (PHP_VERSION_ID < 50309) {
299-
$this->assertEquals(array(Validation::API_VERSION_2_4), $calls[6][1]);
300-
} else {
301-
$this->assertEquals(array(Validation::API_VERSION_2_5_BC), $calls[6][1]);
302-
}
297+
$this->assertEquals(array(Validation::API_VERSION_2_5_BC), $calls[6][1]);
303298
}
304299

305300
public function testFullyConfiguredValidationService()
@@ -387,22 +382,6 @@ public function testValidationNoStaticMethod()
387382
// no cache, no annotations, no static methods
388383
}
389384

390-
public function testValidation2Dot4Api()
391-
{
392-
$container = $this->createContainerFromFile('validation_2_4_api');
393-
394-
$calls = $container->getDefinition('validator.builder')->getMethodCalls();
395-
396-
$this->assertCount(6, $calls);
397-
$this->assertSame('addXmlMappings', $calls[3][0]);
398-
$this->assertSame('addMethodMapping', $calls[4][0]);
399-
$this->assertSame(array('loadValidatorMetadata'), $calls[4][1]);
400-
$this->assertSame('setApiVersion', $calls[5][0]);
401-
$this->assertSame(array(Validation::API_VERSION_2_4), $calls[5][1]);
402-
$this->assertSame('Symfony\Component\Validator\ValidatorInterface', $container->getParameter('validator.class'));
403-
// no cache, no annotations
404-
}
405-
406385
public function testValidation2Dot5Api()
407386
{
408387
$container = $this->createContainerFromFile('validation_2_5_api');
@@ -448,11 +427,7 @@ public function testValidationImplicitApi()
448427
$this->assertSame('setApiVersion', $calls[5][0]);
449428
// no cache, no annotations
450429

451-
if (PHP_VERSION_ID < 50309) {
452-
$this->assertSame(array(Validation::API_VERSION_2_4), $calls[5][1]);
453-
} else {
454-
$this->assertSame(array(Validation::API_VERSION_2_5_BC), $calls[5][1]);
455-
}
430+
$this->assertSame(array(Validation::API_VERSION_2_5_BC), $calls[5][1]);
456431
}
457432

458433
/**
@@ -472,11 +447,7 @@ public function testValidationAutoApi()
472447
$this->assertSame('setApiVersion', $calls[5][0]);
473448
// no cache, no annotations
474449

475-
if (PHP_VERSION_ID < 50309) {
476-
$this->assertSame(array(Validation::API_VERSION_2_4), $calls[5][1]);
477-
} else {
478-
$this->assertSame(array(Validation::API_VERSION_2_5_BC), $calls[5][1]);
479-
}
450+
$this->assertSame(array(Validation::API_VERSION_2_5_BC), $calls[5][1]);
480451
}
481452

482453
public function testFormsCanBeEnabledWithoutCsrfProtection()

src/Symfony/Bundle/FrameworkBundle/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
}
1717
],
1818
"require": {
19-
"php": ">=5.3.3",
19+
"php": ">=5.3.9",
2020
"symfony/dependency-injection" : "~2.6,>=2.6.2",
2121
"symfony/config" : "~2.4",
2222
"symfony/event-dispatcher": "~2.5|~3.0.0",

src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityRoutingIntegrationTest.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ public function testRoutingErrorIsNotExposedForProtectedResourceWhenAnonymous($c
3030
*/
3131
public function testRoutingErrorIsExposedWhenNotProtected($config)
3232
{
33-
if ('\\' === DIRECTORY_SEPARATOR && PHP_VERSION_ID < 50309) {
34-
$this->markTestSkipped('Test hangs on Windows & PHP due to https://bugs.php.net/bug.php?id=60120 fixed in http://svn.php.net/viewvc?view=revision&revision=318366');
35-
}
36-
3733
$client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config));
3834
$client->insulate();
3935
$client->request('GET', '/unprotected_resource');
@@ -46,10 +42,6 @@ public function testRoutingErrorIsExposedWhenNotProtected($config)
4642
*/
4743
public function testRoutingErrorIsNotExposedForProtectedResourceWhenLoggedInWithInsufficientRights($config)
4844
{
49-
if ('\\' === DIRECTORY_SEPARATOR && PHP_VERSION_ID < 50309) {
50-
$this->markTestSkipped('Test hangs on Windows & PHP due to https://bugs.php.net/bug.php?id=60120 fixed in http://svn.php.net/viewvc?view=revision&revision=318366');
51-
}
52-
5345
$client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config));
5446
$client->insulate();
5547

src/Symfony/Bundle/SecurityBundle/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
}
1717
],
1818
"require": {
19-
"php": ">=5.3.3",
19+
"php": ">=5.3.9",
2020
"symfony/security": "~2.7|~3.0.0",
2121
"symfony/http-kernel": "~2.2|~3.0.0"
2222
},

src/Symfony/Bundle/TwigBundle/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
}
1717
],
1818
"require": {
19-
"php": ">=5.3.3",
19+
"php": ">=5.3.9",
2020
"symfony/twig-bridge": "~2.6|~3.0.0",
2121
"symfony/http-foundation": "~2.5|~3.0.0",
2222
"symfony/http-kernel": "~2.3.24|~2.5.9|~2.6,>=2.6.2|~3.0.0"

src/Symfony/Bundle/WebProfilerBundle/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
}
1717
],
1818
"require": {
19-
"php": ">=5.3.3",
19+
"php": ">=5.3.9",
2020
"symfony/http-kernel": "~2.4|~3.0.0",
2121
"symfony/routing": "~2.2|~3.0.0",
2222
"symfony/twig-bridge": "~2.2|~3.0.0"

src/Symfony/Component/BrowserKit/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
}
1717
],
1818
"require": {
19-
"php": ">=5.3.3",
19+
"php": ">=5.3.9",
2020
"symfony/dom-crawler": "~2.0,>=2.0.5|~3.0.0"
2121
},
2222
"require-dev": {

src/Symfony/Component/ClassLoader/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
],
1818
"minimum-stability": "dev",
1919
"require": {
20-
"php": ">=5.3.3"
20+
"php": ">=5.3.9"
2121
},
2222
"require-dev": {
2323
"symfony/finder": "~2.0,>=2.0.5|~3.0.0"

src/Symfony/Component/Config/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
}
1717
],
1818
"require": {
19-
"php": ">=5.3.3",
19+
"php": ">=5.3.9",
2020
"symfony/filesystem": "~2.3|~3.0.0"
2121
},
2222
"autoload": {

src/Symfony/Component/Console/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
}
1717
],
1818
"require": {
19-
"php": ">=5.3.3"
19+
"php": ">=5.3.9"
2020
},
2121
"require-dev": {
2222
"symfony/event-dispatcher": "~2.1|~3.0.0",

0 commit comments

Comments
 (0)