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](https://github.com/symfony/symfony/pull/14050#discussion_r27568751) by @stof.

Commits
-------

a3917fc [Form] Removed remaining deprecation notices in the test suite
8f297c1 [Form] Moved deprecation notice triggers to file level
This commit is contained in:
Fabien Potencier 2015-04-19 18:51:57 +02:00
commit fc8626dcf2
13 changed files with 78 additions and 47 deletions

View File

@ -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 @@ class EntityChoiceList extends ObjectChoiceList
}
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);
}
/**

View File

@ -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 @@ class ChoiceList implements ChoiceListInterface
}
$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);
}
/**

View File

@ -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}
*/

View File

@ -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 @@ class ObjectChoiceList extends ChoiceList
$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);
}
/**

View File

@ -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.
*

View File

@ -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 @@ class ChoiceToBooleanArrayTransformer implements DataTransformerInterface
{
$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);
}
/**

View File

@ -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);
}
/**

View File

@ -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)

View File

@ -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 @@ class FixRadioInputListener implements EventSubscriberInterface
{
$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)

View File

@ -639,7 +639,7 @@ class DefaultChoiceListFactoryTest extends \PHPUnit_Framework_TestCase
null, // group
array(
'B' => array('attr1' => 'value1'),
'C' => array('attr2' => 'value2')
'C' => array('attr2' => 'value2'),
)
);
@ -730,6 +730,9 @@ class DefaultChoiceListFactoryTest extends \PHPUnit_Framework_TestCase
$this->assertFlatViewWithAttr($view);
}
/**
* @group legacy
*/
public function testCreateViewForLegacyChoiceList()
{
$preferred = array(new ChoiceView('Preferred', 'x', 'x'));

View File

@ -0,0 +1,29 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* 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;
}
}

View File

@ -0,0 +1,22 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* 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();
}
}

View File

@ -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 @@ use Symfony\Component\Form\Extension\Core\View\ChoiceView;
class LazyChoiceListTest extends \PHPUnit_Framework_TestCase
{
/**
* @var LazyChoiceListTest_Impl
* @var LazyChoiceListImpl
*/
private $list;
@ -29,7 +30,7 @@ class LazyChoiceListTest extends \PHPUnit_Framework_TestCase
{
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 @@ class LazyChoiceListTest extends \PHPUnit_Framework_TestCase
*/
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();
}
}