Skip to content

[2.7] adds deprecation notices. #13060

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 13 commits into from
Jan 5, 2015
Prev Previous commit
Fixes more deprecation notices as per @stof review.
  • Loading branch information
Hugo Hamon committed Jan 5, 2015
commit f9fbb4f55ea288dff028e5608dee735d0a9cefd6
6 changes: 2 additions & 4 deletions src/Symfony/Bundle/TwigBundle/Extension/ActionsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

namespace Symfony\Bundle\TwigBundle\Extension;

trigger_error('The '.__NAMESPACE__.'\ActionsExtension class is deprecated since version 2.2 and will be removed in Symfony 3.0.', E_USER_DEPRECATED);

use Symfony\Bundle\TwigBundle\TokenParser\RenderTokenParser;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpKernel\Fragment\FragmentHandler;
Expand All @@ -31,14 +29,14 @@ class ActionsExtension extends \Twig_Extension
/**
* @param FragmentHandler|ContainerInterface $handler
*
* @deprecated Passing a ContainerInterface as a first argument is deprecated as of 2.7 and will be removed in 3.0.
* @deprecated Passing a ContainerInterface as a first argument is deprecated since 2.7 and will be removed in 3.0.
*/
public function __construct($handler)
{
if ($handler instanceof FragmentHandler) {
$this->handler = $handler;
} elseif ($handler instanceof ContainerInterface) {
trigger_error(sprintf('The ability to pass a ContainerInterface instance as a first argument to %s was deprecated in 2.7 and will be removed in 3.0. Please, pass a FragmentHandler instance instead.', __METHOD__), E_USER_DEPRECATED);
trigger_error('The ability to pass a ContainerInterface instance as a first argument to '.__METHOD__.' method is deprecated since version 2.7 and will be removed in 3.0. Pass a FragmentHandler instance instead.', E_USER_DEPRECATED);

$this->handler = $handler->get('fragment.handler');
} else {
Expand Down
8 changes: 4 additions & 4 deletions src/Symfony/Bundle/TwigBundle/TwigEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,23 @@ public function __construct(\Twig_Environment $environment, TemplateNameParserIn
}

/**
* @deprecated since version 2.3, to be removed in 3.0.
* @deprecated since version 2.7, to be removed in 3.0.
* Inject the escaping strategy on \Twig_Environment instead.
*/
public function setDefaultEscapingStrategy($strategy)
Copy link
Member

Choose a reason for hiding this comment

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

please add a deprecation warning in it (TwigBundle does not call this method anymore. It sets the strategy directly in Twig)

{
trigger_error('The '.__METHOD__.' method is deprecated since version 2.3 and will be removed in 3.0. Inject the escaping strategy in the Twig_Environment object instead.', E_USER_DEPRECATED);
trigger_error('The '.__METHOD__.' method is deprecated since version 2.7 and will be removed in 3.0. Inject the escaping strategy in the Twig_Environment object instead.', E_USER_DEPRECATED);

$this->environment->getExtension('escaper')->setDefaultStrategy($strategy);
}

/**
* @deprecated since version 2.3, to be removed in 3.0.
* @deprecated since version 2.7, to be removed in 3.0.
* Use TwigDefaultEscapingStrategy instead.
*/
public function guessDefaultEscapingStrategy($filename)
Copy link
Member

Choose a reason for hiding this comment

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

please add a warning here (TwigBundle does not use the deprecated method anymore.

{
trigger_error('The '.__METHOD__.' method is deprecated since version 2.3 and will be removed in 3.0. Use the Symfony\Bundle\TwigBundle\TwigDefaultEscapingStrategy::guess method instead.', E_USER_DEPRECATED);
trigger_error('The '.__METHOD__.' method is deprecated since version 2.7 and will be removed in 3.0. Use the Symfony\Bundle\TwigBundle\TwigDefaultEscapingStrategy::guess method instead.', E_USER_DEPRECATED);

return TwigDefaultEscapingStrategy::guess($filename);
}
Expand Down
6 changes: 0 additions & 6 deletions src/Symfony/Component/Form/Util/InheritDataAwareIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,4 @@
*/
class InheritDataAwareIterator extends VirtualFormAwareIterator
{
public function __construct(\Traversable $iterator)
{
// Do not trigger deprecation notice in parent construct method
// when using this class instead of the deprecated parent one.
parent::__construct($iterator, false);
}
}
6 changes: 3 additions & 3 deletions src/Symfony/Component/Form/Util/VirtualFormAwareIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
*/
class VirtualFormAwareIterator extends \IteratorIterator implements \RecursiveIterator
{
public function __construct(\Traversable $iterator, $triggerDeprecationNotice = true)
public function __construct(\Traversable $iterator)
{
/**
/*
* Prevent to trigger deprecation notice when already using the
* InheritDataAwareIterator class that extends this deprecated one.
* The {@link Symfony\Component\Form\Util\InheritDataAwareIterator::__construct} method
* forces this argument to false.
*/
if ($triggerDeprecationNotice) {
if (__CLASS__ === get_class($this)) {
trigger_error('The '.__CLASS__.' class is deprecated since version 2.3 and will be removed in 3.0. Use the Symfony\Component\Form\Util\InheritDataAwareIterator class instead.', E_USER_DEPRECATED);
}

Expand Down
8 changes: 1 addition & 7 deletions src/Symfony/Component/Validator/Context/ExecutionContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,6 @@ public function addViolation($message, array $parameters = array(), $invalidValu
// API, as they are not present in the new interface anymore.
// You should use buildViolation() instead.
if (func_num_args() > 2) {
trigger_error('The parameters $invalidValue, $plural and $code in method '.__METHOD__.' are deprecated since version 2.5 and will be removed in 3.0. Use the '.__CLASS__.'::buildViolation method instead.', E_USER_DEPRECATED);

throw new BadMethodCallException(
'The parameters $invalidValue, $plural and $code are '.
'not supported anymore as of Symfony 2.5. Please use '.
Expand Down Expand Up @@ -288,11 +286,7 @@ public function getGroup()
*/
public function getClassName()
{
if ($this->metadata instanceof ClassBasedInterface) {
return $this->metadata->getClassName();
}

return null;
return $this->metadata instanceof ClassBasedInterface ? $this->metadata->getClassName() : null;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ interface ExecutionContextInterface
*
* @api
*
* @deprecated since version 2.5.
* The parameters $invalidValue, $plural and $code will be removed
* in 3.0.
* @deprecated the parameters $invalidValue, $plural and $code are deprecated since version 2.5 and will be removed in 3.0.
*/
public function addViolation($message, array $params = array(), $invalidValue = null, $plural = null, $code = null);

Expand Down
4 changes: 1 addition & 3 deletions src/Symfony/Component/Yaml/Yaml.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ class Yaml
*
* @throws ParseException If the YAML is not valid
*
* @deprecated since version 2.2, to be removed in 3.0.
* The ability to pass file names to the parse() method is
* deprecated. Pass the YAML contents of the file instead.
* @deprecated The ability to pass file names to the Yaml::parse method is deprecated since version 2.2 and will be removed in 3.0. Pass the YAML contents of the file instead.
*
* @api
*/
Expand Down