From 8f297c14e83ec696de2ba2b3a1ad1bb24af47119 Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Fri, 3 Apr 2015 17:41:07 +0200 Subject: [PATCH 1/2] [Form] Moved deprecation notice triggers to file level --- .../Bridge/Doctrine/Form/ChoiceList/EntityChoiceList.php | 4 ++-- .../Form/Extension/Core/ChoiceList/ChoiceList.php | 4 ++-- .../Form/Extension/Core/ChoiceList/ChoiceListInterface.php | 2 ++ .../Form/Extension/Core/ChoiceList/LazyChoiceList.php | 7 ++----- .../Form/Extension/Core/ChoiceList/ObjectChoiceList.php | 4 ++-- .../Form/Extension/Core/ChoiceList/SimpleChoiceList.php | 2 ++ .../DataTransformer/ChoiceToBooleanArrayTransformer.php | 4 ++-- .../DataTransformer/ChoicesToBooleanArrayTransformer.php | 4 ++-- .../Core/EventListener/FixCheckboxInputListener.php | 4 ++-- .../Extension/Core/EventListener/FixRadioInputListener.php | 4 ++-- 10 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/EntityChoiceList.php b/src/Symfony/Bridge/Doctrine/Form/ChoiceList/EntityChoiceList.php index 1d4232306df9b..27fa1f6440620 100644 --- a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/EntityChoiceList.php +++ b/src/Symfony/Bridge/Doctrine/Form/ChoiceList/EntityChoiceList.php @@ -11,6 +11,8 @@ namespace Symfony\Bridge\Doctrine\Form\ChoiceList; +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); + use Doctrine\Common\Persistence\Mapping\ClassMetadata; use Doctrine\Common\Persistence\ObjectManager; use Symfony\Component\Form\Exception\RuntimeException; @@ -129,8 +131,6 @@ public function __construct(ObjectManager $manager, $class, $labelPath = null, E } parent::__construct($entities, $labelPath, $preferredEntities, $groupPath, null, $propertyAccessor); - - 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); } /** diff --git a/src/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceList.php b/src/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceList.php index e11d8f7825950..d79428f681c4d 100644 --- a/src/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceList.php +++ b/src/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceList.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Form\Extension\Core\ChoiceList; +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); + use Symfony\Component\Form\FormConfigBuilder; use Symfony\Component\Form\Exception\UnexpectedTypeException; use Symfony\Component\Form\Exception\InvalidConfigurationException; @@ -92,8 +94,6 @@ public function __construct($choices, array $labels, array $preferredChoices = a } $this->initialize($choices, $labels, $preferredChoices); - - 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); } /** diff --git a/src/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceListInterface.php b/src/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceListInterface.php index ac5847ed32f2b..bb4ff13c65c84 100644 --- a/src/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceListInterface.php +++ b/src/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceListInterface.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Form\Extension\Core\ChoiceList; +trigger_error('The '.__NAMESPACE__.'\ChoiceListInterface interface is deprecated since version 2.7 and will be removed in 3.0. Use Symfony\Component\Form\ChoiceList\ChoiceListInterface instead.', E_USER_DEPRECATED); + use Symfony\Component\Form\ChoiceList\ChoiceListInterface as BaseChoiceListInterface; use Symfony\Component\Form\FormConfigBuilder; diff --git a/src/Symfony/Component/Form/Extension/Core/ChoiceList/LazyChoiceList.php b/src/Symfony/Component/Form/Extension/Core/ChoiceList/LazyChoiceList.php index 0b3a7ee23c692..df0995713d626 100644 --- a/src/Symfony/Component/Form/Extension/Core/ChoiceList/LazyChoiceList.php +++ b/src/Symfony/Component/Form/Extension/Core/ChoiceList/LazyChoiceList.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Form\Extension\Core\ChoiceList; +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); + use Symfony\Component\Form\Exception\InvalidArgumentException; /** @@ -34,11 +36,6 @@ abstract class LazyChoiceList implements ChoiceListInterface */ private $choiceList; - public function __construct() - { - 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); - } - /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Form/Extension/Core/ChoiceList/ObjectChoiceList.php b/src/Symfony/Component/Form/Extension/Core/ChoiceList/ObjectChoiceList.php index aa6b0b630727e..3270591ab3885 100644 --- a/src/Symfony/Component/Form/Extension/Core/ChoiceList/ObjectChoiceList.php +++ b/src/Symfony/Component/Form/Extension/Core/ChoiceList/ObjectChoiceList.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Form\Extension\Core\ChoiceList; +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); + use Symfony\Component\Form\Exception\StringCastException; use Symfony\Component\Form\Exception\InvalidArgumentException; use Symfony\Component\PropertyAccess\PropertyPath; @@ -96,8 +98,6 @@ public function __construct($choices, $labelPath = null, array $preferredChoices $this->valuePath = null !== $valuePath ? new PropertyPath($valuePath) : null; parent::__construct($choices, array(), $preferredChoices); - - 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); } /** diff --git a/src/Symfony/Component/Form/Extension/Core/ChoiceList/SimpleChoiceList.php b/src/Symfony/Component/Form/Extension/Core/ChoiceList/SimpleChoiceList.php index af0ef2005231f..136e7289cf1a6 100644 --- a/src/Symfony/Component/Form/Extension/Core/ChoiceList/SimpleChoiceList.php +++ b/src/Symfony/Component/Form/Extension/Core/ChoiceList/SimpleChoiceList.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Form\Extension\Core\ChoiceList; +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); + /** * A choice list for choices of type string or integer. * diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoiceToBooleanArrayTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoiceToBooleanArrayTransformer.php index 9d3e14535b2b8..70c2e0286e9f9 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoiceToBooleanArrayTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoiceToBooleanArrayTransformer.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Form\Extension\Core\DataTransformer; +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); + use Symfony\Component\Form\ChoiceList\ChoiceListInterface; use Symfony\Component\Form\DataTransformerInterface; use Symfony\Component\Form\Exception\TransformationFailedException; @@ -37,8 +39,6 @@ public function __construct(ChoiceListInterface $choiceList, $placeholderPresent { $this->choiceList = $choiceList; $this->placeholderPresent = $placeholderPresent; - - 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); } /** diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoicesToBooleanArrayTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoicesToBooleanArrayTransformer.php index e4492929f261d..ba3bf22af32f3 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoicesToBooleanArrayTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoicesToBooleanArrayTransformer.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Form\Extension\Core\DataTransformer; +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); + use Symfony\Component\Form\ChoiceList\ChoiceListInterface; use Symfony\Component\Form\DataTransformerInterface; use Symfony\Component\Form\Exception\TransformationFailedException; @@ -28,8 +30,6 @@ class ChoicesToBooleanArrayTransformer implements DataTransformerInterface public function __construct(ChoiceListInterface $choiceList) { $this->choiceList = $choiceList; - - 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); } /** diff --git a/src/Symfony/Component/Form/Extension/Core/EventListener/FixCheckboxInputListener.php b/src/Symfony/Component/Form/Extension/Core/EventListener/FixCheckboxInputListener.php index d1ab55bacc112..abdf11420d5a0 100644 --- a/src/Symfony/Component/Form/Extension/Core/EventListener/FixCheckboxInputListener.php +++ b/src/Symfony/Component/Form/Extension/Core/EventListener/FixCheckboxInputListener.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Form\Extension\Core\EventListener; +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); + use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\Form\ChoiceList\ChoiceListInterface; use Symfony\Component\Form\Exception\TransformationFailedException; @@ -38,8 +40,6 @@ class FixCheckboxInputListener implements EventSubscriberInterface public function __construct(ChoiceListInterface $choiceList) { $this->choiceList = $choiceList; - - 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); } public function preSubmit(FormEvent $event) diff --git a/src/Symfony/Component/Form/Extension/Core/EventListener/FixRadioInputListener.php b/src/Symfony/Component/Form/Extension/Core/EventListener/FixRadioInputListener.php index 2ef7b2b8239dc..c009d8104a659 100644 --- a/src/Symfony/Component/Form/Extension/Core/EventListener/FixRadioInputListener.php +++ b/src/Symfony/Component/Form/Extension/Core/EventListener/FixRadioInputListener.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Form\Extension\Core\EventListener; +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); + use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\Form\ChoiceList\ChoiceListInterface; use Symfony\Component\Form\FormEvent; @@ -41,8 +43,6 @@ public function __construct(ChoiceListInterface $choiceList, $placeholderPresent { $this->choiceList = $choiceList; $this->placeholderPresent = $placeholderPresent; - - 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); } public function preSubmit(FormEvent $event) From a3917fc8c14e6117d6c0c5f18c8746cdbb85dd9e Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Tue, 7 Apr 2015 19:09:54 +0200 Subject: [PATCH 2/2] [Form] Removed remaining deprecation notices in the test suite --- .../Core/ChoiceList/ChoiceListInterface.php | 2 -- .../Factory/DefaultChoiceListFactoryTest.php | 5 ++- .../Fixtures/LazyChoiceListImpl.php | 29 +++++++++++++++++ .../Fixtures/LazyChoiceListInvalidImpl.php | 22 +++++++++++++ .../Core/ChoiceList/LazyChoiceListTest.php | 32 +++---------------- 5 files changed, 60 insertions(+), 30 deletions(-) create mode 100644 src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/Fixtures/LazyChoiceListImpl.php create mode 100644 src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/Fixtures/LazyChoiceListInvalidImpl.php diff --git a/src/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceListInterface.php b/src/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceListInterface.php index bb4ff13c65c84..ac5847ed32f2b 100644 --- a/src/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceListInterface.php +++ b/src/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceListInterface.php @@ -11,8 +11,6 @@ namespace Symfony\Component\Form\Extension\Core\ChoiceList; -trigger_error('The '.__NAMESPACE__.'\ChoiceListInterface interface is deprecated since version 2.7 and will be removed in 3.0. Use Symfony\Component\Form\ChoiceList\ChoiceListInterface instead.', E_USER_DEPRECATED); - use Symfony\Component\Form\ChoiceList\ChoiceListInterface as BaseChoiceListInterface; use Symfony\Component\Form\FormConfigBuilder; diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php index a2b817ed8d8ba..3519bd8f21be3 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php @@ -639,7 +639,7 @@ public function testCreateViewFlatAttrAsArray() null, // group array( 'B' => array('attr1' => 'value1'), - 'C' => array('attr2' => 'value2') + 'C' => array('attr2' => 'value2'), ) ); @@ -730,6 +730,9 @@ function ($object, $key, $value) { $this->assertFlatViewWithAttr($view); } + /** + * @group legacy + */ public function testCreateViewForLegacyChoiceList() { $preferred = array(new ChoiceView('Preferred', 'x', 'x')); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/Fixtures/LazyChoiceListImpl.php b/src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/Fixtures/LazyChoiceListImpl.php new file mode 100644 index 0000000000000..c7de003c0a85b --- /dev/null +++ b/src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/Fixtures/LazyChoiceListImpl.php @@ -0,0 +1,29 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Form\Tests\Extension\Core\ChoiceList\Fixtures; + +use Symfony\Component\Form\Extension\Core\ChoiceList\LazyChoiceList; + +class LazyChoiceListImpl extends LazyChoiceList +{ + private $choiceList; + + public function __construct($choiceList) + { + $this->choiceList = $choiceList; + } + + protected function loadChoiceList() + { + return $this->choiceList; + } +} diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/Fixtures/LazyChoiceListInvalidImpl.php b/src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/Fixtures/LazyChoiceListInvalidImpl.php new file mode 100644 index 0000000000000..7cdef5180e616 --- /dev/null +++ b/src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/Fixtures/LazyChoiceListInvalidImpl.php @@ -0,0 +1,22 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Form\Tests\Extension\Core\ChoiceList\Fixtures; + +use Symfony\Component\Form\Extension\Core\ChoiceList\LazyChoiceList; + +class LazyChoiceListInvalidImpl extends LazyChoiceList +{ + protected function loadChoiceList() + { + return new \stdClass(); + } +} diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/LazyChoiceListTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/LazyChoiceListTest.php index eee95823d4513..5504d8df7371e 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/LazyChoiceListTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/LazyChoiceListTest.php @@ -12,8 +12,9 @@ namespace Symfony\Component\Form\Tests\Extension\Core\ChoiceList; use Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList; -use Symfony\Component\Form\Extension\Core\ChoiceList\LazyChoiceList; use Symfony\Component\Form\Extension\Core\View\ChoiceView; +use Symfony\Component\Form\Tests\Extension\Core\ChoiceList\Fixtures\LazyChoiceListImpl; +use Symfony\Component\Form\Tests\Extension\Core\ChoiceList\Fixtures\LazyChoiceListInvalidImpl; /** * @group legacy @@ -21,7 +22,7 @@ class LazyChoiceListTest extends \PHPUnit_Framework_TestCase { /** - * @var LazyChoiceListTest_Impl + * @var LazyChoiceListImpl */ private $list; @@ -29,7 +30,7 @@ protected function setUp() { parent::setUp(); - $this->list = new LazyChoiceListTest_Impl(new SimpleChoiceList(array( + $this->list = new LazyChoiceListImpl(new SimpleChoiceList(array( 'a' => 'A', 'b' => 'B', 'c' => 'C', @@ -92,31 +93,8 @@ public function testGetValuesForChoices() */ public function testLoadChoiceListShouldReturnChoiceList() { - $list = new LazyChoiceListTest_InvalidImpl(); + $list = new LazyChoiceListInvalidImpl(); $list->getChoices(); } } - -class LazyChoiceListTest_Impl extends LazyChoiceList -{ - private $choiceList; - - public function __construct($choiceList) - { - $this->choiceList = $choiceList; - } - - protected function loadChoiceList() - { - return $this->choiceList; - } -} - -class LazyChoiceListTest_InvalidImpl extends LazyChoiceList -{ - protected function loadChoiceList() - { - return new \stdClass(); - } -}