bug #34878 [TwigBundle] fix broken FilesystemLoader::exists() with Twig 3 (dpesch)
This PR was merged into the 4.4 branch. Discussion ---------- [TwigBundle] fix broken FilesystemLoader::exists() with Twig 3 | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #34877 | License | MIT | Doc PR | This fix adapts the declaration of Twig 3 `\Twig\Loader\FilesystemLoader::findTemplate()` which expects to return `string|null` and returns `null` instead of `false`. Returning `false` breaks `\Twig\Loader\FilesystemLoader::exists()` which returns `true` if `findTemplate()` does not return `null`. Twig 2 should not be affected by this patch. The `exists()` method expects `null` or `false` for not found templates: <fdb691a424/src/Loader/FilesystemLoader.php (L169)
> Commits -------ff1d77e155
bug #34877 [TwigBundle] fix findTemplate() to return `null`
This commit is contained in:
commit
25494fa519
@ -96,7 +96,7 @@ class FilesystemLoader extends BaseFilesystemLoader
|
||||
throw $twigLoaderException;
|
||||
}
|
||||
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->cache[$logicalName] = $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));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user