8000 bug #34877 [TwigBundle] fix findTemplate() to return `null` · symfony/symfony@ff1d77e · GitHub
[go: up one dir, main page]

Skip to content

Commit ff1d77e

Browse files
committed
bug #34877 [TwigBundle] fix findTemplate() to return null
Twig3 FilesystemLoader::findTemplate() should return `string|null` instead of Twig2 `string|null|false`: see <https://github.com/twigphp/Twig/blob/3.x/src/Loader/FilesystemLoader.php#L167> 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`.
1 parent b81f428 commit ff1d77e

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ protected function findTemplate($template, $throw = true)
9696
throw $twigLoaderException;
9797
}
9898

99-
return false;
99+
return null;
100100
}
101101

102102
return $this->cache[$logicalName] = $file;

src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,6 @@ public function testTwigSoftErrorIfTemplateDoesNotExist()
123123

124124
$method = new \ReflectionMethod('Symfony\Bundle\TwigBundle\Loader\FilesystemLoader', 'findTemplate');
125125
$method->setAccessible(true);
126-
$this->assertFalse($method->invoke($loader, 'name.format.engine', false));
126+
$this->assertNull($method->invoke($loader, 'name.format.engine', false));
127127
}
128128
}

0 commit comments

Comments
 (0)
0