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

Skip to content

Validator deprecation fixes #13338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jan 9, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ language: php

matrix:
include:
- php: 5.3.3
- php: 5.3
- php: 5.4
- php: 5.5
- php: 5.6
- php: 5.3.3
- php: 5.3
env: components=low
- php: 5.6
env: components=high
Expand Down
6 changes: 5 additions & 1 deletion autoload.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ class DeprecationErrorHandler
$class = isset($trace[$i]['object']) ? get_class($trace[$i]['object']) : $trace[$i]['class'];
$method = $trace[$i]['function'];

$type = 0 === strpos($method, 'testLegacy') || 0 === strpos($method, 'provideLegacy') || strpos($class, '\Legacy') ? 'legacy' : 'remaining';
$type =
0 === strpos($method, 'testLegacy')
|| 0 === strpos($method, 'provideLegacy')
|| strpos($class, '\Legacy')
? 'legacy' : 'remaining';

if ('legacy' === $type && 0 === (error_reporting() & E_USER_DEPRECATED)) {
@++$deprecations[$type]['Silenced']['count'];
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}
],
"require": {
"php": ">=5.3.3",
"php": ">=5.3.9",
"doctrine/common": "~2.3",
"twig/twig": "~1.12,>=1.12.3",
"psr/log": "~1.0"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Bridge\Doctrine\Validator\Constraints;

use Doctrine\Common\Persistence\ManagerRegistry;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
Expand Down Expand Up @@ -133,9 +134,16 @@ public function validate($entity, Constraint $constraint)

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

$this->buildViolation($constraint->message)
->atPath($errorPath)
->setInvalidValue($criteria[$fields[0]])
->addViolation();
if ($this->context instanceof ExecutionContextInterface) {
$this->context->buildViolation($constraint->message)
->atPath($errorPath)
->setInvalidValue($criteria[$fields[0]])
->addViolation();
} else {
$this->buildViolation($constraint->message)
->atPath($errorPath)
->setInvalidValue($criteria[$fields[0]])
->addViolation();
}
}
}
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Doctrine/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}
],
"require": {
"php": ">=5.3.3",
"php": ">=5.3.9",
"doctrine/common": "~2.3"
},
"require-dev": {
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Monolog/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}
],
"require": {
"php": ">=5.3.3",
"php": ">=5.3.9",
"monolog/monolog": "~1.11"
},
"require-dev": {
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Propel1/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}
],
"require": {
"php": ">=5.3.3",
"php": ">=5.3.9",
"symfony/http-foundation": "~2.0,>=2.0.5|~3.0.0",
"symfony/http-kernel": "~2.0,>=2.0.5|~3.0.0",
"symfony/form": "~2.3,>=2.3.8|~3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/ProxyManager/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}
],
"require": {
"php": ">=5.3.3",
"php": ">=5.3.9",
"symfony/dependency-injection": "~2.3|~3.0.0",
"ocramius/proxy-manager": "~0.4|~1.0"
},
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Swiftmailer/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}
],
"require": {
"php": ">=5.3.3",
"php": ">=5.3.9",
"swiftmailer/swiftmailer": ">=4.2.0,<6.0-dev"
},
"suggest": {
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Twig/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}
],
"require": {
"php": ">=5.3.3",
"php": ">=5.3.9",
"symfony/security-csrf": "~2.6|~3.0.0",
"twig/twig": "~1.13,>=1.13.1"
},
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/DebugBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}
],
"require": {
"php": ">=5.3.3",
"php": ">=5.3.9",
"symfony/http-kernel": "~2.6|~3.0.0",
"symfony/twig-bridge": "~2.6|~3.0.0",
"symfony/var-dumper": "~2.6|~3.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,9 +503,7 @@ private function addValidationSection(ArrayNodeDefinition $rootNode)
// API version already during container configuration
// (to adjust service classes etc.)
// See https://github.com/symfony/symfony/issues/11580
$v['validation']['api'] = PHP_VERSION_ID < 50309
? '2.4'
: '2.5-bc';
$v['validation']['api'] = '2.5-bc';

return $v;
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -744,19 +744,13 @@ private function registerValidationConfiguration(array $config, ContainerBuilder
$validatorBuilder->addMethodCall('setMetadataCache', array(new Reference($config['cache'])));
}

switch ($config['api']) {
case '2.4':
$api = Validation::API_VERSION_2_4;
break;
case '2.5':
$api = Validation::API_VERSION_2_5;
// the validation class needs to be changed only for the 2.5 api since the deprecated interface is
// set as the default interface
$container->setParameter('validator.class', 'Symfony\Component\Validator\Validator\ValidatorInterface');
break;
default:
$api = Validation::API_VERSION_2_5_BC;
break;
if ('2.5' === $config['api']) {
$api = Validation::API_VERSION_2_5;
} else {
// 2.4 is now the same as 2.5 BC
$api = Validation::API_VERSION_2_5_BC;
// the validation class needs to be changed for BC
$container->setParameter('validator.class', 'Symfony\Component\Validator\ValidatorInterface');
}

$validatorBuilder->addMethodCall('setApiVersion', array($api));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

<parameters>
<parameter key="validator.class">Symfony\Component\Validator\ValidatorInterface</parameter>
<parameter key="validator.class">Symfony\Component\Validator\Validator\ValidatorInterface</parameter>
<parameter key="validator.builder.class">Symfony\Component\Validator\ValidatorBuilderInterface</parameter>
<parameter key="validator.builder.factory.class">Symfony\Component\Validator\Validation</parameter>
<parameter key="validator.mapping.cache.apc.class">Symfony\Component\Validator\Mapping\Cache\ApcCache</parameter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ protected static function getBundleDefaultConfig()
'static_method' => array('loadValidatorMetadata'),
'translation_domain' => 'validators',
'strict_email' => false,
'api' => PHP_VERSION_ID < 50309 ? '2.4' : '2.5-bc',
'api' => '2.5-bc',
),
'annotations' => array(
'cache' => 'file',
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,7 @@ public function testValidation()
$this->assertSame('setMetadataCache', $calls[5][0]);
$this->assertEquals(array(new Reference('validator.mapping.cache.apc')), $calls[5][1]);
$this->assertSame('setApiVersion', $calls[6][0]);

if (PHP_VERSION_ID < 50309) {
$this->assertEquals(array(Validation::API_VERSION_2_4), $calls[6][1]);
} else {
$this->assertEquals(array(Validation::API_VERSION_2_5_BC), $calls[6][1]);
}
$this->assertEquals(array(Validation::API_VERSION_2_5_BC), $calls[6][1]);
}

public function testFullyConfiguredValidationService()
Expand Down Expand Up @@ -387,22 +382,6 @@ public function testValidationNoStaticMethod()
// no cache, no annotations, no static methods
}

