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`.
This commit is contained in:
Dominik Pesch 2019-12-08 12:31:05 +01:00
parent b81f4280df
commit ff1d77e155
2 changed files with 2 additions and 2 deletions

View File

@ -96,7 +96,7 @@ class FilesystemLoader extends BaseFilesystemLoader
throw $twigLoaderException;
}
return false;
return null;
}
return $this->cache[$logicalName] = $file;

View File

@ -123,6 +123,6 @@ class FilesystemLoaderTest extends TestCase
$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));
}
}