From ff1d77e155863749b608f872cd3ae9db427f15e6 Mon Sep 17 00:00:00 2001 From: Dominik Pesch Date: Sun, 8 Dec 2019 12:31:05 +0100 Subject: [PATCH] bug #34877 [TwigBundle] fix findTemplate() to return `null` Twig3 FilesystemLoader::findTemplate() should return `string|null` instead of Twig2 `string|null|false`: see Returning `null` fixes `exists()` of Twig 3 FilesystemLoader without breaking Twig 2 (which expected `null` or `false` for not found templates). Change the test to assert `null` instead of `false`. --- src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php | 2 +- .../Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php b/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php index 3f6179d27f4d..c9fcae2179da 100644 --- a/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php +++ b/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php @@ -96,7 +96,7 @@ protected function findTemplate($template, $throw = true) throw $twigLoaderException; } - return false; + return null; } return $this->cache[$logicalName] = $file; diff --git a/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php b/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php index a33477bfd959..2d678fa8f350 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php @@ -123,6 +123,6 @@ public function testTwigSoftErrorIfTemplateDoesNotExist() $method = new \ReflectionMethod('Symfony\Bundle\TwigBundle\Loader\FilesystemLoader', 'findTemplate'); $method->setAccessible(true); - $this->assertFalse($method->invoke($loader, 'name.format.engine', false)); + $this->assertNull($method->invoke($loader, 'name.format.engine', false)); } }