public function testValidation2Dot4Api()
{
$container = $this->createContainerFromFile('validation_2_4_api');

$calls = $container->getDefinition('validator.builder')->getMethodCalls();

$this->assertCount(6, $calls);
$this->assertSame('addXmlMappings', $calls[3][0]);
$this->assertSame('addMethodMapping', $calls[4][0]);
$this->assertSame(array('loadValidatorMetadata'), $calls[4][1]);
$this->assertSame('setApiVersion', $calls[5][0]);
$this->assertSame(array(Validation::API_VERSION_2_4), $calls[5][1]);
$this->assertSame('Symfony\Component\Validator\ValidatorInterface', $container->getParameter('validator.class'));
// no cache, no annotations
}

public function testValidation2Dot5Api()
{
$container = $this->createContainerFromFile('validation_2_5_api');
Expand Down Expand Up @@ -448,11 +427,7 @@ public function testValidationImplicitApi()
$this->assertSame('setApiVersion', $calls[5][0]);
// no cache, no annotations

if (PHP_VERSION_ID < 50309) {
$this->assertSame(array(Validation::API_VERSION_2_4), $calls[5][1]);
} else {
$this->assertSame(array(Validation::API_VERSION_2_5_BC), $calls[5][1]);
}
$this->assertSame(array(Validation::API_VERSION_2_5_BC), $calls[5][1]);
}

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

if (PHP_VERSION_ID < 50309) {
$this->assertSame(array(Validation::API_VERSION_2_4), $calls[5][1]);
} else {
$this->assertSame(array(Validation::API_VERSION_2_5_BC), $calls[5][1]);
}
$this->assertSame(array(Validation::API_VERSION_2_5_BC), $calls[5][1]);
}

public function testFormsCanBeEnabledWithoutCsrfProtection()
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/FrameworkBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}
],
"require": {
"php": ">=5.3.3",
"php": ">=5.3.9",
"symfony/dependency-injection" : "~2.6,>=2.6.2",
"symfony/config" : "~2.4",
"symfony/event-dispatcher": "~2.5|~3.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ public function testRoutingErrorIsNotExposedForProtectedResourceWhenAnonymous($c
*/
public function testRoutingErrorIsExposedWhenNotProtected($config)
{
if ('\\' === DIRECTORY_SEPARATOR && PHP_VERSION_ID < 50309) {
$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');
}

$client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config));
$client->insulate();
$client->request('GET', '/unprotected_resource');
Expand All @@ -46,10 +42,6 @@ public function testRoutingErrorIsExposedWhenNotProtected($config)
*/
public function testRoutingErrorIsNotExposedForProtectedResourceWhenLoggedInWithInsufficientRights($config)
{
if ('\\' === DIRECTORY_SEPARATOR && PHP_VERSION_ID < 50309) {
$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');
}

$client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config));
$client->insulate();

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/SecurityBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}
],
"require": {
"php": ">=5.3.3",
"php": ">=5.3.9",
"symfony/security": "~2.7|~3.0.0",
"symfony/http-kernel": "~2.2|~3.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/TwigBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}
],
"require": {
"php": ">=5.3.3",
"php": ">=5.3.9",
"symfony/twig-bridge": "~2.6|~3.0.0",
"symfony/http-foundation": "~2.5|~3.0.0",
"symfony/http-kernel": "~2.3.24|~2.5.9|~2.6,>=2.6.2|~3.0.0"
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/WebProfilerBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}
],
"require": {
"php": ">=5.3.3",
"php": ">=5.3.9",
"symfony/http-kernel": "~2.4|~3.0.0",
"symfony/routing": "~2.2|~3.0.0",
"symfony/twig-bridge": "~2.2|~3.0.0"
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/BrowserKit/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}
],
"require": {
"php": ">=5.3.3",
"php": ">=5.3.9",
"symfony/dom-crawler": "~2.0,>=2.0.5|~3.0.0"
},
"require-dev": {
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/ClassLoader/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
],
"minimum-stability": "dev",
"require": {
"php": ">=5.3.3"
"php": ">=5.3.9"
},
"require-dev": {
"symfony/finder": "~2.0,>=2.0.5|~3.0.0"
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Config/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}
],
"require": {
"php": ">=5.3.3",
"php": ">=5.3.9",
"symfony/filesystem": "~2.3|~3.0.0"
},
"autoload": {
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Console/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}
],
"require": {
"php": ">=5.3.3"
"php": ">=5.3.9"
},
"require-dev": {
"symfony/event-dispatcher": "~2.1|~3.0.0",
Expand Down
Loading