minor #15687 [2.7] Clean deprecated interfaces (nicolas-grekas)

This PR was merged into the 2.7 branch.

Discussion
----------

[2.7] Clean deprecated interfaces

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Commits
-------

e49739c [2.7] Clean deprecated interfaces
This commit is contained in:
Fabien Potencier 2015-09-06 10:30:54 +02:00
commit 22c5964a3c
20 changed files with 89 additions and 12 deletions

View File

@ -19,6 +19,7 @@ class ORMQueryBuilderLoaderTest extends \PHPUnit_Framework_TestCase
{
/**
* @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
* @group legacy
*/
public function testItOnlyWorksWithQueryBuilderOrClosure()
{

View File

@ -90,7 +90,7 @@ class EntityTypePerformanceTest extends FormPerformanceTestCase
$this->setMaxRunningTime(1);
for ($i = 0; $i < 40; ++$i) {
$form = $this->factory->create('entity', null, array(
$form = $this->factory->create('Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
'class' => self::ENTITY_CLASS,
));
@ -108,7 +108,7 @@ class EntityTypePerformanceTest extends FormPerformanceTestCase
$this->setMaxRunningTime(1);
for ($i = 0; $i < 40; ++$i) {
$form = $this->factory->create('entity', null, array(
$form = $this->factory->create('Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
'class' => self::ENTITY_CLASS,
'choices' => $choices,
));
@ -127,7 +127,7 @@ class EntityTypePerformanceTest extends FormPerformanceTestCase
$this->setMaxRunningTime(1);
for ($i = 0; $i < 40; ++$i) {
$form = $this->factory->create('entity', null, array(
$form = $this->factory->create('Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
'class' => self::ENTITY_CLASS,
'preferred_choices' => $choices,
));

View File

@ -141,7 +141,7 @@ class CachingFactoryDecorator implements ChoiceListFactoryInterface
* @deprecated Added for backwards compatibility in Symfony 2.7, to be
* removed in Symfony 3.0.
*/
public function createListFromFlippedChoices($choices, $value = null)
public function createListFromFlippedChoices($choices, $value = null, $triggerDeprecationNotice = true)
{
if ($choices instanceof \Traversable) {
$choices = iterator_to_array($choices);
@ -158,7 +158,7 @@ class CachingFactoryDecorator implements ChoiceListFactoryInterface
$hash = self::generateHash(array($flatChoices, $value), 'fromFlippedChoices');
if (!isset($this->lists[$hash])) {
$this->lists[$hash] = $this->decoratedFactory->createListFromFlippedChoices($choices, $value);
$this->lists[$hash] = $this->decoratedFactory->createListFromFlippedChoices($choices, $value, $triggerDeprecationNotice);
}
return $this->lists[$hash];

View File

@ -43,8 +43,12 @@ class DefaultChoiceListFactory implements ChoiceListFactoryInterface
* @deprecated Added for backwards compatibility in Symfony 2.7, to be
* removed in Symfony 3.0.
*/
public function createListFromFlippedChoices($choices, $value = null)
public function createListFromFlippedChoices($choices, $value = null, $triggerDeprecationNotice = true)
{
if ($triggerDeprecationNotice) {
@trigger_error('The '.__METHOD__.' is deprecated since version 2.7 and will be removed in 3.0.', E_USER_DEPRECATED);
}
return new ArrayKeyChoiceList($choices, $value);
}

View File

@ -116,11 +116,11 @@ class PropertyAccessDecorator implements ChoiceListFactoryInterface
* @deprecated Added for backwards compatibility in Symfony 2.7, to be
* removed in Symfony 3.0.
*/
public function createListFromFlippedChoices($choices, $value = null)
public function createListFromFlippedChoices($choices, $value = null, $triggerDeprecationNotice = true)
{
// Property paths are not supported here, because array keys can never
// be objects
return $this->decoratedFactory->createListFromFlippedChoices($choices, $value);
return $this->decoratedFactory->createListFromFlippedChoices($choices, $value, $triggerDeprecationNotice);
}
/**

View File

@ -280,7 +280,7 @@ class ChoiceType extends AbstractType
// BC when choices are in the keys, not in the values
if (!$options['choices_as_values']) {
return $choiceListFactory->createListFromFlippedChoices($choices, $options['choice_value']);
return $choiceListFactory->createListFromFlippedChoices($choices, $options['choice_value'], false);
}
return $choiceListFactory->createListFromChoices($choices, $options['choice_value']);

View File

@ -155,6 +155,9 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
$this->assertSame($list2, $this->factory->createListFromChoices($choices, $closure2));
}
/**
* @group legacy
*/
public function testCreateFromFlippedChoicesEmpty()
{
$list = new \stdClass();
@ -168,6 +171,9 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
$this->assertSame($list, $this->factory->createListFromFlippedChoices(array()));
}
/**
* @group legacy
*/
public function testCreateFromFlippedChoicesComparesTraversableChoicesAsArray()
{
// The top-most traversable is converted to an array
@ -184,6 +190,9 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
$this->assertSame($list, $this->factory->createListFromFlippedChoices($choices2));
}
/**
* @group legacy
*/
public function testCreateFromFlippedChoicesFlattensChoices()
{
$choices1 = array('key' => array('a' => 'A'));
@ -201,6 +210,7 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
/**
* @dataProvider provideSameKeyChoices
* @group legacy
*/
public function testCreateFromFlippedChoicesSameChoices($choice1, $choice2)
{
@ -219,6 +229,7 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
/**
* @dataProvider provideDistinguishedKeyChoices
* @group legacy
*/
public function testCreateFromFlippedChoicesDifferentChoices($choice1, $choice2)
{
@ -240,6 +251,9 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
$this->assertSame($list2, $this->factory->createListFromFlippedChoices($choices2));
}
/**
* @group legacy
*/
public function testCreateFromFlippedChoicesSameValueClosure()
{
$choices = array(1);
@ -255,6 +269,9 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
$this->assertSame($list, $this->factory->createListFromFlippedChoices($choices, $closure));
}
/**
* @group legacy
*/
public function testCreateFromFlippedChoicesDifferentValueClosure()
{
$choices = array(1);

View File

@ -193,6 +193,9 @@ class DefaultChoiceListFactoryTest extends \PHPUnit_Framework_TestCase
$this->assertObjectListWithCustomValues($list);
}
/**
* @group legacy
*/
public function testCreateFromFlippedChoicesEmpty()
{
$list = $this->factory->createListFromFlippedChoices(array());
@ -201,6 +204,9 @@ class DefaultChoiceListFactoryTest extends \PHPUnit_Framework_TestCase
$this->assertSame(array(), $list->getValues());
}
/**
* @group legacy
*/
public function testCreateFromFlippedChoicesFlat()
{
$list = $this->factory->createListFromFlippedChoices(
@ -210,6 +216,9 @@ class DefaultChoiceListFactoryTest extends \PHPUnit_Framework_TestCase
$this->assertScalarListWithChoiceValues($list);
}
/**
* @group legacy
*/
public function testCreateFromFlippedChoicesFlatTraversable()
{
$list = $this->factory->createListFromFlippedChoices(
@ -219,6 +228,9 @@ class DefaultChoiceListFactoryTest extends \PHPUnit_Framework_TestCase
$this->assertScalarListWithChoiceValues($list);
}
/**
* @group legacy
*/
public function testCreateFromFlippedChoicesFlatValuesAsCallable()
{
$list = $this->factory->createListFromFlippedChoices(
@ -229,6 +241,9 @@ class DefaultChoiceListFactoryTest extends \PHPUnit_Framework_TestCase
$this->assertScalarListWithCustomValues($list);
}
/**
* @group legacy
*/
public function testCreateFromFlippedChoicesFlatValuesAsClosure()
{
$list = $this->factory->createListFromFlippedChoices(
@ -246,6 +261,9 @@ class DefaultChoiceListFactoryTest extends \PHPUnit_Framework_TestCase
$this->assertScalarListWithCustomValues($list);
}
/**
* @group legacy
*/
public function testCreateFromFlippedChoicesGrouped()
{
$list = $this->factory->createListFromFlippedChoices(
@ -258,6 +276,9 @@ class DefaultChoiceListFactoryTest extends \PHPUnit_Framework_TestCase
$this->assertScalarListWithChoiceValues($list);
}
/**
* @group legacy
*/
public function testCreateFromFlippedChoicesGroupedTraversable()
{
$list = $this->factory->createListFromFlippedChoices(
@ -270,6 +291,9 @@ class DefaultChoiceListFactoryTest extends \PHPUnit_Framework_TestCase
$this->assertScalarListWithChoiceValues($list);
}
/**
* @group legacy
*/
public function testCreateFromFlippedChoicesGroupedValuesAsCallable()
{
$list = $this->factory->createListFromFlippedChoices(
@ -283,6 +307,9 @@ class DefaultChoiceListFactoryTest extends \PHPUnit_Framework_TestCase
$this->assertScalarListWithCustomValues($list);
}
/**
* @group legacy
*/
public function testCreateFromFlippedChoicesGroupedValuesAsClosure()
{
$list = $this->factory->createListFromFlippedChoices(

View File

@ -63,6 +63,9 @@ class PropertyAccessDecoratorTest extends \PHPUnit_Framework_TestCase
$this->assertSame(array('value'), $this->factory->createListFromChoices($choices, new PropertyPath('property')));
}
/**
* @group legacy
*/
public function testCreateFromFlippedChoices()
{
// Property paths are not supported here, because array keys can never

View File

@ -16,6 +16,7 @@ use Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface;
/**
* @author Bernhard Schussek <bschussek@gmail.com>
* @group legacy
*/
class LegacyChoiceListAdapterTest extends \PHPUnit_Framework_TestCase
{

View File

@ -1529,6 +1529,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
/**
* @dataProvider getOptionsWithPlaceholder
* @group legacy
*/
public function testPassEmptyValueBC($multiple, $expanded, $required, $placeholder, $viewValue)
{

View File

@ -328,6 +328,9 @@ class DateTimeTypeTest extends TestCase
$this->assertSame('Empty', $view['time']['second']->vars['placeholder']);
}
/**
* @group legacy
*/
public function testPassEmptyValueBC()
{
$form = $this->factory->create('datetime', null, array(

View File

@ -759,6 +759,9 @@ class DateTypeTest extends TestCase
$this->assertSame('Empty', $view['day']->vars['placeholder']);
}
/**
* @group legacy
*/
public function testPassEmptyValueBC()
{
$form = $this->factory->create('date', null, array(

View File

@ -562,6 +562,9 @@ class TimeTypeTest extends TestCase
$this->assertSame('Empty', $view['second']->vars['placeholder']);
}
/**
* @group legacy
*/
public function testPassEmptyValueBC()
{
$form = $this->factory->create('time', null, array(

View File

@ -48,6 +48,9 @@ class ValidatorExtensionTest extends \PHPUnit_Framework_TestCase
$this->assertInstanceOf('Symfony\Component\Form\Extension\Validator\ValidatorTypeGuesser', $guesser);
}
/**
* @group legacy
*/
public function test2Dot4ValidationApi()
{
$factory = $this->getMock('Symfony\Component\Validator\MetadataFactoryInterface');
@ -82,6 +85,7 @@ class ValidatorExtensionTest extends \PHPUnit_Framework_TestCase
/**
* @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
* @group legacy
*/
public function testInvalidValidatorInterface()
{

View File

@ -68,6 +68,8 @@ interface ConstraintViolationInterface
* @see getMessageTemplate()
*
* @api
*
* @deprecated since version 2.7, to be replaced by getParameters() in 3.0.
*/
public function getMessageParameters();
@ -86,6 +88,8 @@ interface ConstraintViolationInterface
* pluralization form (in this case "choices").
*
* @return int|null The number to use to pluralize of the message.
*
* @deprecated since version 2.7, to be replaced by getPlural() in 3.0.
*/
public function getMessagePluralization();

View File

@ -54,7 +54,10 @@ class CallbackValidator extends ConstraintValidator
$method($object, $this->context);
} elseif (is_array($method)) {
if (!is_callable($method)) {
throw new ConstraintDefinitionException(sprintf('"%s::%s" targeted by Callback constraint is not a valid callable', $method[0], $method[1]));
if (isset($method[0]) && is_object($method[0])) {
$method[0] = get_class($method[0]);
}
throw new ConstraintDefinitionException(sprintf('%s targeted by Callback constraint is not a valid callable', json_encode($method)));
}
call_user_func($method, $object, $this->context);

View File

@ -298,7 +298,7 @@ class CallbackValidatorTest extends AbstractConstraintValidatorTest
{
$object = new CallbackValidatorTest_Object();
$this->validator->validate($object, new Callback(array('foobar')));
$this->validator->validate($object, new Callback(array('callback' => array('foobar'))));
}
/**
@ -308,7 +308,7 @@ class CallbackValidatorTest extends AbstractConstraintValidatorTest
{
$object = new CallbackValidatorTest_Object();
$this->validator->validate($object, new Callback(array(array('foo', 'bar'))));
$this->validator->validate($object, new Callback(array('callback' => array('foo', 'bar'))));
}
/**

View File

@ -544,6 +544,7 @@ abstract class Abstract2Dot5ApiTest extends AbstractValidatorTest
/**
* @expectedException \Symfony\Component\Validator\Exception\UnsupportedMetadataException
* @group legacy
*/
public function testMetadataMustImplementClassMetadataInterface()
{
@ -561,6 +562,7 @@ abstract class Abstract2Dot5ApiTest extends AbstractValidatorTest
/**
* @expectedException \Symfony\Component\Validator\Exception\UnsupportedMetadataException
* @group legacy
*/
public function testReferenceMetadataMustImplementClassMetadataInterface()
{

View File

@ -26,6 +26,7 @@ use Symfony\Component\Validator\ValidatorInterface as LegacyValidatorInterface;
* @since 2.5
*
* @author Bernhard Schussek <bschussek@gmail.com>
* @group legacy
*/
abstract class AbstractLegacyApiTest extends AbstractValidatorTest
{