8000 [Form] Moved deprecation notice triggers to file level · symfony/symfony@cc259cc · GitHub
[go: up one dir, main page]

Skip to content

Commit cc259cc

Browse files
committed
[Form] Moved deprecation notice triggers to file level
1 parent 81bf910 commit cc259cc

File tree

12 files changed

+26
-44
lines changed

12 files changed

+26
-44
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/ChoiceList/View/ChoiceView.php

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,6 @@
2020
*/
2121
class ChoiceView extends LegacyChoiceView
2222
{
23-
/**
24-
* The label displayed to humans.
25-
*
26-
* @var string
27-
*/
28-
public $label;
29-
30-
/**
31-
* The view representation of the choice.
32-
*
33-
* @var string
34-
*/
35-
public $value;
36-
37-
/**
38-
* The original choice value.
39-
*
40-
* @var mixed
41-
*/
42-
public $data;
43-
4423
/**
4524
* Additional attributes for the HTML tag.
4625
*
@@ -58,9 +37,8 @@ class ChoiceView extends LegacyChoiceView
5837
*/
5938
public function __construct($label, $value, $data, array $attr = array())
6039
{
61-
$this->label = $label;
62-
$this->value = $value;
63-
$this->data = $data;
40+
parent::__construct($data, $value, $label);
41+
6442
$this->attr = $attr;
6543
}
6644
}

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/ChoiceListInterface.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__.'\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);
15+
1416
use Symfony\Component\Form\ChoiceList\ChoiceListInterface as BaseChoiceListInterface;
1517

1618
/**

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
/**
@@ -35,11 +37,6 @@ abstract class LazyChoiceList implements ChoiceListInterface
3537
*/
3638
private $choiceList;
3739

38-
public function __construct()
39-
{
40-
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);
41-
}
42-
4340
/**
4441
* {@inheritdoc}
4542
*/

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;
@@ -97,8 +99,6 @@ public function __construct($choices, $labelPath = null, array $preferredChoices
9799
$this->valuePath = null !== $valuePath ? new PropertyPath($valuePath) : null;
98100

99101
parent::__construct($choices, array(), $preferredChoices);
100-
101-
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);
102102
}
103103

104104
/**

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;
@@ -38,8 +40,6 @@ public function __construct(ChoiceListInterface $choiceList, $placeholderPresent
3840
{
3941
$this->choiceList = $choiceList;
4042
$this->placeholderPresent = $placeholderPresent;
41-
42-
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);
4343
}
4444

4545
/**

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;
@@ -29,8 +31,6 @@ class ChoicesToBooleanArrayTransformer implements DataTransformerInterface
2931
public function __construct(ChoiceListInterface $choiceList)
3032
{
3133
$this->choiceList = $choiceList;
32-
33-
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);
3434
}
3535

3636
/**

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;
@@ -39,8 +41,6 @@ class FixCheckboxInputListener implements EventSubscriberInterface
3941
public function __construct(ChoiceListInterface $choiceList)
4042
{
4143
$this->choiceList = $choiceList;
42-
43-
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);
4444
}
4545

4646
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;
@@ -42,8 +44,6 @@ public function __construct(ChoiceListInterface $choiceList, $placeholderPresent
4244
{
4345
$this->choiceList = $choiceList;
4446
$this->placeholderPresent = $placeholderPresent;
45-
46-
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);
4747
}
4848

4949
public function preSubmit(FormEvent $event)

src/Symfony/Component/Form/Extension/Core/View/ChoiceView.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ public function __construct($data, $value, $label)
5555
$this->value = $value;
5656
$this->label = $label;
5757

58-
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);
58+
// Trigger deprecation notice unless this is the new ChoiceView class
59+
if ('Symfony\Component\Form\ChoiceList\View\ChoiceView' !== get_class($this)) {
60+
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);
61+
}
5962
}
6063
}

0 commit comments

Comments
 (0)
0