Skip to content

Commit 816de64

Browse files
committed
IBX-9727: Added missing strict types and adapted the codebase to PHP 8.3
1 parent 7b51145 commit 816de64

13 files changed

+83
-72
lines changed

src/bundle/DataCollector/TwigDataCollector.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414

1515
class TwigDataCollector extends BaseCollector
1616
{
17-
private TemplatePathRegistryInterface $templatePathRegistry;
18-
19-
public function __construct(Profile $profile, Environment $environment, TemplatePathRegistryInterface $templatePathRegistry)
20-
{
17+
public function __construct(
18+
Profile $profile,
19+
Environment $environment,
20+
private TemplatePathRegistryInterface $templatePathRegistry
21+
) {
2122
parent::__construct($profile, $environment);
22-
$this->templatePathRegistry = $templatePathRegistry;
2323
}
2424

25-
private function getTemplatePathRegistry()
25+
private function getTemplatePathRegistry(): TemplatePathRegistryInterface
2626
{
2727
if (!isset($this->templatePathRegistry)) {
2828
$this->templatePathRegistry = unserialize($this->data['template_path_registry']);
@@ -31,12 +31,17 @@ private function getTemplatePathRegistry()
3131
return $this->templatePathRegistry;
3232
}
3333

34+
#[\Override]
3435
public function lateCollect(): void
3536
{
3637
parent::lateCollect();
3738
$this->data['template_path_registry'] = serialize($this->templatePathRegistry);
3839
}
3940

41+
/**
42+
* @return array<string, int>
43+
*/
44+
#[\Override]
4045
public function getTemplates(): array
4146
{
4247
$registry = $this->getTemplatePathRegistry();

src/bundle/DependencyInjection/Compiler/AssetPathResolutionPass.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ public function process(ContainerBuilder $container): void
4242
$container->setAlias('ibexadesign.asset_path_resolver', new Alias(ProvisionedPathResolver::class));
4343
}
4444

45+
/**
46+
* @param array<string, list<string>> $designPathMap
47+
*
48+
* @return array<string, array<string, string>>
49+
*/
4550
private function preResolveAssetsPaths(AssetPathProvisionerInterface $provisioner, array $designPathMap): array
4651
{
4752
$resolvedPathsByDesign = [];

src/bundle/DependencyInjection/DesignConfigParser.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313

1414
class DesignConfigParser implements ParserInterface
1515
{
16+
/**
17+
* @param array<string, mixed> $scopeSettings
18+
* @param string $currentScope
19+
*/
1620
public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerInterface $contextualizer): void
1721
{
1822
if (isset($scopeSettings['design'])) {

src/bundle/DependencyInjection/IbexaDesignEngineExtension.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
namespace Ibexa\Bundle\DesignEngine\DependencyInjection;
99

10-
use Ibexa\Bundle\Core\DependencyInjection\Configuration\SiteAccessAware\ConfigurationProcessor;
1110
use Symfony\Component\Config\Definition\ConfigurationInterface;
1211
use Symfony\Component\Config\FileLocator;
1312
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -18,11 +17,13 @@ class IbexaDesignEngineExtension extends Extension
1817
{
1918
public const string EXTENSION_NAME = 'ibexa_design_engine';
2019

20+
#[\Override]
2121
public function getAlias(): string
2222
{
2323
return self::EXTENSION_NAME;
2424
}
2525

26+
#[\Override]
2627
public function getConfiguration(array $config, ContainerBuilder $container): ?ConfigurationInterface
2728
{
2829
return new Configuration();
@@ -40,12 +41,11 @@ public function load(array $configs, ContainerBuilder $container): void
4041
$configuration = $this->getConfiguration($configs, $container);
4142
assert(null !== $configuration);
4243
$config = $this->processConfiguration($configuration, $configs);
43-
$processor = new ConfigurationProcessor($container, 'ezdesign');
4444

45-
$this->configureDesigns($config, $processor, $container);
45+
$this->configureDesigns($config, $container);
4646
}
4747

48-
private function configureDesigns(array $config, ConfigurationProcessor $processor, ContainerBuilder $container): void
48+
private function configureDesigns(array $config, ContainerBuilder $container): void
4949
{
5050
// Always add "standard" design to the list (defaults to application level & override paths only)
5151
$config['design_list'] += ['standard' => []];

src/bundle/IbexaDesignEngineBundle.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public function build(ContainerBuilder $container): void
3434
$container->addCompilerPass(new AssetPathResolutionPass(), PassConfig::TYPE_OPTIMIZE);
3535
}
3636

37+
#[\Override]
3738
public function getContainerExtension(): ?ExtensionInterface
3839
{
3940
if (!isset($this->extension)) {

src/lib/Asset/AssetPathResolver.php

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,14 @@
1212

1313
class AssetPathResolver implements AssetPathResolverInterface
1414
{
15-
/** @var array<string, string> */
16-
private array $designPaths;
17-
18-
private string $webRootDir;
19-
20-
private ?LoggerInterface $logger;
21-
22-
public function __construct(array $designPaths, string $webRootDir, LoggerInterface $logger = null)
23-
{
24-
$this->designPaths = $designPaths;
25-
$this->webRootDir = $webRootDir;
26-
$this->logger = $logger;
15+
/**
16+
* @param array<string, array<string, string>> $designPaths
17+
*/
18+
public function __construct(
19+
private readonly array $designPaths,
20+
private readonly string $webRootDir,
21+
private readonly ?LoggerInterface $logger = null
22+
) {
2723
}
2824

2925
public function resolveAssetPath(string $path, string $design): string

src/lib/Asset/ProvisionedPathResolver.php

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,18 @@
1212
class ProvisionedPathResolver implements AssetPathResolverInterface, AssetPathProvisionerInterface
1313
{
1414
/**
15-
* @var array<string, array<string, string>>
15+
* @param array<string, array<string, string>> $resolvedPaths
1616
*/
17-
private array $resolvedPaths;
18-
19-
private AssetPathResolverInterface $innerResolver;
20-
21-
private string $webRootDir;
22-
23-
public function __construct(array $resolvedPaths, AssetPathResolverInterface $innerResolver, string $webRootDir)
24-
{
25-
$this->resolvedPaths = $resolvedPaths;
26-
$this->innerResolver = $innerResolver;
27-
$this->webRootDir = $webRootDir;
17+
public function __construct(
18+
private array $resolvedPaths,
19+
private readonly AssetPathResolverInterface $innerResolver,
20+
private readonly string $webRootDir
21+
) {
2822
}
2923

3024
/**
3125
* Looks for $path within pre-resolved paths for provided design.
3226
* If it cannot be found, fallbacks to original resolver.
33-
*
34-
* {@inheritdoc}
3527
*/
3628
public function resolveAssetPath(string $path, string $design): string
3729
{

src/lib/Asset/ThemePackage.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,10 @@ class ThemePackage implements PackageInterface, DesignAwareInterface
1515
{
1616
use DesignAwareTrait;
1717

18-
private AssetPathResolverInterface $pathResolver;
19-
20-
private PackageInterface $innerPackage;
21-
22-
public function __construct(AssetPathResolverInterface $pathResolver, PackageInterface $innerPackage)
23-
{
24-
$this->pathResolver = $pathResolver;
25-
$this->innerPackage = $innerPackage;
18+
public function __construct(
19+
private AssetPathResolverInterface $pathResolver,
20+
private PackageInterface $innerPackage
21+
) {
2622
}
2723

2824
public function getUrl(string $path): string

src/lib/Templating/TemplatePathRegistry.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@ class TemplatePathRegistry implements TemplatePathRegistryInterface, Serializabl
1414
/** @var array<string, string> */
1515
private array $pathMap = [];
1616

17-
private string $kernelRootDir;
18-
19-
public function __construct(string $kernelRootDir)
20-
{
21-
$this->kernelRootDir = $kernelRootDir;
17+
public function __construct(
18+
private string $kernelRootDir
19+
) {
2220
}
2321

2422
public function mapTemplatePath(string $templateName, string $path): void
@@ -41,16 +39,22 @@ public function serialize(): ?string
4139
return serialize([$this->pathMap, $this->kernelRootDir]);
4240
}
4341

44-
public function unserialize($serialized): void
42+
public function unserialize(string $serialized): void
4543
{
4644
[$this->pathMap, $this->kernelRootDir] = unserialize($serialized);
4745
}
4846

47+
/**
48+
* @return array<array<string, string>, string>
49+
*/
4950
public function __serialize(): array
5051
{
5152
return [$this->pathMap, $this->kernelRootDir];
5253
}
5354

55+
/**
56+
* @param array<string, mixed> $data
57+
*/
5458
public function __unserialize(array $data): void
5559
{
5660
[$this->pathMap, $this->kernelRootDir] = $data;

src/lib/Templating/Twig/TwigThemeLoader.php

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,11 @@
1919
*/
2020
class TwigThemeLoader implements LoaderInterface
2121
{
22-
/**
23-
* @var \Ibexa\DesignEngine\Templating\TemplateNameResolverInterface
24-
*/
25-
private TemplateNameResolverInterface $nameResolver;
26-
27-
/**
28-
* @var \Ibexa\DesignEngine\Templating\TemplatePathRegistryInterface
29-
*/
30-
private TemplatePathRegistryInterface $pathRegistry;
31-
32-
private FilesystemLoader $innerFilesystemLoader;
33-
3422
public function __construct(
35-
TemplateNameResolverInterface $templateNameResolver,
36-
TemplatePathRegistryInterface $templatePathRegistry,
37-
FilesystemLoader $innerFilesystemLoader
23+
private readonly TemplateNameResolverInterface $nameResolver,
24+
private readonly TemplatePathRegistryInterface $pathRegistry,
25+
private readonly FilesystemLoader $innerFilesystemLoader
3826
) {
39-
$this->innerFilesystemLoader = $innerFilesystemLoader;
40-
$this->nameResolver = $templateNameResolver;
41-
$this->pathRegistry = $templatePathRegistry;
4227
}
4328

4429
public function exists(string $name): bool

0 commit comments

Comments
 (0)