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

Skip to content

Commit fc8626d

Browse files
committed
minor #14406 Issue4067 class triggers (webmozart)
This PR was merged into the 2.7 branch. Discussion ---------- Issue4067 class triggers | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - This is #14201 rebased on latest 2.7. This PR moves the deprecation notice triggers introduced in #14050 to file level, as [suggested](#14050 (comment)) by @stof. Commits ------- a3917fc [Form] Removed remaining deprecation notices in the test suite 8f297c1 [Form] Moved deprecation notice triggers to file level
2 parents 8cf0613 + a3917fc commit fc8626d

File tree

13 files changed

+78
-47
lines changed

13 files changed

+78
-47
lines changed

src/Symfony/Bridge/Doctrine/Form/ChoiceList/EntityChoiceList.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Symfony\Bridge\Doctrine\Form\ChoiceList;
1313

14+
trigger_error('The '.__NAMESPACE__.'\EntityChoiceList class is deprecated since version 2.7 and will be removed in 3.0. Use Symfony\Bridge\Doctrine\Form\ChoiceList\DoctrineChoiceLoader instead.', E_USER_DEPRECATED);
15+
1416
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
1517
use Doctrine\Common\Persistence\ObjectManager;
1618
use Symfony\Component\Form\Exception\RuntimeException;
@@ -129,8 +131,6 @@ public function __construct(ObjectManager $manager, $class, $labelPath = null, E
129131
}
130132

131133
parent::__construct($entities, $labelPath, $preferredEntities, $groupPath, null, $propertyAccessor);
132-
133-
trigger_error('The '.__CLASS__.' class is deprecated since version 2.7 and will be removed in 3.0. Use Symfony\Bridge\Doctrine\Form\ChoiceList\DoctrineChoiceLoader instead.', E_USER_DEPRECATED);
134134
}
135135

136136
/**

src/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceList.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Symfony\Component\Form\Extension\Core\ChoiceList;
1313

14+
trigger_error('The '.__NAMESPACE__.'\ChoiceList class is deprecated since version 2.7 and will be removed in 3.0. Use Symfony\Component\Form\ChoiceList\ArrayChoiceList instead.', E_USER_DEPRECATED);
15+
1416
use Symfony\Component\Form\FormConfigBuilder;
1517
use Symfony\Component\Form\Exception\UnexpectedTypeException;
1618
use Symfony\Component\Form\Exception\InvalidConfigurationException;
@@ -92,8 +94,6 @@ public function __construct($choices, array $labels, array $preferredChoices = a
9294
}
9395

9496
$this->initialize($choices, $labels, $preferredChoices);
95-
96-
trigger_error('The '.__CLASS__.' class is deprecated since version 2.7 and will be removed in 3.0. Use Symfony\Component\Form\ChoiceList\ArrayChoiceList instead.', E_USER_DEPRECATED);
9797
}
9898

9999
/**

src/Symfony/Component/Form/Extension/Core/ChoiceList/LazyChoiceList.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Symfony\Component\Form\Extension\Core\ChoiceList;
1313

14+
trigger_error('The '.__NAMESPACE__.'\LazyChoiceList class is deprecated since version 2.7 and will be removed in 3.0. Use Symfony\Component\Form\ChoiceList\ArrayChoiceList instead.', E_USER_DEPRECATED);
15+
1416
use Symfony\Component\Form\Exception\InvalidArgumentException;
1517

1618
/**
@@ -34,11 +36,6 @@ abstract class LazyChoiceList implements ChoiceListInterface
3436
*/
3537
private $choiceList;
3638

37-
public function __construct()
38-
{
39-
trigger_error('The '.__CLASS__.' class is deprecated since version 2.7 and will be removed in 3.0. Use Symfony\Component\Form\ChoiceList\LazyChoiceList instead.', E_USER_DEPRECATED);
40-
}
41-
4239
/**
4340
* {@inheritdoc}
4441
*/

src/Symfony/Component/Form/Extension/Core/ChoiceList/ObjectChoiceList.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Symfony\Component\Form\Extension\Core\ChoiceList;
1313

14+
trigger_error('The '.__NAMESPACE__.'\ObjectChoiceList class is deprecated since version 2.7 and will be removed in 3.0. Use Symfony\Component\Form\ChoiceList\ArrayChoiceList instead.', E_USER_DEPRECATED);
15+
1416
use Symfony\Component\Form\Exception\StringCastException;
1517
use Symfony\Component\Form\Exception\InvalidArgumentException;
1618
use Symfony\Component\PropertyAccess\PropertyPath;
@@ -96,8 +98,6 @@ public function __construct($choices, $labelPath = null, array $preferredChoices
9698
$this->valuePath = null !== $valuePath ? new PropertyPath($valuePath) : null;
9799

98100
parent::__construct($choices, array(), $preferredChoices);
99-
100-
trigger_error('The '.__CLASS__.' class is deprecated since version 2.7 and will be removed in 3.0. Use Symfony\Component\Form\ChoiceList\ArrayChoiceList instead.', E_USER_DEPRECATED);
101101
}
102102

