diff --git a/composer.json b/composer.json index 657d21c..2c7ef0b 100644 --- a/composer.json +++ b/composer.json @@ -18,20 +18,20 @@ ], "require": { "php": " >=8.3", - "ibexa/core": "~5.0.x-dev", - "symfony/asset": "^5.0", - "symfony/config": "^5.0", - "symfony/dependency-injection": "^5.0", - "symfony/filesystem": "^5.0", - "symfony/finder": "^5.0", - "symfony/http-foundation": "^5.0", - "symfony/http-kernel": "^5.0", - "symfony/templating": "^5.0", + "ibexa/core": "dev-ibx-8470-symfony-6 as 5.0.x-dev", + "symfony/asset": "^6.4", + "symfony/config": "^6.4", + "symfony/dependency-injection": "^6.4", + "symfony/filesystem": "^6.4", + "symfony/finder": "^6.4", + "symfony/http-foundation": "^6.4", + "symfony/http-kernel": "^6.4", + "symfony/templating": "^6.4", "twig/twig": "^3.0" }, "require-dev": { "ibexa/code-style": "~2.0.0", - "ibexa/doctrine-schema": "~5.0.x-dev", + "ibexa/doctrine-schema": "dev-ibx-8470-symfony-6 as 5.0.x-dev", "mikey179/vfsstream": "^1.6", "phpunit/phpunit": "^9.6" }, diff --git a/src/bundle/DataCollector/TwigDataCollector.php b/src/bundle/DataCollector/TwigDataCollector.php index f506b8b..c842b1f 100644 --- a/src/bundle/DataCollector/TwigDataCollector.php +++ b/src/bundle/DataCollector/TwigDataCollector.php @@ -9,18 +9,12 @@ use Ibexa\DesignEngine\Templating\TemplatePathRegistryInterface; use Symfony\Bridge\Twig\DataCollector\TwigDataCollector as BaseCollector; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\DataCollector\LateDataCollectorInterface; use Twig\Environment; use Twig\Profiler\Profile; -class TwigDataCollector extends BaseCollector implements LateDataCollectorInterface +class TwigDataCollector extends BaseCollector { - /** - * @var \Ibexa\DesignEngine\Templating\TemplatePathRegistryInterface - */ - private $templatePathRegistry; + private TemplatePathRegistryInterface $templatePathRegistry; public function __construct(Profile $profile, Environment $environment, TemplatePathRegistryInterface $templatePathRegistry) { @@ -37,28 +31,13 @@ private function getTemplatePathRegistry() return $this->templatePathRegistry; } - public function collect(Request $request, Response $response, \Throwable $exception = null) - { - parent::collect($request, $response, $exception); - } - - public function lateCollect() + public function lateCollect(): void { parent::lateCollect(); $this->data['template_path_registry'] = serialize($this->templatePathRegistry); } - public function getTime() - { - return parent::getTime(); - } - - public function getTemplateCount() - { - return parent::getTemplateCount(); - } - - public function getTemplates() + public function getTemplates(): array { $registry = $this->getTemplatePathRegistry(); $templates = []; @@ -68,26 +47,4 @@ public function getTemplates() return $templates; } - - public function getBlockCount() - { - return parent::getBlockCount(); - } - - public function getMacroCount() - { - return parent::getMacroCount(); - } - - public function getHtmlCallGraph() - { - return parent::getHtmlCallGraph(); - } - - public function getProfile() - { - $profile = parent::getProfile(); - - return $profile; - } } diff --git a/src/bundle/DependencyInjection/Compiler/AssetPathResolutionPass.php b/src/bundle/DependencyInjection/Compiler/AssetPathResolutionPass.php index 8b38f9f..f719cd8 100644 --- a/src/bundle/DependencyInjection/Compiler/AssetPathResolutionPass.php +++ b/src/bundle/DependencyInjection/Compiler/AssetPathResolutionPass.php @@ -23,7 +23,10 @@ */ class AssetPathResolutionPass implements CompilerPassInterface { - public function process(ContainerBuilder $container) + /** + * @throws \Exception + */ + public function process(ContainerBuilder $container): void { if ($container->getParameter('ibexa.design.assets.resolution.disabled')) { return; @@ -39,7 +42,7 @@ public function process(ContainerBuilder $container) $container->setAlias('ibexadesign.asset_path_resolver', new Alias(ProvisionedPathResolver::class)); } - private function preResolveAssetsPaths(AssetPathProvisionerInterface $provisioner, array $designPathMap) + private function preResolveAssetsPaths(AssetPathProvisionerInterface $provisioner, array $designPathMap): array { $resolvedPathsByDesign = []; foreach ($designPathMap as $design => $paths) { diff --git a/src/bundle/DependencyInjection/Compiler/AssetThemePass.php b/src/bundle/DependencyInjection/Compiler/AssetThemePass.php index bcf8489..858692e 100644 --- a/src/bundle/DependencyInjection/Compiler/AssetThemePass.php +++ b/src/bundle/DependencyInjection/Compiler/AssetThemePass.php @@ -15,7 +15,7 @@ class AssetThemePass implements CompilerPassInterface { - public function process(ContainerBuilder $container) + public function process(ContainerBuilder $container): void { if (!($container->hasParameter('kernel.bundles') && $container->hasParameter('webroot_dir') && $container->hasDefinition('assets.packages'))) { return; @@ -50,7 +50,7 @@ public function process(ContainerBuilder $container) if (is_dir($appLevelThemeDir)) { foreach ((new Finder())->directories()->in($appLevelThemeDir)->depth('== 0') as $directoryInfo) { $theme = $directoryInfo->getBasename(); - $themePaths = isset($themesPathMap[$theme]) ? $themesPathMap[$theme] : []; + $themePaths = $themesPathMap[$theme] ?? []; // Application level paths are always top priority. array_unshift($themePaths, 'assets/themes/' . $theme); $themesPathMap[$theme] = $themePaths; diff --git a/src/bundle/DependencyInjection/Compiler/TwigThemePass.php b/src/bundle/DependencyInjection/Compiler/TwigThemePass.php index cddd5e4..159bf59 100644 --- a/src/bundle/DependencyInjection/Compiler/TwigThemePass.php +++ b/src/bundle/DependencyInjection/Compiler/TwigThemePass.php @@ -23,7 +23,10 @@ */ class TwigThemePass implements CompilerPassInterface { - public function process(ContainerBuilder $container) + /** + * @throws \ReflectionException + */ + public function process(ContainerBuilder $container): void { if (!($container->hasParameter('kernel.bundles') && $container->hasDefinition(TwigThemeLoader::class))) { return; @@ -50,7 +53,10 @@ public function process(ContainerBuilder $container) $twigLoaderDef = $container->findDefinition(TwigThemeLoader::class); // Now look for themes at application level - $appLevelThemesDir = $container->getParameter('twig.default_path') . '/themes'; + $appLevelThemesDir = $container->getParameterBag()->resolveValue( + $container->getParameter('twig.default_path') . '/themes' + ); + if (is_dir($appLevelThemesDir)) { foreach ((new Finder())->directories()->in($appLevelThemesDir)->depth('== 0') as $directoryInfo) { $theme = $directoryInfo->getBasename(); diff --git a/src/bundle/DependencyInjection/DesignConfigParser.php b/src/bundle/DependencyInjection/DesignConfigParser.php index 7282e01..c1d83eb 100644 --- a/src/bundle/DependencyInjection/DesignConfigParser.php +++ b/src/bundle/DependencyInjection/DesignConfigParser.php @@ -13,22 +13,24 @@ class DesignConfigParser implements ParserInterface { - public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerInterface $contextualizer) + public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerInterface $contextualizer): void { if (isset($scopeSettings['design'])) { $contextualizer->setContextualParameter('design', $currentScope, $scopeSettings['design']); } } - public function preMap(array $config, ContextualizerInterface $contextualizer) + public function preMap(array $config, ContextualizerInterface $contextualizer): void { + // Nothing to map } - public function postMap(array $config, ContextualizerInterface $contextualizer) + public function postMap(array $config, ContextualizerInterface $contextualizer): void { + // Nothing to map } - public function addSemanticConfig(NodeBuilder $nodeBuilder) + public function addSemanticConfig(NodeBuilder $nodeBuilder): void { $nodeBuilder ->scalarNode('design') diff --git a/src/bundle/DependencyInjection/IbexaDesignEngineExtension.php b/src/bundle/DependencyInjection/IbexaDesignEngineExtension.php index 849a21c..ae1887a 100644 --- a/src/bundle/DependencyInjection/IbexaDesignEngineExtension.php +++ b/src/bundle/DependencyInjection/IbexaDesignEngineExtension.php @@ -16,7 +16,7 @@ class IbexaDesignEngineExtension extends Extension { - public const EXTENSION_NAME = 'ibexa_design_engine'; + public const string EXTENSION_NAME = 'ibexa_design_engine'; public function getAlias(): string { @@ -28,20 +28,24 @@ public function getConfiguration(array $config, ContainerBuilder $container): ?C return new Configuration(); } - public function load(array $configs, ContainerBuilder $container) + /** + * @throws \Exception + */ + public function load(array $configs, ContainerBuilder $container): void { $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); $loader->load('services.yaml'); $loader->load('default_settings.yaml'); $configuration = $this->getConfiguration($configs, $container); + assert(null !== $configuration); $config = $this->processConfiguration($configuration, $configs); $processor = new ConfigurationProcessor($container, 'ezdesign'); $this->configureDesigns($config, $processor, $container); } - private function configureDesigns(array $config, ConfigurationProcessor $processor, ContainerBuilder $container) + private function configureDesigns(array $config, ConfigurationProcessor $processor, ContainerBuilder $container): void { // Always add "standard" design to the list (defaults to application level & override paths only) $config['design_list'] += ['standard' => []]; diff --git a/src/bundle/IbexaDesignEngineBundle.php b/src/bundle/IbexaDesignEngineBundle.php index 6af98ac..065c3bb 100644 --- a/src/bundle/IbexaDesignEngineBundle.php +++ b/src/bundle/IbexaDesignEngineBundle.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\DesignEngine; @@ -19,7 +20,7 @@ class IbexaDesignEngineBundle extends Bundle { - public function build(ContainerBuilder $container) + public function build(ContainerBuilder $container): void { parent::build($container); diff --git a/src/contracts/DesignAwareInterface.php b/src/contracts/DesignAwareInterface.php index 5cad927..de6ef46 100644 --- a/src/contracts/DesignAwareInterface.php +++ b/src/contracts/DesignAwareInterface.php @@ -4,12 +4,13 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Contracts\DesignEngine; interface DesignAwareInterface { - public const DESIGN_NAMESPACE = 'ibexadesign'; + public const string DESIGN_NAMESPACE = 'ibexadesign'; public function getCurrentDesign(): ?string; } diff --git a/src/lib/Asset/AssetPathProvisionerInterface.php b/src/lib/Asset/AssetPathProvisionerInterface.php index a33f0a9..589e380 100644 --- a/src/lib/Asset/AssetPathProvisionerInterface.php +++ b/src/lib/Asset/AssetPathProvisionerInterface.php @@ -11,12 +11,12 @@ interface AssetPathProvisionerInterface { /** * Pre-resolves assets paths for a given design from themes paths, where are stored physical assets. - * Returns an map with asset logical path as key and its resolved path (relative to webroot dir) as value. + * Returns a map with asset logical path as key and its resolved path (relative to webroot dir) as value. * Example => ['images/foo.png' => 'asset/themes/some_theme/images/foo.png']. * - * @param string $design + * @param string[] $assetsPaths * - * @return array + * @return array */ - public function provisionResolvedPaths(array $assetsPaths, $design); + public function provisionResolvedPaths(array $assetsPaths, string $design): array; } diff --git a/src/lib/Asset/AssetPathResolver.php b/src/lib/Asset/AssetPathResolver.php index 41e141c..e213299 100644 --- a/src/lib/Asset/AssetPathResolver.php +++ b/src/lib/Asset/AssetPathResolver.php @@ -12,20 +12,12 @@ class AssetPathResolver implements AssetPathResolverInterface { - /** - * @var array - */ - private $designPaths; + /** @var array */ + private array $designPaths; - /** - * @var string - */ - private $webRootDir; + private string $webRootDir; - /** - * @var \Psr\Log\LoggerInterface - */ - private $logger; + private ?LoggerInterface $logger; public function __construct(array $designPaths, $webRootDir, LoggerInterface $logger = null) { @@ -34,7 +26,7 @@ public function __construct(array $designPaths, $webRootDir, LoggerInterface $lo $this->logger = $logger; } - public function resolveAssetPath($path, $design) + public function resolveAssetPath(string $path, string $design): string { if (!isset($this->designPaths[$design])) { throw new InvalidDesignException("Invalid design '$design'"); @@ -46,14 +38,12 @@ public function resolveAssetPath($path, $design) } } - if ($this->logger) { - $this->logger->warning( - "Asset '$path' cannot be found in any configured themes.\nTried directories: " . implode( - ', ', - array_values($this->designPaths[$design]) - ) - ); - } + $this->logger?->warning( + "Asset '$path' cannot be found in any configured themes.\nTried directories: " . implode( + ', ', + array_values($this->designPaths[$design]) + ) + ); return $path; } diff --git a/src/lib/Asset/AssetPathResolverInterface.php b/src/lib/Asset/AssetPathResolverInterface.php index a08c9b6..3627cce 100644 --- a/src/lib/Asset/AssetPathResolverInterface.php +++ b/src/lib/Asset/AssetPathResolverInterface.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\DesignEngine\Asset; @@ -18,8 +19,6 @@ interface AssetPathResolverInterface * * @param string $path Asset path to resolve * @param string $design Design to resolve path for - * - * @return string */ - public function resolveAssetPath($path, $design); + public function resolveAssetPath(string $path, string $design): string; } diff --git a/src/lib/Asset/ProvisionedPathResolver.php b/src/lib/Asset/ProvisionedPathResolver.php index e91d7ec..a22a0b7 100644 --- a/src/lib/Asset/ProvisionedPathResolver.php +++ b/src/lib/Asset/ProvisionedPathResolver.php @@ -12,19 +12,13 @@ class ProvisionedPathResolver implements AssetPathResolverInterface, AssetPathProvisionerInterface { /** - * @var array + * @var array> */ - private $resolvedPaths; + private array $resolvedPaths; - /** - * @var AssetPathResolverInterface - */ - private $innerResolver; + private AssetPathResolverInterface $innerResolver; - /** - * @var string - */ - private $webRootDir; + private string $webRootDir; public function __construct(array $resolvedPaths, AssetPathResolverInterface $innerResolver, $webRootDir) { @@ -39,22 +33,19 @@ public function __construct(array $resolvedPaths, AssetPathResolverInterface $in * * {@inheritdoc} */ - public function resolveAssetPath($path, $design) + public function resolveAssetPath(string $path, string $design): string { - if (!isset($this->resolvedPaths[$design][$path])) { - return $this->innerResolver->resolveAssetPath($path, $design); - } - - return $this->resolvedPaths[$design][$path]; + return $this->resolvedPaths[$design][$path] ?? $this->innerResolver->resolveAssetPath($path, $design); } - public function provisionResolvedPaths(array $assetsPaths, $design) + public function provisionResolvedPaths(array $assetsPaths, string $design): array { $webrootDir = $this->webRootDir; $assetsLogicalPaths = []; foreach ($assetsPaths as $path) { - $themePath = "$webrootDir/$path"; - $assetsLogicalPaths = array_merge($assetsLogicalPaths, $this->computeLogicalPathFromPhysicalAssets($themePath)); + foreach ($this->computeLogicalPathFromPhysicalAssets("$webrootDir/$path") as $logicalPath) { + $assetsLogicalPaths[] = $logicalPath; + } } $resolvedPaths = []; @@ -72,11 +63,9 @@ public function provisionResolvedPaths(array $assetsPaths, $design) * This exclusion mainly applies to override directories, * e.g. "assets/", which is both an override dir and where app level themes can be defined. * - * @param string $themePath - * - * @return array + * @phpstan-return list */ - private function computeLogicalPathFromPhysicalAssets($themePath) + private function computeLogicalPathFromPhysicalAssets(string $themePath): array { if (!is_dir($themePath)) { return []; diff --git a/src/lib/Asset/ThemePackage.php b/src/lib/Asset/ThemePackage.php index 29feb91..c7e82b2 100644 --- a/src/lib/Asset/ThemePackage.php +++ b/src/lib/Asset/ThemePackage.php @@ -15,15 +15,9 @@ class ThemePackage implements PackageInterface, DesignAwareInterface { use DesignAwareTrait; - /** - * @var AssetPathResolverInterface - */ - private $pathResolver; + private AssetPathResolverInterface $pathResolver; - /** - * @var \Symfony\Component\Asset\PackageInterface - */ - private $innerPackage; + private PackageInterface $innerPackage; public function __construct(AssetPathResolverInterface $pathResolver, PackageInterface $innerPackage) { @@ -31,12 +25,12 @@ public function __construct(AssetPathResolverInterface $pathResolver, PackageInt $this->innerPackage = $innerPackage; } - public function getUrl($path) + public function getUrl(string $path): string { return $this->innerPackage->getUrl($this->pathResolver->resolveAssetPath($path, $this->getCurrentDesign())); } - public function getVersion($path) + public function getVersion(string $path): string { return $this->innerPackage->getVersion($this->pathResolver->resolveAssetPath($path, $this->getCurrentDesign())); } diff --git a/src/lib/DesignAwareTrait.php b/src/lib/DesignAwareTrait.php index 45ae87b..feb1bd2 100644 --- a/src/lib/DesignAwareTrait.php +++ b/src/lib/DesignAwareTrait.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\DesignEngine; @@ -11,10 +12,7 @@ trait DesignAwareTrait { - /** - * @var \Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface - */ - private $configResolver; + private ConfigResolverInterface $configResolver; public function setConfigResolver(ConfigResolverInterface $configResolver): void { diff --git a/src/lib/Templating/TemplateNameResolverInterface.php b/src/lib/Templating/TemplateNameResolverInterface.php index 93880fe..b452ed3 100644 --- a/src/lib/Templating/TemplateNameResolverInterface.php +++ b/src/lib/Templating/TemplateNameResolverInterface.php @@ -15,27 +15,15 @@ */ interface TemplateNameResolverInterface extends DesignAwareInterface { - /** - * @deprecated since Ibexa 4.0. Use - * {@see \Ibexa\Contracts\DesignEngine\DesignAwareInterface::DESIGN_NAMESPACE} instead. - */ - public const EZ_DESIGN_NAMESPACE = 'ezdesign'; - /** * Resolves provided template name within current design and returns properly namespaced template name. * * @param string $name Template name to resolve - * - * @return string */ - public function resolveTemplateName($name); + public function resolveTemplateName(string $name): string; /** - * Checks if provided template name is using @ibexadesign namespace. - * - * @param string $name - * - * @return bool + * Checks if provided template name is using `@ibexadesign` namespace. */ - public function isTemplateDesignNamespaced($name); + public function isTemplateDesignNamespaced(string $name): bool; } diff --git a/src/lib/Templating/TemplatePathRegistry.php b/src/lib/Templating/TemplatePathRegistry.php index 9cddb81..81e8d80 100644 --- a/src/lib/Templating/TemplatePathRegistry.php +++ b/src/lib/Templating/TemplatePathRegistry.php @@ -12,37 +12,36 @@ class TemplatePathRegistry implements TemplatePathRegistryInterface, Serializable { /** @var array */ - private $pathMap = []; + private array $pathMap = []; - /** @var string */ - private $kernelRootDir; + private string $kernelRootDir; public function __construct($kernelRootDir) { $this->kernelRootDir = $kernelRootDir; } - public function mapTemplatePath($templateName, $path) + public function mapTemplatePath(string $templateName, string $path): void { $this->pathMap[$templateName] = str_replace($this->kernelRootDir . '/', '', $path); } - public function getTemplatePath($templateName) + public function getTemplatePath(string $templateName): string { - return isset($this->pathMap[$templateName]) ? $this->pathMap[$templateName] : $templateName; + return $this->pathMap[$templateName] ?? $templateName; } - public function getPathMap() + public function getPathMap(): array { return $this->pathMap; } - public function serialize() + public function serialize(): ?string { return serialize([$this->pathMap, $this->kernelRootDir]); } - public function unserialize($serialized) + public function unserialize($serialized): void { [$this->pathMap, $this->kernelRootDir] = unserialize($serialized); } diff --git a/src/lib/Templating/TemplatePathRegistryInterface.php b/src/lib/Templating/TemplatePathRegistryInterface.php index 3994b09..4900692 100644 --- a/src/lib/Templating/TemplatePathRegistryInterface.php +++ b/src/lib/Templating/TemplatePathRegistryInterface.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\DesignEngine\Templating; @@ -19,21 +20,14 @@ interface TemplatePathRegistryInterface * @param string $templateName The template logical name * @param string $path Template path */ - public function mapTemplatePath($templateName, $path); + public function mapTemplatePath(string $templateName, string $path): void; - /** - * Returns path for given template. - * - * @param string $templateName - * - * @return string - */ - public function getTemplatePath($templateName); + public function getTemplatePath(string $templateName): string; /** * Returns the whole hash map. * - * @return array + * @return array */ - public function getPathMap(); + public function getPathMap(): array; } diff --git a/src/lib/Templating/ThemeTemplateNameResolver.php b/src/lib/Templating/ThemeTemplateNameResolver.php index ae68dc5..333792d 100644 --- a/src/lib/Templating/ThemeTemplateNameResolver.php +++ b/src/lib/Templating/ThemeTemplateNameResolver.php @@ -17,16 +17,16 @@ class ThemeTemplateNameResolver implements TemplateNameResolverInterface /** * Collection of already resolved template names. * - * @var array + * @var array */ - private $resolvedTemplateNames = []; + private array $resolvedTemplateNames = []; public function __construct(ConfigResolverInterface $configResolver) { $this->setConfigResolver($configResolver); } - public function resolveTemplateName($name) + public function resolveTemplateName(string $name): string { if (!$this->isTemplateDesignNamespaced($name)) { return $name; @@ -39,8 +39,9 @@ public function resolveTemplateName($name) )); } - public function isTemplateDesignNamespaced($name) + public function isTemplateDesignNamespaced(string $name): bool { - return (strpos($name, '@' . static::DESIGN_NAMESPACE) !== false) || (strpos($name, '@' . $this->getCurrentDesign()) !== false); + return str_contains($name, '@' . static::DESIGN_NAMESPACE) + || (str_contains($name, '@' . $this->getCurrentDesign())); } } diff --git a/src/lib/Templating/Twig/TwigThemeLoader.php b/src/lib/Templating/Twig/TwigThemeLoader.php index 58e281e..1097db2 100644 --- a/src/lib/Templating/Twig/TwigThemeLoader.php +++ b/src/lib/Templating/Twig/TwigThemeLoader.php @@ -22,38 +22,30 @@ class TwigThemeLoader implements LoaderInterface /** * @var \Ibexa\DesignEngine\Templating\TemplateNameResolverInterface */ - private $nameResolver; + private TemplateNameResolverInterface $nameResolver; /** * @var \Ibexa\DesignEngine\Templating\TemplatePathRegistryInterface */ - private $pathRegistry; + private TemplatePathRegistryInterface $pathRegistry; - /** - * @var \Twig\Loader\FilesystemLoader - */ - private $innerFilesystemLoader; + private FilesystemLoader $innerFilesystemLoader; public function __construct( TemplateNameResolverInterface $templateNameResolver, TemplatePathRegistryInterface $templatePathRegistry, - LoaderInterface $innerFilesystemLoader + FilesystemLoader $innerFilesystemLoader ) { $this->innerFilesystemLoader = $innerFilesystemLoader; $this->nameResolver = $templateNameResolver; $this->pathRegistry = $templatePathRegistry; } - public function exists($name) + public function exists(string $name): bool { return $this->innerFilesystemLoader->exists($this->nameResolver->resolveTemplateName($name)); } - public function getSource($name) - { - return $this->innerFilesystemLoader->getSource($this->nameResolver->resolveTemplateName($name)); - } - public function getSourceContext(string $name): Source { $source = $this->innerFilesystemLoader->getSourceContext($this->nameResolver->resolveTemplateName((string)$name)); @@ -72,27 +64,36 @@ public function isFresh(string $name, int $time): bool return $this->innerFilesystemLoader->isFresh($this->nameResolver->resolveTemplateName($name), $time); } - public function getPaths($namespace = FilesystemLoader::MAIN_NAMESPACE) + public function getPaths(string $namespace = FilesystemLoader::MAIN_NAMESPACE): array { return $this->innerFilesystemLoader->getPaths($namespace); } - public function getNamespaces() + public function getNamespaces(): array { return $this->innerFilesystemLoader->getNamespaces(); } - public function setPaths($paths, $namespace = FilesystemLoader::MAIN_NAMESPACE) + /** + * @param string|string[] $paths + */ + public function setPaths(string|array $paths, $namespace = FilesystemLoader::MAIN_NAMESPACE): void { $this->innerFilesystemLoader->setPaths($paths, $namespace); } - public function addPath($path, $namespace = FilesystemLoader::MAIN_NAMESPACE) + /** + * @throws \Twig\Error\LoaderError + */ + public function addPath(string $path, string $namespace = FilesystemLoader::MAIN_NAMESPACE): void { $this->innerFilesystemLoader->addPath($path, $namespace); } - public function prependPath($path, $namespace = FilesystemLoader::MAIN_NAMESPACE) + /** + * @throws \Twig\Error\LoaderError + */ + public function prependPath(string $path, string $namespace = FilesystemLoader::MAIN_NAMESPACE): void { $this->innerFilesystemLoader->prependPath($path, $namespace); } diff --git a/tests/bundle/.gitkeep b/tests/bundle/.gitkeep new file mode 100644 index 0000000..e69de29