minor #12968 Deprecations (jzawadzki, dkvk, nicolas-grekas, picur, mrcmorales)

This PR was merged into the 2.7 branch.

Discussion
----------

Deprecations

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #12625, #12605, #12628, #12622, #12642, #12609, #12651, #12604,  #12607, #12667, #12648
| License       | MIT
| Doc PR        | -

Cherry-picking some pending PRs to make them move forward

Commits
-------

badf8fc [Form] Log deprecation of constants, fixes #12607 #12667
1d58df4 Fix deprecation notice on VirtualFormAwareIterator
e2a19ee Add a deprecation note about VirtualFormAwareIterator
ab4d9b8 Add a deprecation note about CsrfProviderInterface
cb70632 [HttpKernel] fix deprecation notice for Kernel::init()
b5a315d [HttpKernel] Added deprecated error to init()
70012c1 [Hackday] [2.7] Add a deprecation note about TypeTestCase
This commit is contained in:
Fabien Potencier 2014-12-20 16:44:40 +01:00
commit 13fae153b0
16 changed files with 91 additions and 20 deletions

View File

@ -15,7 +15,7 @@ use Symfony\Bridge\Propel1\Tests\Fixtures\Item;
use Symfony\Bridge\Propel1\Form\PropelExtension;
use Symfony\Bridge\Propel1\Tests\Fixtures\TranslatableItemI18n;
use Symfony\Bridge\Propel1\Tests\Fixtures\TranslatableItem;
use Symfony\Component\Form\Tests\Extension\Core\Type\TypeTestCase;
use Symfony\Component\Form\Test\TypeTestCase;
class TranslationCollectionTypeTest extends TypeTestCase
{

View File

@ -74,10 +74,6 @@ class AppKernel extends Kernel
return include $filename;
}
public function init()
{
}
public function getRootDir()
{
return __DIR__;

View File

@ -74,10 +74,6 @@ class AppKernel extends Kernel
return include $filename;
}
public function init()
{
}
public function getRootDir()
{
return __DIR__;

View File

@ -0,0 +1,28 @@
<?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\Deprecated;
trigger_error('Constants PRE_BIND, BIND and POST_BIND on class Symfony\Component\Form\FormEvents were deprecated in Symfony 2.3 and will be removed in 3.0. Use PRE_SUBMIT, SUBMIT and POST_SUBMIT instead.', E_USER_DEPRECATED);
/**
* @deprecated since 2.7, to be removed in 3.0.
* @internal
*/
final class FormEvents
{
const PRE_BIND = 'form.pre_bind';
const BIND = 'form.bind';
const POST_BIND = 'form.post_bind';
private function __construct()
{
}
}

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\Deprecated;
trigger_error('Constants ROUND_HALFEVEN, ROUND_HALFUP and ROUND_HALFDOWN on class NumberToLocalizedStringTransformer were deprecated in Symfony 2.4 and will be removed in 3.0. Use ROUND_HALF_EVEN, ROUND_HALF_UP and ROUND_HALF_DOWN instead.', E_USER_DEPRECATED);
/**
* @deprecated since 2.7, to be removed in 3.0.
* @internal
*/
final class NumberToLocalizedStringTransformer
{
const ROUND_HALFEVEN = \NumberFormatter::ROUND_HALFEVEN;
const ROUND_HALFUP = \NumberFormatter::ROUND_HALFUP;
const ROUND_HALFDOWN = \NumberFormatter::ROUND_HALFDOWN;
private function __construct()
{
}
}

View File

@ -13,6 +13,7 @@ namespace Symfony\Component\Form\Extension\Core\DataTransformer;
use Symfony\Component\Form\DataTransformerInterface;
use Symfony\Component\Form\Exception\TransformationFailedException;
use Symfony\Component\Form\Deprecated\NumberToLocalizedStringTransformer as Deprecated;
/**
* Transforms between a number type and a localized number with grouping
@ -77,21 +78,21 @@ class NumberToLocalizedStringTransformer implements DataTransformerInterface
*
* @deprecated Deprecated as of Symfony 2.4, to be removed in Symfony 3.0.
*/
const ROUND_HALFEVEN = self::ROUND_HALF_EVEN;
const ROUND_HALFEVEN = Deprecated::ROUND_HALFEVEN;
/**
* Alias for {@link self::ROUND_HALF_UP}.
*
* @deprecated Deprecated as of Symfony 2.4, to be removed in Symfony 3.0.
*/
const ROUND_HALFUP = self::ROUND_HALF_UP;
const ROUND_HALFUP = Deprecated::ROUND_HALFUP;
/**
* Alias for {@link self::ROUND_HALF_DOWN}.
*
* @deprecated Deprecated as of Symfony 2.4, to be removed in Symfony 3.0.
*/
const ROUND_HALFDOWN = self::ROUND_HALF_DOWN;
const ROUND_HALFDOWN = Deprecated::ROUND_HALFDOWN;
protected $precision;

View File

@ -11,6 +11,8 @@
namespace Symfony\Component\Form\Extension\Csrf\CsrfProvider;
trigger_error('Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderAdapter was deprecated in version 2.4 and will be removed in version 3.0. Please use Symfony\Component\Security\Csrf\CsrfTokenManager instead.', E_USER_DEPRECATED);
use Symfony\Component\Form\Exception\BadMethodCallException;
use Symfony\Component\Security\Csrf\CsrfToken;
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;

View File

@ -11,6 +11,8 @@
namespace Symfony\Component\Form\Extension\Csrf\CsrfProvider;
trigger_error('Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderInterface was deprecated in version 2.4 and will be removed in version 3.0. Please use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface instead.', E_USER_DEPRECATED);
/**
* Marks classes able to provide CSRF protection
*

View File

@ -11,6 +11,8 @@
namespace Symfony\Component\Form\Extension\Csrf\CsrfProvider;
trigger_error('Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfTokenManagerAdapter was deprecated in version 2.4 and will be removed in version 3.0. Please use Symfony\Component\Security\Csrf\CsrfTokenManager instead.', E_USER_DEPRECATED);
use Symfony\Component\Security\Csrf\CsrfToken;
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;

View File

@ -11,6 +11,8 @@
namespace Symfony\Component\Form\Extension\Csrf\CsrfProvider;
trigger_error('Symfony\Component\Security\Csrf\CsrfTokenManager was deprecated in version 2.4 and will be removed in version 3.0. Please use \Symfony\Component\Security\Csrf\TokenStorage\NativeSessionTokenStorage instead.', E_USER_DEPRECATED);
/**
* Default implementation of CsrfProviderInterface.
*

View File

@ -11,6 +11,8 @@
namespace Symfony\Component\Form\Extension\Csrf\CsrfProvider;
trigger_error('Symfony\Component\Security\Csrf\CsrfTokenManager was deprecated in version 2.4 and will be removed in version 3.0. Please use Symfony\Component\Security\Csrf\TokenStorage\SessionTokenStorage instead.', E_USER_DEPRECATED);
use Symfony\Component\HttpFoundation\Session\Session;
/**

View File

@ -10,6 +10,8 @@
namespace Symfony\Component\Form;
use Symfony\Component\Form\Deprecated\FormEvents as Deprecated;
/**
* @author Bernhard Schussek <bschussek@gmail.com>
*/
@ -77,7 +79,7 @@ final class FormEvents
*
* @Event
*/
const PRE_BIND = 'form.pre_bind';
const PRE_BIND = Deprecated::PRE_BIND;
/**
* @deprecated Deprecated since version 2.3, to be removed in 3.0. Use
@ -85,7 +87,7 @@ final class FormEvents
*
* @Event
*/
const BIND = 'form.bind';
const BIND = Deprecated::BIND;
/**
* @deprecated Deprecated since version 2.3, to be removed in 3.0. Use
@ -93,7 +95,7 @@ final class FormEvents
*
* @Event
*/
const POST_BIND = 'form.post_bind';
const POST_BIND = Deprecated::POST_BIND;
private function __construct()
{

View File

@ -18,4 +18,9 @@ use Symfony\Component\Form\Test\TypeTestCase as BaseTypeTestCase;
*/
abstract class TypeTestCase extends BaseTypeTestCase
{
protected function setUp()
{
trigger_error('Abstract class "Symfony\Component\Form\Tests\Extension\Core\Type\TypeTestCase" is deprecated since version 2.3 and will be removed in 3.0. Use "Symfony\Component\Form\Test\TypeTestCase" instead.', E_USER_DEPRECATED);
parent::setUp();
}
}

View File

@ -11,6 +11,8 @@
namespace Symfony\Component\Form\Util;
trigger_error('Symfony\Component\Form\Util\VirtualFormAwareIterator is deprecated since Symfony 2.3 and will be removed in 3.0. Use Symfony\Component\Form\Util\InheritDataAwareIterator instead.', E_USER_DEPRECATED);
/**
* Iterator that traverses an array of forms.
*

View File

@ -85,7 +85,13 @@ abstract class Kernel implements KernelInterface, TerminableInterface
$this->startTime = microtime(true);
}
$this->init();
$defClass = new \ReflectionMethod($this, 'init');
$defClass = $defClass->getDeclaringClass()->name;
if (__CLASS__ !== $defClass) {
trigger_error(sprintf('Calling %s::init() was deprecated in Symfony 2.3 and will be removed in 3.0. Move your logic to the constructor instead.', $defClass), E_USER_DEPRECATED);
$this->init();
}
}
/**

View File

@ -69,10 +69,6 @@ class KernelForTest extends Kernel
{
}
public function init()
{
}
public function getBundles()
{
return array();