deprecated passing a string as a source on Twig_Error

This commit is contained in:
Fabien Potencier
2019-01-12 03:31:07 +01:00
parent 69633fc191
commit 2d66fa85a5
4 changed files with 10 additions and 3 deletions
+1
View File
@@ -1,5 +1,6 @@
* 2.6.1 (2018-XX-XX)
* deprecated passing a string as a source on Twig_Error
* switched generated code to use the PHP short array notation
* 2.6.0 (2018-12-16)
+6
View File
@@ -13,6 +13,12 @@ Inheritance
``Twig_Error_Syntax`` exception. It does not work anyway, so most projects
won't need to do anything to upgrade.
Errors
------
* Passing a string as the ``$source`` argument on ``Twig_Error`` constructor is
deprecated since Twig 2.6.1. Pass an instance of ``Twig_Source`` instead.
Tags
----
+1 -1
View File
@@ -63,7 +63,7 @@ class Twig_Error extends Exception
if (null === $source) {
$name = null;
} elseif (!$source instanceof Twig_Source) {
// for compat with the Twig C ext., passing the template name as string is accepted
@trigger_error(sprintf('Passing a string as a source to %s is deprecated since version 2.6.1; pass a Twig_Source instance instead.', __CLASS__), E_USER_DEPRECATED);
$name = $source;
} else {
$name = $source->getName();
+2 -2
View File
@@ -206,9 +206,9 @@ abstract class Twig_Template
} elseif (false !== $parent = $this->getParent($context)) {
$parent->displayBlock($name, $context, array_merge($this->blocks, $blocks), false);
} elseif (isset($blocks[$name])) {
throw new Twig_Error_Runtime(sprintf('Block "%s" should not call parent() in "%s" as the block does not exist in the parent template "%s".', $name, $blocks[$name][0]->getTemplateName(), $this->getTemplateName()), -1, $blocks[$name][0]->getTemplateName());
throw new Twig_Error_Runtime(sprintf('Block "%s" should not call parent() in "%s" as the block does not exist in the parent template "%s".', $name, $blocks[$name][0]->getTemplateName(), $this->getTemplateName()), -1, $blocks[$name][0]->getSourceContext());
} else {
throw new Twig_Error_Runtime(sprintf('Block "%s" on template "%s" does not exist.', $name, $this->getTemplateName()), -1, $this->getTemplateName());
throw new Twig_Error_Runtime(sprintf('Block "%s" on template "%s" does not exist.', $name, $this->getTemplateName()), -1, $this->getSourceContext());
}
}