bug #14258 [Form] Cleanup deprecation notices (nicolas-grekas)

This PR was merged into the 2.7 branch.

Discussion
----------

[Form] Cleanup deprecation notices

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

This uses the same technique used for FlattenException in HttpKernel that prevents repeated notices triggered by the constructor.

Commits
-------

3f58862 [Form] Cleanup deprecation notices
This commit is contained in:
Bernhard Schussek 2015-04-08 11:34:58 +02:00
commit 94eb384163
13 changed files with 55 additions and 72 deletions

View File

@ -9,16 +9,17 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Symfony\Component\Form\ChoiceList\View; namespace Symfony\Component\Form\Extension\Core\View;
use Symfony\Component\Form\Extension\Core\View\ChoiceView as LegacyChoiceView;
/** /**
* Represents a choice in templates. * Represents a choice in templates.
* *
* @author Bernhard Schussek <bschussek@gmail.com> * @author Bernhard Schussek <bschussek@gmail.com>
*
* @deprecated since version 2.7, to be removed in 3.0.
* Use {@link \Symfony\Component\Form\ChoiceList\View\ChoiceView} instead.
*/ */
class ChoiceView extends LegacyChoiceView class ChoiceView
{ {
/** /**
* The label displayed to humans. * The label displayed to humans.
@ -41,6 +42,32 @@ class ChoiceView extends LegacyChoiceView
*/ */
public $data; public $data;
/**
* Creates a new ChoiceView.
*
* @param mixed $data The original choice.
* @param string $value The view representation of the choice.
* @param string $label The label displayed to humans.
*/
public function __construct($data, $value, $label)
{
$this->data = $data;
$this->value = $value;
$this->label = $label;
}
}
namespace Symfony\Component\Form\ChoiceList\View;
use Symfony\Component\Form\Extension\Core\View\ChoiceView as LegacyChoiceView;
/**
* Represents a choice in templates.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class ChoiceView extends LegacyChoiceView
{
/** /**
* Additional attributes for the HTML tag. * Additional attributes for the HTML tag.
* *
@ -58,9 +85,8 @@ class ChoiceView extends LegacyChoiceView
*/ */
public function __construct($label, $value, $data, array $attr = array()) public function __construct($label, $value, $data, array $attr = array())
{ {
$this->label = $label; parent::__construct($data, $value, $label);
$this->value = $value;
$this->data = $data;
$this->attr = $attr; $this->attr = $attr;
} }
} }

View File

@ -34,7 +34,7 @@ use Symfony\Component\Form\Extension\Core\View\ChoiceView;
* *
* @author Bernhard Schussek <bschussek@gmail.com> * @author Bernhard Schussek <bschussek@gmail.com>
* *
* @deprecated Deprecated since Symfony 2.7, to be removed in Symfony 3.0. * @deprecated since version 2.7, to be removed in 3.0.
* Use {@link \Symfony\Component\Form\ChoiceList\ArrayChoiceList} instead. * Use {@link \Symfony\Component\Form\ChoiceList\ArrayChoiceList} instead.
*/ */
class ChoiceList implements ChoiceListInterface class ChoiceList implements ChoiceListInterface

View File

@ -28,7 +28,7 @@ use Symfony\Component\Form\ChoiceList\ChoiceListInterface as BaseChoiceListInter
* *
* @author Bernhard Schussek <bschussek@gmail.com> * @author Bernhard Schussek <bschussek@gmail.com>
* *
* @deprecated Deprecated since Symfony 2.7, to be removed in Symfony 3.0. * @deprecated since version 2.7, to be removed in 3.0.
* Use {@link BaseChoiceListInterface} instead. * Use {@link BaseChoiceListInterface} instead.
*/ */
interface ChoiceListInterface extends BaseChoiceListInterface interface ChoiceListInterface extends BaseChoiceListInterface

View File