103103
/**

src/Symfony/Component/Form/Extension/Core/ChoiceList/SimpleChoiceList.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Symfony\Component\Form\Extension\Core\ChoiceList;
1313

14+
trigger_error('The '.__NAMESPACE__.'\SimpleChoiceList class is deprecated since version 2.7 and will be removed in 3.0. Use Symfony\Component\Form\ChoiceList\ArrayChoiceList instead.', E_USER_DEPRECATED);
15+
1416
/**
1517
* A choice list for choices of type string or integer.
1618
*

src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoiceToBooleanArrayTransformer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Symfony\Component\Form\Extension\Core\DataTransformer;
1313

14+
trigger_error('The class '.__NAMESPACE__.'\ChoiceToBooleanArrayTransformer is deprecated since version 2.7 and will be removed in 3.0. Use Symfony\Component\Form\Extension\Core\DataMapper\RadioListMapper instead.', E_USER_DEPRECATED);
15+
1416
use Symfony\Component\Form\ChoiceList\ChoiceListInterface;
1517
use Symfony\Component\Form\DataTransformerInterface;
1618
use Symfony\Component\Form\Exception\TransformationFailedException;
@@ -37,8 +39,6 @@ public function __construct(ChoiceListInterface $choiceList, $placeholderPresent
3739
{
3840
$this->choiceList = $choiceList;
3941
$this->placeholderPresent = $placeholderPresent;
40-
41-
trigger_error('The class '.__CLASS__.' is deprecated since version 2.7 and will be removed in 3.0. Use Symfony\Component\Form\ChoiceList\LazyChoiceList instead.', E_USER_DEPRECATED);
4242
}
4343

4444
/**

src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoicesToBooleanArrayTransformer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Symfony\Component\Form\Extension\Core\DataTransformer;
1313

14+
trigger_error('The class '.__NAMESPACE__.'\ChoicesToBooleanArrayTransformer is deprecated since version 2.7 and will be removed in 3.0. Use Symfony\Component\Form\Extension\Core\DataMapper\CheckboxListMapper instead.', E_USER_DEPRECATED);
15+
1416
use Symfony\Component\Form\ChoiceList\ChoiceListInterface;
1517
use Symfony\Component\Form\DataTransformerInterface;
1618
use Symfony\Component\Form\Exception\TransformationFailedException;
@@ -28,8 +30,6 @@ class ChoicesToBooleanArrayTransformer implements DataTransformerInterface
2830
public function __construct(ChoiceListInterface $choiceList)
2931
{
3032
$this->choiceList = $choiceList;
31-
32-
trigger_error('The class '.__CLASS__.' is deprecated since version 2.7 and will be removed in 3.0. Use Symfony\Component\Form\ChoiceList\LazyChoiceList instead.', E_USER_DEPRECATED);
3333
}
3434

3535
/**

src/Symfony/Component/Form/Extension/Core/EventListener/FixCheckboxInputListener.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Symfony\Component\Form\Extension\Core\EventListener;
1313

14+
trigger_error('The class '.__NAMESPACE__.'\FixCheckboxInputListener is deprecated since version 2.7 and will be removed in 3.0. Use Symfony\Component\Form\Extension\Core\DataMapper\CheckboxListMapper instead.', E_USER_DEPRECATED);
15+
1416
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1517
use Symfony\Component\Form\ChoiceList\ChoiceListInterface;
1618
use Symfony\Component\Form\Exception\TransformationFailedException;
@@ -38,8 +40,6 @@ class FixCheckboxInputListener implements EventSubscriberInterface
3840
public function __construct(ChoiceListInterface $choiceList)
3941
{
4042
$this->choiceList = $choiceList;
41-
42-
trigger_error('The class '.__CLASS__.' is deprecated since version 2.7 and will be removed in 3.0. Use Symfony\Component\Form\Extension\Core\DataMapper\CheckboxListMapper instead.', E_USER_DEPRECATED);
4343
}
4444

4545
public function preSubmit(FormEvent $event)

src/Symfony/Component/Form/Extension/Core/EventListener/FixRadioInputListener.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Symfony\Component\Form\Extension\Core\EventListener;
1313

14+
trigger_error('The class '.__NAMESPACE__.'\FixRadioInputListener is deprecated since version 2.7 and will be removed in 3.0. Use Symfony\Component\Form\Extension\Core\DataMapper\RadioListMapper instead.', E_USER_DEPRECATED);
15+
1416
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1517
use Symfony\Component\Form\ChoiceList\ChoiceListInterface;
1618
use Symfony\Component\Form\FormEvent;
@@ -41,8 +43,6 @@ public function __construct(ChoiceListInterface $choiceList, $placeholderPresent
4143
{
4244
$this->choiceList = $choiceList;
4345
$this->placeholderPresent = $placeholderPresent;
44-
45-
trigger_error('The class '.__CLASS__.' is deprecated since version 2.7 and will be removed in 3.0. Use Symfony\Component\Form\Extension\Core\DataMapper\RadioListMapper instead.', E_USER_DEPRECATED);
4646
}
4747

4848
public function preSubmit(FormEvent $event)

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ public function testCreateViewFlatAttrAsArray()
639639
null, // group
640640
array(
641641
'B' => array('attr1' => 'value1'),
642-
'C' => array('attr2' => 'value2')
642+
'C' => array('attr2' => 'value2'),
643643
)
644644
);
645645

@@ -730,6 +730,9 @@ function ($object, $key, $value) {
730730
$this->assertFlatViewWithAttr($view);
731731
}
732732

733+
/**
734+
* @group legacy
735+
*/
733736
public function testCreateViewForLegacyChoiceList()
734737
{
735738
$preferred = array(new ChoiceView('Preferred', 'x', 'x'));
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Form\Tests\Extension\Core\ChoiceList\Fixtures;
13+
14+
use Symfony\Component\Form\Extension\Core\ChoiceList\LazyChoiceList;
15+
16+
class LazyChoiceListImpl extends LazyChoiceList
17+
{
18+
private $choiceList;
19+
20+
public function __construct($choiceList)
21+
{
22+
$this->choiceList = $choiceList;
23+
}
24+
25+
protected function loadChoiceList()
26+
{
27+
return $this->choiceList;
28+
}
29+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Form\Tests\Extension\Core\ChoiceList\Fixtures;
13+
14+
use Symfony\Component\Form\Extension\Core\ChoiceList\LazyChoiceList;
15+
16+
class LazyChoiceListInvalidImpl extends LazyChoiceList
17+
{
18+
protected function loadChoiceList()
19+
{
20+
return new \stdClass();
21+
}
22+
}

src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/LazyChoiceListTest.php

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,25 @@
1212
namespace Symfony\Component\Form\Tests\Extension\Core\ChoiceList;
1313

1414
use Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList;
15-
use Symfony\Component\Form\Extension\Core\ChoiceList\LazyChoiceList;
1615
use Symfony\Component\Form\Extension\Core\View\ChoiceView;
16+
use Symfony\Component\Form\Tests\Extension\Core\ChoiceList\Fixtures\LazyChoiceListImpl;
17+
use Symfony\Component\Form\Tests\Extension\Core\ChoiceList\Fixtures\LazyChoiceListInvalidImpl;
1718

1819
/**
1920
* @group legacy
2021
*/
2122
class LazyChoiceListTest extends \PHPUnit_Framework_TestCase
2223
{
2324
/**
24-
* @var LazyChoiceListTest_Impl
25+
* @var LazyChoiceListImpl
2526
*/
2627
private $list;
2728

2829
protected function setUp()
2930
{
3031
parent::setUp();
3132

32-
$this->list = new LazyChoiceListTest_Impl(new SimpleChoiceList(array(
33+
$this->list = new LazyChoiceListImpl(new SimpleChoiceList(array(
3334
'a' => 'A',
3435
'b' => 'B',
3536
'c' => 'C',
@@ -92,31 +93,8 @@ public function testGetValuesForChoices()
9293
*/
9394
public function testLoadChoiceListShouldReturnChoiceList()
9495
{
95-
$list = new LazyChoiceListTest_InvalidImpl();
96+
$list = new LazyChoiceListInvalidImpl();
9697

9798
$list->getChoices();
9899
}
99100
}
100-
101-
class LazyChoiceListTest_Impl extends LazyChoiceList
102-
{
103-
private $choiceList;
104-
105-
public function __construct($choiceList)
106-
{
107-
$this->choiceList = $choiceList;
108-
}
109-
110-
protected function loadChoiceList()
111-
{
112-
return $this->choiceList;
113-
}
114-
}
115-
116-
class LazyChoiceListTest_InvalidImpl extends LazyChoiceList
117-
{
118-
protected function loadChoiceList()
119-
{
120-
return new \stdClass();
121-
}
122-
}

0 commit comments

Comments
 (0)