diff --git a/Classes/Cache/HandlebarsCache.php b/Classes/Cache/HandlebarsCache.php index e2e25202..ebdbda84 100644 --- a/Classes/Cache/HandlebarsCache.php +++ b/Classes/Cache/HandlebarsCache.php @@ -23,9 +23,8 @@ namespace Fr\Typo3Handlebars\Cache; -use Symfony\Component\DependencyInjection\Attribute\AsAlias; -use Symfony\Component\DependencyInjection\Attribute\Autowire; -use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface; +use Symfony\Component\DependencyInjection; +use TYPO3\CMS\Core; /** * HandlebarsCache @@ -33,12 +32,12 @@ * @author Elias Häußler * @license GPL-2.0-or-later */ -#[AsAlias('handlebars.cache')] -class HandlebarsCache implements Cache +#[DependencyInjection\Attribute\AsAlias('handlebars.cache')] +final readonly class HandlebarsCache implements Cache { public function __construct( - #[Autowire('@cache.handlebars')] - protected readonly FrontendInterface $cache, + #[DependencyInjection\Attribute\Autowire('@cache.handlebars')] + private Core\Cache\Frontend\FrontendInterface $cache, ) {} public function get(string $template): ?string diff --git a/Classes/Cache/NullCache.php b/Classes/Cache/NullCache.php index ed47cb4f..11b0e12e 100644 --- a/Classes/Cache/NullCache.php +++ b/Classes/Cache/NullCache.php @@ -29,7 +29,7 @@ * @author Elias Häußler * @license GPL-2.0-or-later */ -final class NullCache implements Cache +final readonly class NullCache implements Cache { public function get(string $template): ?string { diff --git a/Classes/Compatibility/View/ExtbaseViewAdapter.php b/Classes/Compatibility/View/ExtbaseViewAdapter.php index 8812cab9..9dc91130 100644 --- a/Classes/Compatibility/View/ExtbaseViewAdapter.php +++ b/Classes/Compatibility/View/ExtbaseViewAdapter.php @@ -23,10 +23,9 @@ namespace Fr\Typo3Handlebars\Compatibility\View; -use Fr\Typo3Handlebars\DataProcessing\DataProcessor; -use TYPO3\CMS\Extbase\Mvc\Request; -use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext; -use TYPO3\CMS\Fluid\View\AbstractTemplateView; +use Fr\Typo3Handlebars\DataProcessing; +use TYPO3\CMS\Extbase; +use TYPO3\CMS\Fluid; /** * ExtbaseViewAdapter @@ -34,15 +33,15 @@ * @author Elias Häußler * @license GPL-2.0-or-later */ -class ExtbaseViewAdapter extends AbstractTemplateView +final class ExtbaseViewAdapter extends Fluid\View\AbstractTemplateView { /** * @var array */ - protected array $renderData = []; + private array $renderData = []; public function __construct( - protected readonly DataProcessor $processor, + private readonly DataProcessing\DataProcessor $processor, ) { parent::__construct(); } @@ -71,11 +70,11 @@ public function render($actionName = null): string $controller = null; $request = null; - if ($renderingContext instanceof RenderingContext) { + if ($renderingContext instanceof Fluid\Core\Rendering\RenderingContext) { $request = $renderingContext->getRequest(); $actionName ??= $renderingContext->getControllerAction(); } - if ($request instanceof Request) { + if ($request instanceof Extbase\Mvc\Request) { $controller = $request->getControllerObjectName(); } diff --git a/Classes/Compatibility/View/HandlebarsViewResolver.php b/Classes/Compatibility/View/HandlebarsViewResolver.php index 9f76831c..bc217647 100644 --- a/Classes/Compatibility/View/HandlebarsViewResolver.php +++ b/Classes/Compatibility/View/HandlebarsViewResolver.php @@ -23,12 +23,12 @@ namespace Fr\Typo3Handlebars\Compatibility\View; -use Fr\Typo3Handlebars\DataProcessing\DataProcessor; -use Psr\Http\Message\ServerRequestInterface; -use Symfony\Component\DependencyInjection\Attribute\Autoconfigure; -use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Extbase\Mvc\View\GenericViewResolver; -use TYPO3Fluid\Fluid\View\ViewInterface; +use Fr\Typo3Handlebars\DataProcessing; +use Psr\Http\Message; +use Symfony\Component\DependencyInjection; +use TYPO3\CMS\Core; +use TYPO3\CMS\Extbase; +use TYPO3Fluid\Fluid; /** * HandlebarsViewResolver @@ -36,15 +36,15 @@ * @author Elias Häußler * @license GPL-2.0-or-later */ -#[Autoconfigure(public: true)] -class HandlebarsViewResolver extends GenericViewResolver +#[DependencyInjection\Attribute\Autoconfigure(public: true)] +final class HandlebarsViewResolver extends Extbase\Mvc\View\GenericViewResolver { /** - * @var array> + * @var array> */ - protected array $processorMap = []; + private array $processorMap = []; - public function resolve(string $controllerObjectName, string $actionName, string $format): ViewInterface + public function resolve(string $controllerObjectName, string $actionName, string $format): Fluid\View\ViewInterface { if (!$this->hasProcessor($controllerObjectName, $actionName)) { return parent::resolve($controllerObjectName, $actionName, $format); @@ -53,19 +53,19 @@ public function resolve(string $controllerObjectName, string $actionName, string return $this->buildView($controllerObjectName, $actionName); } - protected function buildView(string $controllerClassName, string $actionName): ExtbaseViewAdapter + private function buildView(string $controllerClassName, string $actionName): ExtbaseViewAdapter { $processor = $this->getProcessor($controllerClassName, $actionName); - return GeneralUtility::makeInstance(ExtbaseViewAdapter::class, $processor); + return Core\Utility\GeneralUtility::makeInstance(ExtbaseViewAdapter::class, $processor); } - protected function hasProcessor(string $controllerClassName, string $actionName): bool + private function hasProcessor(string $controllerClassName, string $actionName): bool { return $this->getProcessor($controllerClassName, $actionName) !== null; } - protected function getProcessor(string $controllerClassName, string $actionName): ?DataProcessor + private function getProcessor(string $controllerClassName, string $actionName): ?DataProcessing\DataProcessor { if (!\array_key_exists($controllerClassName, $this->processorMap)) { return null; @@ -87,7 +87,7 @@ protected function getProcessor(string $controllerClassName, string $actionName) } /** - * @param array> $processorMap + * @param array> $processorMap */ public function setProcessorMap(array $processorMap): self { @@ -95,7 +95,7 @@ public function setProcessorMap(array $processorMap): self return $this; } - protected function getRequest(): ServerRequestInterface + private function getRequest(): Message\ServerRequestInterface { return $GLOBALS['TYPO3_REQUEST']; } diff --git a/Classes/Configuration/Extension.php b/Classes/Configuration/Extension.php index bb96469d..508aa2ef 100644 --- a/Classes/Configuration/Extension.php +++ b/Classes/Configuration/Extension.php @@ -23,8 +23,7 @@ namespace Fr\Typo3Handlebars\Configuration; -use TYPO3\CMS\Core\Core\Environment; -use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Core; /** * Extension @@ -33,7 +32,7 @@ * @license GPL-2.0-or-later * @codeCoverageIgnore */ -final class Extension +final readonly class Extension { public const KEY = 'handlebars'; public const NAME = 'Handlebars'; @@ -61,12 +60,12 @@ public static function registerCaches(): void public static function loadVendorLibraries(): void { // Vendor libraries are already available in Composer mode - if (Environment::isComposerMode()) { + if (Core\Core\Environment::isComposerMode()) { return; } - $vendorPharFile = GeneralUtility::getFileAbsFileName('EXT:handlebars/Resources/Private/Libs/vendors.phar'); - if (file_exists($vendorPharFile)) { + $vendorPharFile = Core\Utility\GeneralUtility::getFileAbsFileName('EXT:handlebars/Resources/Private/Libs/vendors.phar'); + if (is_file($vendorPharFile)) { require_once 'phar://' . $vendorPharFile . '/vendor/autoload.php'; } } diff --git a/Classes/Data/DataProvider.php b/Classes/Data/DataProvider.php index 58b9c145..ae1b3d15 100644 --- a/Classes/Data/DataProvider.php +++ b/Classes/Data/DataProvider.php @@ -23,8 +23,6 @@ namespace Fr\Typo3Handlebars\Data; -use Fr\Typo3Handlebars\Data\Response\ProviderResponse; - /** * DataProvider * @@ -36,5 +34,5 @@ interface DataProvider /** * @param array $data */ - public function get(array $data): ProviderResponse; + public function get(array $data): Response\ProviderResponse; } diff --git a/Classes/Data/Response/SimpleProviderResponse.php b/Classes/Data/Response/SimpleProviderResponse.php index b66272d6..388e15a9 100644 --- a/Classes/Data/Response/SimpleProviderResponse.php +++ b/Classes/Data/Response/SimpleProviderResponse.php @@ -29,42 +29,20 @@ * @author Elias Häußler * @license GPL-2.0-or-later * - * @implements \ArrayAccess + * @extends \ArrayObject */ -class SimpleProviderResponse implements ProviderResponse, \ArrayAccess +class SimpleProviderResponse extends \ArrayObject implements ProviderResponse { /** * @param array $data */ - public function __construct( - protected array $data = [], - ) {} - - public function offsetExists($offset): bool - { - return \array_key_exists($offset, $this->data); - } - - public function offsetGet($offset): mixed - { - if ($this->offsetExists($offset)) { - return $this->data[$offset]; - } - return null; - } - - public function offsetSet($offset, mixed $value): void - { - $this->data[$offset] = $value; - } - - public function offsetUnset($offset): void + public function __construct(array $data = []) { - unset($this->data[$offset]); + parent::__construct($data); } public function toArray(): array { - return $this->data; + return $this->getArrayCopy(); } } diff --git a/Classes/DependencyInjection/Compatibility/ExtbaseControllerCompatibilityLayer.php b/Classes/DependencyInjection/Compatibility/ExtbaseControllerCompatibilityLayer.php index 5d47693b..76ec09fa 100644 --- a/Classes/DependencyInjection/Compatibility/ExtbaseControllerCompatibilityLayer.php +++ b/Classes/DependencyInjection/Compatibility/ExtbaseControllerCompatibilityLayer.php @@ -23,14 +23,12 @@ namespace Fr\Typo3Handlebars\DependencyInjection\Compatibility; -use Fr\Typo3Handlebars\Compatibility\View\HandlebarsViewResolver; -use Fr\Typo3Handlebars\DataProcessing\DataProcessor; -use Fr\Typo3Handlebars\Exception\InvalidClassException; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Definition; -use Symfony\Component\DependencyInjection\Reference; -use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; +use Fr\Typo3Handlebars\Compatibility; +use Fr\Typo3Handlebars\DataProcessing; +use Fr\Typo3Handlebars\Exception; +use Symfony\Component\DependencyInjection; +use TYPO3\CMS\Core; +use TYPO3\CMS\Extbase; /** * ExtbaseControllerCompatibilityLayer @@ -43,13 +41,13 @@ { public const TYPE = 'extbase_controller'; - private Definition $viewResolverDefinition; + private DependencyInjection\Definition $viewResolverDefinition; public function __construct( - private ContainerBuilder $container, + private DependencyInjection\ContainerBuilder $container, ) { - $this->viewResolverDefinition = $this->container->getDefinition(HandlebarsViewResolver::class); - $this->validateService(HandlebarsViewResolver::class); + $this->viewResolverDefinition = $this->container->getDefinition(Compatibility\View\HandlebarsViewResolver::class); + $this->validateService(Compatibility\View\HandlebarsViewResolver::class); } public function provide(string $processorServiceId, array $configuration): bool @@ -64,8 +62,8 @@ public function provide(string $processorServiceId, array $configuration): bool // Validate controller class name $this->validateService($controller); - $actions = GeneralUtility::trimExplode(',', $configuration['actions'] ?? '_all', true); - $actionMap = array_fill_keys($actions, new Reference($processorServiceId)); + $actions = Core\Utility\GeneralUtility::trimExplode(',', $configuration['actions'] ?? '_all', true); + $actionMap = array_fill_keys($actions, new DependencyInjection\Reference($processorServiceId)); // Merge and apply processor map $processorMap = $this->buildProcessorMap($controllerClassName, $actionMap); @@ -76,15 +74,15 @@ public function provide(string $processorServiceId, array $configuration): bool // Apply processor map and register method call $controllerDefinition->removeMethodCall('injectViewResolver'); - $controllerDefinition->addMethodCall('injectViewResolver', [new Reference($viewResolverClassName)]); + $controllerDefinition->addMethodCall('injectViewResolver', [new DependencyInjection\Reference($viewResolverClassName)]); return true; } /** * @param class-string $controllerClassName - * @param array $actionMap - * @return array> + * @param array $actionMap + * @return array> */ private function buildProcessorMap(string $controllerClassName, array $actionMap): array { @@ -124,9 +122,9 @@ private function validateConfiguration(array $configuration): void 1632814520 ); } - if (!\in_array(ActionController::class, class_parents($this->container->getDefinition($configuration['controller'])->getClass()) ?: [])) { + if (!\in_array(Extbase\Mvc\Controller\ActionController::class, class_parents($this->container->getDefinition($configuration['controller'])->getClass()) ?: [])) { throw new \InvalidArgumentException( - \sprintf('Only extbase controllers extending from "%s" are supported, found in: %s', ActionController::class, $configuration['controller']), + \sprintf('Only extbase controllers extending from "%s" are supported, found in: %s', Extbase\Mvc\Controller\ActionController::class, $configuration['controller']), 1632814592 ); } @@ -145,10 +143,10 @@ private function validateService(string $serviceId): void $className = $definition->getClass(); if ($className === null) { - throw InvalidClassException::forService($serviceId); + throw Exception\InvalidClassException::forService($serviceId); } if (!class_exists($className)) { - throw InvalidClassException::create($className); + throw Exception\InvalidClassException::create($className); } } } diff --git a/Classes/DependencyInjection/Compatibility/ProcessorCompatibility.php b/Classes/DependencyInjection/Compatibility/ProcessorCompatibility.php index 03eecfa7..e02660af 100644 --- a/Classes/DependencyInjection/Compatibility/ProcessorCompatibility.php +++ b/Classes/DependencyInjection/Compatibility/ProcessorCompatibility.php @@ -23,8 +23,8 @@ namespace Fr\Typo3Handlebars\DependencyInjection\Compatibility; -use Fr\Typo3Handlebars\Exception\UnsupportedTypeException; -use Symfony\Component\DependencyInjection\ContainerBuilder; +use Fr\Typo3Handlebars\Exception; +use Symfony\Component\DependencyInjection; /** * ProcessorCompatibility @@ -41,7 +41,7 @@ public function __construct( private string $serviceId, private array $tagAttributes, - private ContainerBuilder $container, + private DependencyInjection\ContainerBuilder $container, ) { $this->validate(); } @@ -57,13 +57,13 @@ public function provideCompatibility(): void } /** - * @throws UnsupportedTypeException + * @throws Exception\UnsupportedTypeException */ private function buildLayerForType(string $type): CompatibilityLayer { return match ($type) { ExtbaseControllerCompatibilityLayer::TYPE => new ExtbaseControllerCompatibilityLayer($this->container), - default => throw UnsupportedTypeException::create($type), + default => throw Exception\UnsupportedTypeException::create($type), }; } diff --git a/Classes/DependencyInjection/Extension/Configuration.php b/Classes/DependencyInjection/Extension/Configuration.php index fa58954d..f26c6c5e 100644 --- a/Classes/DependencyInjection/Extension/Configuration.php +++ b/Classes/DependencyInjection/Extension/Configuration.php @@ -23,8 +23,7 @@ namespace Fr\Typo3Handlebars\DependencyInjection\Extension; -use Symfony\Component\Config\Definition\Builder\TreeBuilder; -use Symfony\Component\Config\Definition\ConfigurationInterface; +use Symfony\Component\Config; /** * HandlebarsExtension configuration structure. @@ -43,11 +42,11 @@ * @internal * @codeCoverageIgnore */ -final class Configuration implements ConfigurationInterface +final readonly class Configuration implements Config\Definition\ConfigurationInterface { - public function getConfigTreeBuilder(): TreeBuilder + public function getConfigTreeBuilder(): Config\Definition\Builder\TreeBuilder { - $treeBuilder = new TreeBuilder('handlebars'); + $treeBuilder = new Config\Definition\Builder\TreeBuilder('handlebars'); /* @phpstan-ignore method.notFound */ $treeBuilder diff --git a/Classes/DependencyInjection/Extension/HandlebarsExtension.php b/Classes/DependencyInjection/Extension/HandlebarsExtension.php index a0d45ca0..f48d9d2e 100644 --- a/Classes/DependencyInjection/Extension/HandlebarsExtension.php +++ b/Classes/DependencyInjection/Extension/HandlebarsExtension.php @@ -23,9 +23,8 @@ namespace Fr\Typo3Handlebars\DependencyInjection\Extension; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Extension\Extension; -use TYPO3\CMS\Core\Utility\ArrayUtility; +use Symfony\Component\DependencyInjection; +use TYPO3\CMS\Core; /** * HandlebarsExtension @@ -34,7 +33,7 @@ * @license GPL-2.0-or-later * @internal */ -final class HandlebarsExtension extends Extension +final class HandlebarsExtension extends DependencyInjection\Extension\Extension { public const PARAMETER_TEMPLATE_ROOT_PATHS = 'handlebars.templateRootPaths'; public const PARAMETER_PARTIAL_ROOT_PATHS = 'handlebars.partialRootPaths'; @@ -58,7 +57,7 @@ final class HandlebarsExtension extends Extension /** * @param array[] $configs */ - public function load(array $configs, ContainerBuilder $container): void + public function load(array $configs, DependencyInjection\ContainerBuilder $container): void { $this->reset(); $this->parseConfiguration($configs); @@ -91,7 +90,7 @@ private function mergeConfigs(array $configs, string $configKey): array $mergedConfig = []; foreach (array_column($configs, $configKey) as $concreteConfig) { - ArrayUtility::mergeRecursiveWithOverrule($mergedConfig, $concreteConfig); + Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($mergedConfig, $concreteConfig); } return $mergedConfig; diff --git a/Classes/Event/AfterRenderingEvent.php b/Classes/Event/AfterRenderingEvent.php index 96b82ae2..f27bc2b0 100644 --- a/Classes/Event/AfterRenderingEvent.php +++ b/Classes/Event/AfterRenderingEvent.php @@ -31,7 +31,7 @@ * @author Elias Häußler * @license GPL-2.0-or-later */ -class AfterRenderingEvent +final class AfterRenderingEvent { public function __construct( private readonly string $templatePath, diff --git a/Classes/Event/BeforeRenderingEvent.php b/Classes/Event/BeforeRenderingEvent.php index 78143db7..7a56a1ad 100644 --- a/Classes/Event/BeforeRenderingEvent.php +++ b/Classes/Event/BeforeRenderingEvent.php @@ -31,7 +31,7 @@ * @author Elias Häußler * @license GPL-2.0-or-later */ -class BeforeRenderingEvent +final class BeforeRenderingEvent { /** * @param array $variables diff --git a/Classes/Renderer/Component/Layout/HandlebarsLayout.php b/Classes/Renderer/Component/Layout/HandlebarsLayout.php index 7b8bc16a..1245b569 100644 --- a/Classes/Renderer/Component/Layout/HandlebarsLayout.php +++ b/Classes/Renderer/Component/Layout/HandlebarsLayout.php @@ -29,20 +29,20 @@ * @author Elias Häußler * @license GPL-2.0-or-later */ -class HandlebarsLayout +final class HandlebarsLayout { - protected bool $parsed = false; + private bool $parsed = false; /** * @var array> */ - protected array $actions = []; + private array $actions = []; /** * @param callable $parseFunction */ public function __construct( - protected $parseFunction, + private $parseFunction, ) {} public function parse(): void diff --git a/Classes/Renderer/HandlebarsRenderer.php b/Classes/Renderer/HandlebarsRenderer.php index edaae349..e9833d08 100644 --- a/Classes/Renderer/HandlebarsRenderer.php +++ b/Classes/Renderer/HandlebarsRenderer.php @@ -23,27 +23,18 @@ namespace Fr\Typo3Handlebars\Renderer; -use Fr\Typo3Handlebars\Cache\Cache; -use Fr\Typo3Handlebars\Cache\NullCache; -use Fr\Typo3Handlebars\Event\AfterRenderingEvent; -use Fr\Typo3Handlebars\Event\BeforeRenderingEvent; -use Fr\Typo3Handlebars\Exception\InvalidTemplateFileException; -use Fr\Typo3Handlebars\Exception\PartialPathIsNotResolvable; -use Fr\Typo3Handlebars\Exception\TemplateCompilationException; -use Fr\Typo3Handlebars\Exception\TemplatePathIsNotResolvable; -use Fr\Typo3Handlebars\Renderer\Helper\HelperRegistry; -use Fr\Typo3Handlebars\Renderer\Template\TemplateResolver; +use Fr\Typo3Handlebars\Cache; +use Fr\Typo3Handlebars\Event; +use Fr\Typo3Handlebars\Exception; use LightnCandy\Context; use LightnCandy\LightnCandy; use LightnCandy\Partial; use LightnCandy\Runtime; -use Psr\EventDispatcher\EventDispatcherInterface; -use Psr\Log\LoggerInterface; -use Symfony\Component\DependencyInjection\Attribute\AsAlias; -use Symfony\Component\DependencyInjection\Attribute\Autoconfigure; -use Symfony\Component\DependencyInjection\Attribute\Autowire; -use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; +use Psr\EventDispatcher; +use Psr\Log; +use Symfony\Component\DependencyInjection; +use TYPO3\CMS\Core; +use TYPO3\CMS\Frontend; /** * HandlebarsRenderer @@ -51,20 +42,20 @@ * @author Elias Häußler * @license GPL-2.0-or-later */ -#[AsAlias('handlebars.renderer')] -#[Autoconfigure(tags: ['handlebars.renderer'])] +#[DependencyInjection\Attribute\AsAlias('handlebars.renderer')] +#[DependencyInjection\Attribute\Autoconfigure(tags: ['handlebars.renderer'])] class HandlebarsRenderer implements Renderer { protected readonly bool $debugMode; public function __construct( - #[Autowire('@handlebars.cache')] - protected readonly Cache $cache, - protected readonly EventDispatcherInterface $eventDispatcher, - protected readonly HelperRegistry $helperRegistry, - protected readonly LoggerInterface $logger, - #[Autowire('@handlebars.template_resolver')] - protected readonly TemplateResolver $templateResolver, + #[DependencyInjection\Attribute\Autowire('@handlebars.cache')] + protected readonly Cache\Cache $cache, + protected readonly EventDispatcher\EventDispatcherInterface $eventDispatcher, + protected readonly Helper\HelperRegistry $helperRegistry, + protected readonly Log\LoggerInterface $logger, + #[DependencyInjection\Attribute\Autowire('@handlebars.template_resolver')] + protected readonly Template\TemplateResolver $templateResolver, protected readonly Variables\VariableBag $variableBag, ) { $this->debugMode = $this->isDebugModeEnabled(); @@ -74,7 +65,7 @@ public function render(string $templatePath, array $data = []): string { try { return $this->processRendering($templatePath, $data); - } catch (InvalidTemplateFileException | TemplateCompilationException | TemplatePathIsNotResolvable $exception) { + } catch (Exception\InvalidTemplateFileException | Exception\TemplateCompilationException | Exception\TemplatePathIsNotResolvable $exception) { $this->logger->critical($exception->getMessage(), ['exception' => $exception]); return ''; @@ -83,9 +74,9 @@ public function render(string $templatePath, array $data = []): string /** * @param array $variables - * @throws InvalidTemplateFileException - * @throws TemplateCompilationException - * @throws TemplatePathIsNotResolvable + * @throws Exception\InvalidTemplateFileException + * @throws Exception\TemplateCompilationException + * @throws Exception\TemplatePathIsNotResolvable */ protected function processRendering(string $templatePath, array $variables): string { @@ -94,7 +85,7 @@ protected function processRendering(string $templatePath, array $variables): str // Throw exception if template file is invalid if ($template === false) { - throw new InvalidTemplateFileException($fullTemplatePath, 1606217313); + throw new Exception\InvalidTemplateFileException($fullTemplatePath, 1606217313); } // Early return if template is empty @@ -110,7 +101,7 @@ protected function processRendering(string $templatePath, array $variables): str $renderer = $this->prepareCompileResult($compileResult); // Dispatch before rendering event - $beforeRenderingEvent = new BeforeRenderingEvent($fullTemplatePath, $mergedVariables, $this); + $beforeRenderingEvent = new Event\BeforeRenderingEvent($fullTemplatePath, $mergedVariables, $this); $this->eventDispatcher->dispatch($beforeRenderingEvent); // Render content @@ -120,7 +111,7 @@ protected function processRendering(string $templatePath, array $variables): str ]); // Dispatch after rendering event - $afterRenderingEvent = new AfterRenderingEvent($fullTemplatePath, $content, $this); + $afterRenderingEvent = new Event\AfterRenderingEvent($fullTemplatePath, $content, $this); $this->eventDispatcher->dispatch($afterRenderingEvent); return $afterRenderingEvent->getContent(); @@ -131,14 +122,14 @@ protected function processRendering(string $templatePath, array $variables): str * * @param string $template Raw template to be compiled * @return string The compiled template - * @throws TemplateCompilationException if template compilation fails and errors are not yet handled by compiler + * @throws Exception\TemplateCompilationException() if template compilation fails and errors are not yet handled by compiler */ protected function compile(string $template): string { // Disable cache if debugging is enabled or caching is disabled $cache = $this->cache; if ($this->debugMode || $this->isCachingDisabled()) { - $cache = new NullCache(); + $cache = new Cache\NullCache(); } // Get compile result from cache @@ -153,7 +144,7 @@ protected function compile(string $template): string if ($compileResult === false) { $errors = LightnCandy::getContext()['error'] ?? []; - throw new TemplateCompilationException( + throw new Exception\TemplateCompilationException( \sprintf( 'Error during template compilation: "%s"', implode('", "', \is_array($errors) ? $errors : [$errors]) @@ -194,24 +185,26 @@ protected function getCompileFlags(): int protected function prepareCompileResult(string $compileResult): callable { // Touch temporary file - $path = GeneralUtility::tempnam('hbs_'); + $path = Core\Utility\GeneralUtility::tempnam('hbs_'); - // Write file and validate write result - /** @var string|null $writeResult */ - $writeResult = GeneralUtility::writeFileToTypo3tempDir($path, ' $context Current context of compiler progress, see {@see Context::create()} * @param string $name Name of the partial to be resolved * @return string|null Partial file contents if partial could be resolved, `null` otherwise - * @throws PartialPathIsNotResolvable + * @throws Exception\PartialPathIsNotResolvable */ public function resolvePartial(array $context, string $name): ?string { @@ -267,7 +260,7 @@ protected function isDebugModeEnabled(): bool return (bool)($GLOBALS['TYPO3_CONF_VARS']['FE']['debug'] ?? false); } - protected function getTypoScriptFrontendController(): ?TypoScriptFrontendController + protected function getTypoScriptFrontendController(): ?Frontend\Controller\TypoScriptFrontendController { return $GLOBALS['TSFE'] ?? null; } diff --git a/Tests/Unit/Data/Response/SimpleProviderResponseTest.php b/Tests/Unit/Data/Response/SimpleProviderResponseTest.php index 287322f6..bf80065d 100644 --- a/Tests/Unit/Data/Response/SimpleProviderResponseTest.php +++ b/Tests/Unit/Data/Response/SimpleProviderResponseTest.php @@ -53,7 +53,7 @@ public function objectCanBeAccessedAsArray(): void // Testing offsetGet self::assertSame('baz', $this->subject['foo']); - self::assertNull($this->subject['baz']); + self::assertNull($this->subject['baz'] ?? null); // Testing offsetSet $this->subject['baz'] = 'dummy'; @@ -63,7 +63,7 @@ public function objectCanBeAccessedAsArray(): void // Testing offsetUnset unset($this->subject['baz']); self::assertFalse(isset($this->subject['baz'])); - self::assertNull($this->subject['baz']); + self::assertNull($this->subject['baz'] ?? null); } #[Framework\Attributes\Test]