From 8ad862b98e8c0ea509a04242c454c97e1265bd9a Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 5 Dec 2016 10:20:45 +0100 Subject: [PATCH] simplified code --- lib/Twig/Template.php | 6 ++---- test/Twig/Tests/TemplateTest.php | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/Twig/Template.php b/lib/Twig/Template.php index f6b21fa1d..3cc60787e 100644 --- a/lib/Twig/Template.php +++ b/lib/Twig/Template.php @@ -202,10 +202,6 @@ abstract class Twig_Template implements Twig_TemplateInterface throw new LogicException('A block must be a method on a Twig_Template instance.'); } - if (!$this->hasBlock($name, $context, $blocks)) { - @trigger_error(sprintf('Silent display of undefined block "%s" in template "%s" is deprecated since version 1.29 and will throw an exception in 2.0.', $name, $this->getTemplateName()), E_USER_DEPRECATED); - } - if (null !== $template) { try { $template->$block($context, $blocks); @@ -227,6 +223,8 @@ abstract class Twig_Template implements Twig_TemplateInterface } } elseif (false !== $parent = $this->getParent($context)) { $parent->displayBlock($name, $context, array_merge($this->blocks, $blocks), false); + } else { + @trigger_error(sprintf('Silent display of undefined block "%s" in template "%s" is deprecated since version 1.29 and will throw an exception in 2.0.', $name, $this->getTemplateName()), E_USER_DEPRECATED); } } diff --git a/test/Twig/Tests/TemplateTest.php b/test/Twig/Tests/TemplateTest.php index 821e2c7a8..6eb09065b 100644 --- a/test/Twig/Tests/TemplateTest.php +++ b/test/Twig/Tests/TemplateTest.php @@ -237,8 +237,8 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase /** * @group legacy - * @expectedDeprecation Displaying undefined block "unknown" in template "index.twig" is deprecated since version 1.29 and will throw an exception in 2.0. - * @expectedDeprecation Displaying undefined block "unknown" in template "index.twig" is deprecated since version 1.29 and will throw an exception in 2.0. + * @expectedDeprecation Silent display of undefined block "unknown" in template "index.twig" is deprecated since version 1.29 and will throw an exception in 2.0. + * @expectedDeprecation Silent display of undefined block "unknown" in template "index.twig" is deprecated since version 1.29 and will throw an exception in 2.0. */ public function testRenderBlockWithUndefinedBlock() {