Skip to content

Commit

Permalink
bug #34877 [TwigBundle] fix findTemplate() to return null
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
dpesch committed Dec 10, 2019
1 parent b81f428 commit ff1d77e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php
Expand Up @@ -96,7 +96,7 @@ protected function findTemplate($template, $throw = true)
throw $twigLoaderException;
}

return false;
return null;
}

return $this->cache[$logicalName] = $file;
Expand Down
Expand Up @@ -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));
}
}

0 comments on commit ff1d77e

Please sign in to comment.