1616use Sylius \Bundle \ThemeBundle \Context \ThemeContextInterface ;
1717use Sylius \Bundle \ThemeBundle \Twig \Locator \TemplateLocatorInterface ;
1818use Sylius \Bundle \ThemeBundle \Twig \Locator \TemplateNotFoundException ;
19- use Symfony \Component \Templating \TemplateReferenceInterface ;
2019use Twig \Loader \LoaderInterface as TwigLoaderInterface ;
2120use Twig \Source ;
2221
@@ -38,76 +37,52 @@ public function __construct(
3837 $ this ->themeContext = $ themeContext ;
3938 }
4039
41- /**
42- * @param string|TemplateReferenceInterface $name
43- */
4440 public function getSourceContext ($ name ): Source
4541 {
4642 try {
4743 $ path = $ this ->locateTemplate ($ name );
4844
49- /** @psalm-suppress RedundantCastGivenDocblockType */
5045 return new Source ((string ) file_get_contents ($ path ), (string ) $ name , $ path );
51- } catch (TemplateNotFoundException | \InvalidArgumentException $ exception ) {
52- /** @psalm-suppress PossiblyInvalidArgument */
46+ } catch (TemplateNotFoundException $ exception ) {
5347 return $ this ->decoratedLoader ->getSourceContext ($ name );
5448 }
5549 }
5650
57- /**
58- * @param string|TemplateReferenceInterface $name
59- */
6051 public function getCacheKey ($ name ): string
6152 {
6253 try {
6354 return $ this ->locateTemplate ($ name );
64- } catch (TemplateNotFoundException | \InvalidArgumentException $ exception ) {
65- /** @psalm-suppress PossiblyInvalidArgument */
55+ } catch (TemplateNotFoundException $ exception ) {
6656 return $ this ->decoratedLoader ->getCacheKey ($ name );
6757 }
6858 }
6959
7060 /**
71- * @param string|TemplateReferenceInterface $name
7261 * @param int $time
7362 */
7463 public function isFresh ($ name , $ time ): bool
7564 {
7665 try {
7766 return filemtime ($ this ->locateTemplate ($ name )) <= $ time ;
78- } catch (TemplateNotFoundException | \InvalidArgumentException $ exception ) {
79- /** @psalm-suppress PossiblyInvalidArgument */
67+ } catch (TemplateNotFoundException $ exception ) {
8068 return $ this ->decoratedLoader ->isFresh ($ name , $ time );
8169 }
8270 }
8371
84- /**
85- * @param string|TemplateReferenceInterface $name
86- */
8772 public function exists ($ name ): bool
8873 {
8974 try {
9075 return stat ($ this ->locateTemplate ($ name )) !== false ;
91- } catch (TemplateNotFoundException | \InvalidArgumentException $ exception ) {
92- /** @psalm-suppress PossiblyInvalidArgument */
76+ } catch (TemplateNotFoundException $ exception ) {
9377 return $ this ->decoratedLoader ->exists ($ name );
9478 }
9579 }
9680
9781 /**
98- * @psalm-assert string $template
99- *
100- * @param string|TemplateReferenceInterface $template
101- *
102- * @throws TemplateNotFoundException|\InvalidArgumentException
82+ * @throws TemplateNotFoundException
10383 */
104- private function locateTemplate ($ template ): string
84+ private function locateTemplate (string $ template ): string
10585 {
106- if ($ template instanceof TemplateReferenceInterface) {
107- // Symfony 4.x still pushes TemplateReferenceInterface to Twig loader (especially when warming up cache)
108- throw new \InvalidArgumentException (sprintf ('Instances of "%s" are not supported. ' , TemplateReferenceInterface::class));
109- }
110-
11186 $ theme = $ this ->themeContext ->getTheme ();
11287
11388 if ($ theme === null ) {
0 commit comments