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

Skip to content

[Form] Moved deprecation notice triggers to file level #14201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

/**
Expand Down
26 changes: 2 additions & 24 deletions src/Symfony/Component/Form/ChoiceList/View/ChoiceView.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,6 @@
*/
class ChoiceView extends LegacyChoiceView
{
/**
* The label displayed to humans.
*
* @var string
*/
public $label;

/**
* The view representation of the choice.
*
* @var string
*/
public $value;

/**
* The original choice value.
*
* @var mixed
*/
public $data;

/**
* Additional attributes for the HTML tag.
*
Expand All @@ -58,9 +37,8 @@ class ChoiceView extends LegacyChoiceView
*/
public function __construct($label, $value, $data, array $attr = array())
{
$this->label = $label;
$this->value = $value;
$this->data = $data;
parent::__construct($data, $value, $label);

$this->attr = $attr;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -35,11 +37,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}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -97,8 +99,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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -38,8 +40,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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -29,8 +31,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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -39,8 +41,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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -42,8 +44,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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public function __construct($data, $value, $label)
$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);
// Trigger deprecation notice unless this is the new ChoiceView class
if ('Symfony\Component\Form\ChoiceList\View\ChoiceView' !== get_class($this)) {
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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,9 @@ function ($object, $key, $value) {
$this->assertFlatViewWithAttr($view);
}

/**
* @group legacy
*/
public function testCreateViewForLegacyChoiceList()
{
$preferred = array(new ChoiceView('Preferred', 'x', 'x'));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* 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;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* 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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,25 @@
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
*/
class LazyChoiceListTest extends \PHPUnit_Framework_TestCase
{
/**
* @var LazyChoiceListTest_Impl
* @var LazyChoiceListImpl
*/
private $list;

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',
Expand Down Expand Up @@ -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();
}
}