@ -22,9 +22,8 @@ use Symfony\Component\Form\Exception\InvalidArgumentException;
* *
* @author Bernhard Schussek <bschussek@gmail.com> * @author Bernhard Schussek <bschussek@gmail.com>
* *
* @deprecated Deprecated since Symfony 2.7, to be removed in Symfony 3.0. * @deprecated since version 2.7, to be removed in 3.0.
* Use {@link \Symfony\Component\Form\ChoiceList\LazyChoiceList} * Use {@link \Symfony\Component\Form\ChoiceList\LazyChoiceList} instead.
* instead.
*/ */
abstract class LazyChoiceList implements ChoiceListInterface abstract class LazyChoiceList implements ChoiceListInterface
{ {

View File

@ -33,9 +33,8 @@ use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
* *
* @author Bernhard Schussek <bschussek@gmail.com> * @author Bernhard Schussek <bschussek@gmail.com>
* *
* @deprecated Deprecated since Symfony 2.7, to be removed in Symfony 3.0. * @deprecated since Symfony 2.7, to be removed in version 3.0.
* Use {@link \Symfony\Component\Form\ChoiceList\ArrayChoiceList} * Use {@link \Symfony\Component\Form\ChoiceList\ArrayChoiceList} instead.
* instead.
*/ */
class ObjectChoiceList extends ChoiceList class ObjectChoiceList extends ChoiceList
{ {

View File

@ -29,9 +29,8 @@ namespace Symfony\Component\Form\Extension\Core\ChoiceList;
* *
* @author Bernhard Schussek <bschussek@gmail.com> * @author Bernhard Schussek <bschussek@gmail.com>
* *
* @deprecated Deprecated since Symfony 2.7, to be removed in Symfony 3.0. * @deprecated since version 2.7, to be removed in 3.0.
* Use {@link \Symfony\Component\Form\ChoiceList\ArrayChoiceList} * Use {@link \Symfony\Component\Form\ChoiceList\ArrayChoiceList} instead.
* instead.
*/ */
class SimpleChoiceList extends ChoiceList class SimpleChoiceList extends ChoiceList
{ {

View File

@ -18,9 +18,8 @@ use Symfony\Component\Form\Exception\TransformationFailedException;
/** /**
* @author Bernhard Schussek <bschussek@gmail.com> * @author Bernhard Schussek <bschussek@gmail.com>
* *
* @deprecated Deprecated since Symfony 2.7, to be removed in Symfony 3.0. * @deprecated since version 2.7, to be removed in 3.0.
* Use {@link \Symfony\Component\Form\ChoiceList\LazyChoiceList} * Use {@link \Symfony\Component\Form\ChoiceList\LazyChoiceList} instead.
* instead.
*/ */
class ChoiceToBooleanArrayTransformer implements DataTransformerInterface class ChoiceToBooleanArrayTransformer implements DataTransformerInterface
{ {

View File

@ -18,9 +18,8 @@ use Symfony\Component\Form\Exception\TransformationFailedException;
/** /**
* @author Bernhard Schussek <bschussek@gmail.com> * @author Bernhard Schussek <bschussek@gmail.com>
* *
* @deprecated Deprecated since Symfony 2.7, to be removed in Symfony 3.0. * @deprecated since version 2.7, to be removed in 3.0.
* Use {@link \Symfony\Component\Form\ChoiceList\LazyChoiceList} * Use {@link \Symfony\Component\Form\ChoiceList\LazyChoiceList} instead.
* instead.
*/ */
class ChoicesToBooleanArrayTransformer implements DataTransformerInterface class ChoicesToBooleanArrayTransformer implements DataTransformerInterface
{ {

View File

@ -23,9 +23,8 @@ use Symfony\Component\Form\FormEvents;
* *
* @author Bernhard Schussek <bschussek@gmail.com> * @author Bernhard Schussek <bschussek@gmail.com>
* *
* @deprecated Deprecated since Symfony 2.7, to be removed in Symfony 3.0. * @deprecated since version 2.7, to be removed in 3.0.
* Use {@link \Symfony\Component\Form\Extension\Core\DataMapper\CheckboxListMapper} * Use {@link \Symfony\Component\Form\Extension\Core\DataMapper\CheckboxListMapper} instead.
* instead.
*/ */
class FixCheckboxInputListener implements EventSubscriberInterface class FixCheckboxInputListener implements EventSubscriberInterface
{ {

View File

@ -22,9 +22,8 @@ use Symfony\Component\Form\FormEvents;
* *
* @author Bernhard Schussek <bschussek@gmail.com> * @author Bernhard Schussek <bschussek@gmail.com>
* *
* @deprecated Deprecated since Symfony 2.7, to be removed in Symfony 3.0. * @deprecated since version 2.7, to be removed in 3.0.
* Use {@link \Symfony\Component\Form\Extension\Core\DataMapper\RadioListMapper} * Use {@link \Symfony\Component\Form\Extension\Core\DataMapper\RadioListMapper} instead.
* instead.
*/ */
class FixRadioInputListener implements EventSubscriberInterface class FixRadioInputListener implements EventSubscriberInterface
{ {

View File

@ -11,50 +11,14 @@
namespace Symfony\Component\Form\Extension\Core\View; namespace Symfony\Component\Form\Extension\Core\View;
trigger_error('The '.__NAMESPACE__.'\ChoiceView class is deprecated since version 2.7 and will be removed in 3.0. Use Symfony\Component\Form\ChoiceList\View\ChoiceView instead.', E_USER_DEPRECATED);
/** /**
* Represents a choice in templates. * Represents a choice in templates.
* *
* @author Bernhard Schussek <bschussek@gmail.com> * @author Bernhard Schussek <bschussek@gmail.com>
* *
* @deprecated Deprecated since Symfony 2.7, to be removed in Symfony 3.0. * @deprecated since version 2.7, to be removed in 3.0.
* Use {@link \Symfony\Component\Form\ChoiceList\View\ChoiceView} instead. * Use {@link \Symfony\Component\Form\ChoiceList\View\ChoiceView} instead.
*/ */
class ChoiceView class_exists('Symfony\Component\Form\ChoiceList\View\ChoiceView');
{
/**
* The original choice value.
*
* @var mixed
*/
public $data;
/**
* The view representation of the choice.
*
* @var string
*/
public $value;
/**
* The label displayed to humans.
*
* @var string
*/
public $label;
/**
* Creates a new ChoiceView.
*
* @param mixed $data The original choice.
* @param string $value The view representation of the choice.
* @param string $label The label displayed to humans.
*/
public function __construct($data, $value, $label)
{
$this->data = $data;
$this->value = $value;
$this->label = $label;
trigger_error('The '.__CLASS__.' class is deprecated since version 2.7 and will be removed in 3.0. Use Symfony\Component\Form\ChoiceList\View\ChoiceView instead.', E_USER_DEPRECATED);
}
}

View File

@ -64,7 +64,7 @@ interface FormTypeExtensionInterface
* *
* @param OptionsResolverInterface $resolver The resolver for the options. * @param OptionsResolverInterface $resolver The resolver for the options.
* *
* @deprecated Deprecated since Symfony 2.7, to be removed in Symfony 3.0. * @deprecated since version 2.7, to be removed in 3.0.
* Use the method configureOptions instead. This method will be * Use the method configureOptions instead. This method will be
* added to the FormTypeExtensionInterface with Symfony 3.0 * added to the FormTypeExtensionInterface with Symfony 3.0
*/ */

View File

@ -73,7 +73,7 @@ interface FormTypeInterface
* *
* @param OptionsResolverInterface $resolver The resolver for the options. * @param OptionsResolverInterface $resolver The resolver for the options.
* *
* @deprecated Deprecated since Symfony 2.7, to be renamed in Symfony 3.0. * @deprecated since version 2.7, to be renamed in 3.0.
* Use the method configureOptions instead. This method will be * Use the method configureOptions instead. This method will be
* added to the FormTypeInterface with Symfony 3.0. * added to the FormTypeInterface with Symfony 3.0.
*/ */