Skip to content

Deprecations #12968

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

Merged
merged 7 commits into from
Dec 20, 2014
Merged
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 @@ -15,7 +15,7 @@
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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ public function registerBundles()
return include $filename;
}

public function init()
{
}

public function getRootDir()
{
return __DIR__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ public function registerBundles()
return include $filename;
}

public function init()
{
}

public function getRootDir()
{
return __DIR__;
Expand Down
28 changes: 28 additions & 0 deletions src/Symfony/Component/Form/Deprecated/FormEvents.php
Original file line number Diff line number Diff line change
@@ -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()
{
}
}
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 <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()
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

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
Expand Down Expand Up @@ -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;

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

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

/**
Expand Down
8 changes: 5 additions & 3 deletions src/Symfony/Component/Form/FormEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

namespace Symfony\Component\Form;

use Symfony\Component\Form\Deprecated\FormEvents as Deprecated;

/**
* @author Bernhard Schussek <bschussek@gmail.com>
*/
Expand Down Expand Up @@ -77,23 +79,23 @@ 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
* {@link SUBMIT} instead.
*
* @Event
*/
const BIND = 'form.bind';
const BIND = Deprecated::BIND;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will autoload the referenced class or not? and thus trigger the deprecation even when the constant is no used at all?!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the trick: PHP lazy loads values of constants, so this won't be triggered unless used.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it true for HHVM too ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like so: http://3v4l.org/vETtp


/**
* @deprecated Deprecated since version 2.3, to be removed in 3.0. Use
* {@link POST_SUBMIT} instead.
*
* @Event
*/
const POST_BIND = 'form.post_bind';
const POST_BIND = Deprecated::POST_BIND;

private function __construct()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@
*/
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();
}
}
2 changes: 2 additions & 0 deletions src/Symfony/Component/Form/Util/VirtualFormAwareIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
8 changes: 7 additions & 1 deletion src/Symfony/Component/HttpKernel/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,13 @@ public function __construct($environment, $debug)
$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();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not convinced this is worth the overhead.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should benchmark with https://blackfire.io/ :)
As this is executed only once, I'm not sure this is relevant.
Is there any better way?

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ public function registerBundles()
{
}

public function init()
{
}

public function getBundles()
{
return array();
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy