8000 minor #15687 [2.7] Clean deprecated interfaces (nicolas-grekas) · symfony/symfony@22c5964 · GitHub
[go: up one dir, main page]

Skip to content

Commit 22c5964

Browse files
committed
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
2 parents 041dff5 + e49739c commit 22c5964

20 files changed

+89
-12
lines changed

src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/ORMQueryBuilderLoaderTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class ORMQueryBuilderLoaderTest extends \PHPUnit_Framework_TestCase
1919
{
2020
/**
2121
* @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
22+
* @group legacy
2223
*/
2324
public function testItOnlyWorksWithQueryBuilderOrClosure()
2425
{

src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function testCollapsedEntityField()
9090
$this->setMaxRunningTime(1);
9191

9292
for ($i = 0; $i < 40; ++$i) {
93-
$form = $this->factory->create('entity', null, array(
93+
$form = $this->factory->create('Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
9494
'class' => self::ENTITY_CLASS,
9595
));
9696

@@ -108,7 +108,7 @@ public function testCollapsedEntityFieldWithChoices()
108108
$this->setMaxRunningTime(1);
109109

110110
for ($i = 0; $i < 40; ++$i) {
111-
$form = $this->factory->create('entity', null, array(
111+
$form = $this->factory->create('Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
112112
'class' => self::ENTITY_CLASS,
113113
'choices' => $choices,
114114
));
@@ -127,7 +127,7 @@ public function testCollapsedEntityFieldWithPreferredChoices()
127127
$this->setMaxRunningTime(1);
128128

129129
for ($i = 0; $i < 40; ++$i) {
130-
$form = $this->factory->create('entity', null, array(
130+
$form = $this->factory->create('Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
131131
'class' => self::ENTITY_CLASS,
132132
'preferred_choices' => $choices,
133133
));

src/Symfony/Component/Form/ChoiceList/Factory/CachingFactoryDecorator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public function createListFromChoices($choices, $value = null)
141141
* @deprecated Added for backwards compatibility in Symfony 2.7, to be
142142
* removed in Symfony 3.0.
143143
*/
144-
public function createListFromFlippedChoices($choices, $value = null)
144+
public function createListFromFlippedChoices($choices, $value = null, $triggerDeprecationNotice = true)
145145
{
146146
if ($choices instanceof \Traversable) {
147147
$choices = iterator_to_array($choices);
@@ -158,7 +158,7 @@ public function createListFromFlippedChoices($choices, $value = null)
158158
$hash = self::generateHash(array($flatChoices, $value), 'fromFlippedChoices');
159159

160160
if (!isset($this->lists[$hash])) {
161-
$this->lists[$hash] = $this->decoratedFactory->createListFromFlippedChoices($choices, $value);
161+
$this->lists[$hash] = $this->decoratedFactory->createListFromFlippedChoices($choices, $value, $triggerDeprecationNotice);
162162
}
163163

164164
return $this->lists[$hash];

src/Symfony/Component/Form/ChoiceList/Factory/DefaultChoiceListFactory.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,12 @@ public function createListFromChoices($choices, $value = null)
4343
* @deprecated Added for backwards compatibility in Symfony 2.7, to be
4444
* removed in Symfony 3.0.
4545
*/
46-
public function createListFromFlippedChoices($choices, $value = null)
46+
public function createListFromFlippedChoices($choices, $value = null, $triggerDeprecationNotice = true)
4747
{
48+
if ($triggerDeprecationNotice) {
49+
@trigger_error('The '.__METHOD__.' is deprecated since version 2.7 and will be removed in 3.0.', E_USER_DEPRECATED);
50+
}
51+
4852
return new ArrayKeyChoiceList($choices, $value);
4953
}
5054

src/Symfony/Component/Form/ChoiceList/Factory/PropertyAccessDecorator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,11 @@ public function createListFromChoices($choices, $value = null)
116116
* @deprecated Added for backwards compatibility in Symfony 2.7, to be
117117
* removed in Symfony 3.0.
118118
*/
119-
public function createListFromFlippedChoices($choices, $value = null)
119+
public function createListFromFlippedChoices($choices, $value = null, $triggerDeprecationNotice = true)
120120
{
121121
// Property paths are not supported here, because array keys can never
122122
// be objects
123-
return $this->decoratedFactory->createListFromFlippedChoices($choices, $value);
123+
return $this->decoratedFactory->createListFromFlippedChoices($choices, $value, $triggerDeprecationNotice);
124124
}
125125

126126
/**

src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ public function configureOptions(OptionsResolver $resolver)
280280

281281
// BC when choices are in the keys, not in the values
282282
if (!$options['choices_as_values']) {
283-
return $choiceListFactory->createListFromFlippedChoices($choices, $options['choice_value']);
283+
return $choiceListFactory->createListFromFlippedChoices($choices, $options['choice_value'], false);
284284
}
285285

286286
return $choiceListFactory->createListFromChoices($choices, $options['choice_value']);

src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ public function testCreateFromChoicesDifferentValueClosure()
155155
$this->assertSame($list2, $this->factory->createListFromChoices($choices, $closure2));
156156
}
157157

158+
/**
159+
* @group legacy
160+
*/
158161
public function testCreateFromFlippedChoicesEmpty()
159162
{
160163
$list = new \stdClass();
@@ -168,6 +171,9 @@ public function testCreateFromFlippedChoicesEmpty()
168171
$this->assertSame($list, $this->factory->createListFromFlippedChoices(array()));
169172
}
170173

174+
/**
175+
* @group legacy
176+
*/
171177
public function testCreateFromFlippedChoicesComparesTraversableChoicesAsArray()
172178
{
173179
// The top-most traversable is converted to an array
@@ -184,6 +190,9 @@ public function testCreateFromFlippedChoicesComparesTraversableChoicesAsArray()
184190
$this->assertSame($list, $this->factory->createListFromFlippedChoices($choices2));
185191
}
186192

193+
/**
194+
* @group legacy
195+
*/
187196
public function testCreateFromFlippedChoicesFlattensChoices()
188197
{
189198
$choices1 = array('key' => array('a' => 'A' 10000 ));
@@ -201,6 +210,7 @@ public function testCreateFromFlippedChoicesFlattensChoices()
201210

202211
/**
203212
* @dataProvider provideSameKeyChoices
213+
* @group legacy
204214
*/
205215
public function testCreateFromFlippedChoicesSameChoices($choice1, $choice2)
206216
{
@@ -219,6 +229,7 @@ public function testCreateFromFlippedChoicesSameChoices($choice1, $choice2)
219229

220230
/**
221231
* @dataProvider provideDistinguishedKeyChoices
232+
* @group legacy
222233
*/
223234
public function testCreateFromFlippedChoicesDifferentChoices($choice1, $choice2)
224235
{
@@ -240,6 +251,9 @@ public function testCreateFromFlippedChoicesDifferentChoices($choice1, $choice2)
240251
$this->assertSame($list2, $this->factory->createListFromFlippedChoices($choices2));
241252
}
242253

254+
/**
255+
* @group legacy
256+
*/
243257
public function testCreateFromFlippedChoicesSameValueClosure()
244258
{
245259
$choices = array(1);
@@ -255,6 +269,9 @@ public function testCreateFromFlippedChoicesSameValueClosure()
255269
$this->assertSame($list, $this->factory->createListFromFlippedChoices($choices, $closure));
256270
}
257271

272+
/**
273+
* @group legacy
274+
*/
258275
public function testCreateFromFlippedChoicesDifferentValueClosure()
259276
{
260277
$choices = array(1);

src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,9 @@ function ($object) { return $object->value; }
193193
$this->assertObjectListWithCustomValues($list);
194194
}
195195

196+
/**
19 10000 7+
* @group legacy
198+
*/
196199
public function testCreateFromFlippedChoicesEmpty()
197200
{
198201
$list = $this->factory->createListFromFlippedChoices(array());
@@ -201,6 +204,9 @@ public function testCreateFromFlippedChoicesEmpty()
201204
$this->assertSame(array(), $list->getValues());
202205
}
203206

207+
/**
208+
* @group legacy
209+
*/
204210
public function testCreateFromFlippedChoicesFlat()
205211
{
206212
$list = $this->factory->createListFromFlippedChoices(
@@ -210,6 +216,9 @@ public function testCreateFromFlippedChoicesFlat()
210216
$this->assertScalarListWithChoiceValues($list);
211217
}
212218

219+
/**
220+
* @group legacy
221+
*/
213222
public function testCreateFromFlippedChoicesFlatTraversable()
214223
{
215224
$list = $this->factory->createListFromFlippedChoices(
@@ -219,6 +228,9 @@ public function testCreateFromFlippedChoicesFlatTraversable()
219228
$this->assertScalarListWithChoiceValues($list);
220229
}
221230

231+
/**
232+
* @group legacy
233+
*/
222234
public function testCreateFromFlippedChoicesFlatValuesAsCallable()
223235
{
224236
$list = $this->factory->createListFromFlippedChoices(
@@ -229,6 +241,9 @@ public function testCreateFromFlippedChoicesFlatValuesAsCallable()
229241
$this->assertScalarListWithCustomValues($list);
230242
}
231243

244+
/**
245+
* @group legacy
246+
*/
232247
public function testCreateFromFlippedChoicesFlatValuesAsClosure()
233248
{
234249
$list = $this->factory->createListFromFlippedChoices(
@@ -246,6 +261,9 @@ function ($choice) {
246261
$this->assertScalarListWithCustomValues($list);
247262
}
248263

264+
/**
265+
* @group legacy
266+
*/
249267
public function testCreateFromFlippedChoicesGrouped()
250268
{
251269
$list = $this->factory->createListFromFlippedChoices(
@@ -258,6 +276,9 @@ public function testCreateFromFlippedChoicesGrouped()
258276
$this->assertScalarListWithChoiceValues($list);
259277
}
260278

279+
/**
280+
* @group legacy
281+
*/
261282
public function testCreateFromFlippedChoicesGroupedTraversable()
262283
{
263284
$list = $this->factory->createListFromFlippedChoices(
@@ -270,6 +291,9 @@ public function testCreateFromFlippedChoicesGroupedTraversable()
270291
$this->assertScalarListWithChoiceValues($list);
271292
}
272293

294+
/**
295+
* @group legacy
296+
*/
273297
public function testCreateFromFlippedChoicesGroupedValuesAsCallable()
274298
{
275299
$list = $this->factory->createListFromFlippedChoices(
@@ -283,6 +307,9 @@ public function testCreateFromFlippedChoicesGroupedValuesAsCallable()
283307
$this->assertScalarListWithCustomValues($list);
284308
}
285309

310+
/**
311+
* @group legacy
312+
*/
286313
public function testCreateFromFlippedChoicesGroupedValuesAsClosure()
287314
{
288315
$list = $this->factory->createListFromFlippedChoices(

src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ public function testCreateFromChoicesPropertyPathInstance()
6363
$this->assertSame(array('value'), $this->factory->createListFromChoices($choices, new PropertyPath('property')));
6464
}
6565

66+
/**
67+
* @group legacy
68+
*/
6669
public function testCreateFromFlippedChoices()
6770
{
6871
// Property paths are not supported here, because array keys can never

src/Symfony/Component/Form/Tests/ChoiceList/LegacyChoiceListAdapterTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
/**
1818
* @author Bernhard Schussek <bschussek@gmail.com>
19+
* @group legacy
1920
*/
2021
class LegacyChoiceListAdapterTest extends \PHPUnit_Framework_TestCase
2122
{

src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,6 +1529,7 @@ public function testPassPlaceholderToView($multiple, $expanded, $required, $plac
15291529

15301530
/**
15311531
* @dataProvider getOptionsWithPlaceholder
1532+
* @group legacy
15321533
*/
15331534
public function testPassEmptyValueBC($multiple, $expanded, $required, $placeholder, $viewValue)
15341535
{

src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,9 @@ public function testPassPlaceholderAsString()
328328
$this->assertSame('Empty', $view['time']['second']->vars['placeholder']);
329329
}
330330

331+
/**
332+
* @group legacy
333+
*/
331334
public function testPassEmptyValueBC()
332335
{
333336
$form = $this->factory->create('datetime', null, array(

src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,9 @@ public function testPassPlaceholderAsString()
759759
$this->assertSame('Empty', $view['day']->vars['placeholder']);
760760
}
761761

762+
/**
763+
* @group legacy
764+
*/
762765
public function testPassEmptyValueBC()
763766
{
764767
$form = $this->factory->create('date', null, array(

src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,9 @@ public function testPassPlaceholderAsString()
562562
$this->assertSame('Empty', $view['second']->vars['placeholder']);
563563
}
564564

565+
/**
566+
* @group legacy
567+
*/
565568
public function testPassEmptyValueBC()
566569
{
567570
$form = $this->factory->create('time', null, array(

src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorExtensionTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ public function test2Dot5ValidationApi()
4848
$this->assertInstanceOf('Symfony\Component\Form\Extension\Validator\ValidatorTypeGuesser', $guesser);
4949
}
5050

51+
/**
52+
* @group legacy
53+
*/
5154
public function test2Dot4ValidationApi()
5255
{
5356
$factory = $this->getMock('Symfony\Component\Validator\MetadataFactoryInterface');
@@ -82,6 +85,7 @@ public function test2Dot4ValidationApi()
8285

8386
/**
8487
* @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
88+
* @group legacy
8589
*/
8690
public function testInvalidValidatorInterface()
8791
{

src/Symfony/Component/Validator/ConstraintViolationInterface.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ public function getMessageTemplate();
6868
* @see getMessageTemplate()
6969
*
7070
* @api
71+
*
72+
* @deprecated since version 2.7, to be replaced by getParameters() in 3.0.
7173
*/
7274
public function getMessageParameters();
7375

@@ -86,6 +88,8 @@ public function getMessageParameters();
8688
* pluralization form (in this case "choices").
8789
*
8890
* @return int|null The number to use to pluralize of the message.
91+
*
92+
* @deprecated since version 2.7, to be replaced by getPlural() in 3.0.
8993
*/
9094
public function getMessagePluralization();
9195

src/Symfony/Component/Validator/Constraints/CallbackValidator.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ public function validate($object, Constraint $constraint)
5454
$method($object, $this->context);
5555
} elseif (is_array($method)) {
5656
if (!is_callable($method)) {
57-
throw new ConstraintDefinitionException(sprintf('"%s::%s" targeted by Callback constraint is not a valid callable', $method[0], $method[1]));
57+
if (isset($method[0]) && is_object($method[0])) {
58+
$method[0] = get_class($method[0]);
59+
}
60+
throw new ConstraintDefinitionException(sprintf('%s targeted by Callback constraint is not a valid callable', json_encode($method)));
5861
}
5962

6063
call_user_func($method, $object, $this->context);

src/Symfony/Component/Validator/Tests/Constraints/CallbackValidatorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ public function testExpectValidMethods()
298298
{
299299
$object = new CallbackValidatorTest_Object();
300300

301-
$this->validator->validate($object, new Callback(array('foobar')));
301+
$this->validator->validate($object, new Callback(array('callback' => array('foobar'))));
302302
}
303303

304304
/**
@@ -308,7 +308,7 @@ public function testExpectValidCallbacks()
308308
{
309309
$object = new CallbackValidatorTest_Object();
310310

311-
$this->validator->validate($object, new Callback(array(array('foo', 'bar'))));
311+
$this->validator->validate($object, new Callback(array('callback' => array('foo', 'bar'))));
312312
}
313313

314314
/**

src/Symfony/Component/Validator/Tests/Validator/Abstract2Dot5ApiTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,7 @@ public function testAddCustomizedViolation()
544544

545545
/**
546546
* @expectedException \Symfony\Component\Validator\Exception\UnsupportedMetadataException
547+
* @group legacy
547548
*/
548549
public function testMetadataMustImplementClassMetadataInterface()
549550
{
@@ -561,6 +562,7 @@ public function testMetadataMustImplementClassMetadataInterface()
561562

562563
/**
563564
* @expectedException \Symfony\Component\Validator\Exception\UnsupportedMetadataException
565+
* @group legacy
564566
*/
565567
public function testReferenceMetadataMustImplementClassMetadataInterface()
566568
{

src/Symfony/Component/Validator/Tests/Validator/AbstractLegacyApiTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
* @since 2.5
2727
*
2828
* @author Bernhard Schussek <bschussek@gmail.com>
29+
* @group legacy
2930
*/
3031
abstract class AbstractLegacyApiTest extends AbstractValidatorTest
3132
{

0 commit comments

Comments
 (0)
0