Skip to content

Commit 62adf16

Browse files
committed
IBX-9727: Added type-hints and adapted codebase to PHP8+
1 parent f36e831 commit 62adf16

File tree

79 files changed

+563
-1076
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+563
-1076
lines changed

phpstan-baseline.neon

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,7 @@
11
parameters:
22
ignoreErrors:
3-
-
4-
message: '#^Binary operation "\." between array\|bool\|float\|int\|string\|null and ''/vendor/'' results in an error\.$#'
5-
identifier: binaryOp.invalid
6-
count: 1
7-
path: src/bundle/DependencyInjection/IbexaSystemInfoExtension.php
8-
9-
-
10-
message: '#^Method Ibexa\\Bundle\\SystemInfo\\DependencyInjection\\IbexaSystemInfoExtension\:\:getConfiguration\(\) has parameter \$config with no value type specified in iterable type array\.$#'
11-
identifier: missingType.iterableValue
12-
count: 1
13-
path: src/bundle/DependencyInjection/IbexaSystemInfoExtension.php
14-
153
-
164
message: '#^Parameter \#4 \$condition of method Doctrine\\DBAL\\Query\\QueryBuilder\:\:innerJoin\(\) expects string\|null, Doctrine\\DBAL\\Query\\Expression\\CompositeExpression given\.$#'
175
identifier: argument.type
186
count: 1
197
path: src/lib/Storage/Metrics/DraftsCountMetrics.php
20-
21-
-
22-
message: '#^Parameter \#1 \$items of class Ibexa\\Bundle\\SystemInfo\\SystemInfo\\Registry\\IdentifierBased constructor expects array\<Ibexa\\Bundle\\SystemInfo\\SystemInfo\\Collector\\SystemInfoCollector\>, array\<Ibexa\\Bundle\\SystemInfo\\SystemInfo\\Collector\\SystemInfoCollector\|PHPUnit\\Framework\\MockObject\\MockObject\> given\.$#'
23-
identifier: argument.type
24-
count: 3
25-
path: tests/bundle/SystemInfo/Registry/IdentifierBasedTest.php

src/bundle/Command/SystemInfoDumpCommand.php

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* @copyright Copyright (C) Ibexa AS. All rights reserved.
55
* @license For full copyright and license information view LICENSE file distributed with this source code.
66
*/
7+
declare(strict_types=1);
78

89
namespace Ibexa\Bundle\SystemInfo\Command;
910

@@ -22,15 +23,10 @@
2223
)]
2324
final class SystemInfoDumpCommand extends Command
2425
{
25-
private SystemInfoCollectorRegistry $systemInfoCollectorRegistry;
26-
27-
private OutputFormatRegistry $outputFormatRegistry;
28-
29-
public function __construct(SystemInfoCollectorRegistry $systemInfoCollectorRegistry, OutputFormatRegistry $outputFormatRegistry)
30-
{
31-
$this->systemInfoCollectorRegistry = $systemInfoCollectorRegistry;
32-
$this->outputFormatRegistry = $outputFormatRegistry;
33-
26+
public function __construct(
27+
private readonly SystemInfoCollectorRegistry $systemInfoCollectorRegistry,
28+
private readonly OutputFormatRegistry $outputFormatRegistry
29+
) {
3430
parent::__construct();
3531
}
3632

@@ -39,10 +35,10 @@ protected function configure(): void
3935
$this
4036
->setHelp(
4137
<<<'EOD'
42-
By default it dumps information from all available information collectors.
43-
You can specify one or more collectors as arguments, e.g. 'php database hardware'.
44-
To get a list if available collectors, use '--list-info-collectors'
45-
EOD
38+
By default it dumps information from all available information collectors.
39+
You can specify one or more collectors as arguments, e.g. 'php database hardware'.
40+
To get a list if available collectors, use '--list-info-collectors'
41+
EOD
4642
)
4743
->addOption(
4844
'list-info-collectors',
@@ -65,16 +61,11 @@ protected function configure(): void
6561
;
6662
}
6763

68-
/**
69-
* Execute the Command.
70-
*
71-
* @param $input InputInterface
72-
* @param $output OutputInterface
73-
*/
7464
protected function execute(InputInterface $input, OutputInterface $output): int
7565
{
7666
if ($input->getOption('list-info-collectors')) {
7767
$output->writeln('Available info collectors:', OutputInterface::OUTPUT_NORMAL);
68+
7869
foreach ($this->systemInfoCollectorRegistry->getIdentifiers() as $identifier) {
7970
$output->writeln(" $identifier", OutputInterface::OUTPUT_NORMAL);
8071
}

src/bundle/Controller/SystemInfoController.php

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* @copyright Copyright (C) Ibexa AS. All rights reserved.
55
* @license For full copyright and license information view LICENSE file distributed with this source code.
66
*/
7+
declare(strict_types=1);
78

89
namespace Ibexa\Bundle\SystemInfo\Controller;
910

@@ -13,29 +14,20 @@
1314
use Ibexa\Core\MVC\Symfony\Security\Authorization\Attribute;
1415
use Symfony\Component\HttpFoundation\Response;
1516

16-
class SystemInfoController extends AdminUiController
17+
final class SystemInfoController extends AdminUiController
1718
{
18-
protected SystemInfoCollectorRegistry $collectorRegistry;
19-
20-
/**
21-
* @param \Ibexa\Bundle\SystemInfo\SystemInfo\SystemInfoCollectorRegistry $collectorRegistry
22-
*/
23-
public function __construct(SystemInfoCollectorRegistry $collectorRegistry)
24-
{
25-
$this->collectorRegistry = $collectorRegistry;
19+
public function __construct(
20+
private readonly SystemInfoCollectorRegistry $collectorRegistry
21+
) {
2622
}
2723

2824
public function performAccessCheck(): void
2925
{
3026
parent::performAccessCheck();
27+
3128
$this->denyAccessUnlessGranted(new Attribute('setup', 'system_info'));
3229
}
3330

34-
/**
35-
* Renders the system information page.
36-
*
37-
* @return \Symfony\Component\HttpFoundation\Response
38-
*/
3931
public function infoAction(): Response
4032
{
4133
return $this->render('@ibexadesign/system_info/info.html.twig', [
@@ -48,9 +40,6 @@ public function viewInfoAction(SystemInfoView $view): SystemInfoView
4840
return $view;
4941
}
5042

51-
/**
52-
* Renders a PHP info page.
53-
*/
5443
public function phpinfoAction(): Response
5544
{
5645
ob_start();

src/bundle/DependencyInjection/Compiler/OutputFormatPass.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* @copyright Copyright (C) Ibexa AS. All rights reserved.
55
* @license For full copyright and license information view LICENSE file distributed with this source code.
66
*/
7+
declare(strict_types=1);
78

89
namespace Ibexa\Bundle\SystemInfo\DependencyInjection\Compiler;
910

@@ -12,13 +13,8 @@
1213
use Symfony\Component\DependencyInjection\ContainerBuilder;
1314
use Symfony\Component\DependencyInjection\Reference;
1415

15-
class OutputFormatPass implements CompilerPassInterface
16+
final readonly class OutputFormatPass implements CompilerPassInterface
1617
{
17-
/**
18-
* Registers the OutputFormat tagged services into the output format registry.
19-
*
20-
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
21-
*/
2218
public function process(ContainerBuilder $container): void
2319
{
2420
if (!$container->has(OutputFormatRegistry::class)) {

src/bundle/DependencyInjection/Compiler/SystemInfoCollectorPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use Symfony\Component\DependencyInjection\ContainerBuilder;
1414
use Symfony\Component\DependencyInjection\Reference;
1515

16-
class SystemInfoCollectorPass implements CompilerPassInterface
16+
final readonly class SystemInfoCollectorPass implements CompilerPassInterface
1717
{
1818
public function process(ContainerBuilder $container): void
1919
{

src/bundle/DependencyInjection/Compiler/SystemInfoTabGroupPass.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* @copyright Copyright (C) Ibexa AS. All rights reserved.
55
* @license For full copyright and license information view LICENSE file distributed with this source code.
66
*/
7+
declare(strict_types=1);
78

89
namespace Ibexa\Bundle\SystemInfo\DependencyInjection\Compiler;
910

@@ -13,10 +14,7 @@
1314
use Symfony\Component\DependencyInjection\ContainerBuilder;
1415
use Symfony\Component\DependencyInjection\Definition;
1516

16-
/**
17-
* {@inheritdoc}
18-
*/
19-
class SystemInfoTabGroupPass implements CompilerPassInterface
17+
final readonly class SystemInfoTabGroupPass implements CompilerPassInterface
2018
{
2119
/**
2220
* @throws \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException

src/bundle/DependencyInjection/IbexaSystemInfoExtension.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,20 @@
1818
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
1919
use Symfony\Component\DependencyInjection\Loader;
2020

21-
class IbexaSystemInfoExtension extends Extension implements PrependExtensionInterface
21+
final class IbexaSystemInfoExtension extends Extension implements PrependExtensionInterface
2222
{
23-
public const EXTENSION_NAME = 'ibexa_system_info';
24-
public const METRICS_TAG = 'ibexa.system_info.metrics';
25-
public const SERVICE_TAG = 'ibexa.system_info.service';
23+
public const string EXTENSION_NAME = 'ibexa_system_info';
24+
public const string METRICS_TAG = 'ibexa.system_info.metrics';
25+
public const string SERVICE_TAG = 'ibexa.system_info.service';
2626

2727
public function getAlias(): string
2828
{
2929
return self::EXTENSION_NAME;
3030
}
3131

32+
/**
33+
* @param array<string, mixed> $config
34+
*/
3235
public function getConfiguration(array $config, ContainerBuilder $container): Configuration
3336
{
3437
return new Configuration();
@@ -54,7 +57,6 @@ public function load(array $configs, ContainerBuilder $container): void
5457
$container->setParameter(
5558
'ibexa.system_info.powered_by.name',
5659
$this->getPoweredByName(
57-
$container,
5860
$config['system_info']['powered_by']['release']
5961
)
6062
);
@@ -66,12 +68,10 @@ public function prepend(ContainerBuilder $container): void
6668
$this->prependJMSTranslation($container);
6769
}
6870

69-
private function getPoweredByName(ContainerBuilder $container, ?string $release): string
71+
private function getPoweredByName(?string $release): string
7072
{
71-
$vendor = $container->getParameter('kernel.project_dir') . '/vendor/';
72-
7373
// Autodetect product name
74-
$name = self::getNameByPackages($vendor);
74+
$name = self::getNameByPackages();
7575

7676
if ($release === 'major') {
7777
$name .= ' v' . (int)Ibexa::VERSION;
@@ -112,8 +112,10 @@ public static function getEditionByPackages(): string
112112
return 'oss';
113113
}
114114

115-
public static function getNameByPackages(string $vendor = null): string
115+
public static function getNameByPackages(): string
116116
{
117-
return IbexaSystemInfo::PRODUCT_NAME_VARIANTS[self::getEditionByPackages()];
117+
return IbexaSystemInfo::PRODUCT_NAME_VARIANTS[
118+
self::getEditionByPackages()
119+
];
118120
}
119121
}

src/bundle/EventSubscriber/AddXPoweredByHeader.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,10 @@
1515
/**
1616
* Sets X-Powered-By header to promote use of Platform.
1717
*/
18-
class AddXPoweredByHeader implements EventSubscriberInterface
18+
final readonly class AddXPoweredByHeader implements EventSubscriberInterface
1919
{
20-
/**
21-
* @var string If empty, this powered by header is skipped.
22-
*/
23-
private string $installationName;
24-
25-
public function __construct(string $installationName)
20+
public function __construct(private string $installationName)
2621
{
27-
$this->installationName = $installationName;
2822
}
2923

3024
public static function getSubscribedEvents(): array

src/bundle/IbexaSystemInfoBundle.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* @copyright Copyright (C) Ibexa AS. All rights reserved.
55
* @license For full copyright and license information view LICENSE file distributed with this source code.
66
*/
7+
declare(strict_types=1);
78

89
namespace Ibexa\Bundle\SystemInfo;
910

@@ -15,19 +16,17 @@
1516
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
1617
use Symfony\Component\HttpKernel\Bundle\Bundle;
1718

18-
class IbexaSystemInfoBundle extends Bundle
19+
final class IbexaSystemInfoBundle extends Bundle
1920
{
2021
public function build(ContainerBuilder $container): void
2122
{
2223
parent::build($container);
24+
2325
$container->addCompilerPass(new SystemInfoCollectorPass());
2426
$container->addCompilerPass(new OutputFormatPass());
2527
$container->addCompilerPass(new SystemInfoTabGroupPass());
2628
}
2729

28-
/**
29-
* {@inheritdoc}
30-
*/
3130
public function getContainerExtension(): ExtensionInterface
3231
{
3332
return new IbexaSystemInfoExtension();

src/bundle/Resources/config/services.yaml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,13 @@ services:
4141

4242
Ibexa\Bundle\SystemInfo\SystemInfo\OutputFormatRegistry: ~
4343

44-
Ibexa\Bundle\SystemInfo\SystemInfo\EzcSystemInfoWrapper:
44+
Ibexa\Bundle\SystemInfo\SystemInfo\SystemInfoWrapper:
4545
lazy: true
4646

4747
# SystemInfoCollectors
4848
Ibexa\Bundle\SystemInfo\SystemInfo\Collector\IbexaSystemInfoCollector:
4949
arguments:
50-
$composerCollector: '@Ibexa\Bundle\SystemInfo\SystemInfo\Collector\JsonComposerLockSystemInfoCollector'
51-
$kernelProjectDir: '%kernel.project_dir%'
50+
$collector: '@Ibexa\Bundle\SystemInfo\SystemInfo\Collector\JsonComposerLockSystemInfoCollector'
5251
tags:
5352
- { name: ibexa.system_info.collector, identifier: ibexa }
5453

@@ -69,19 +68,19 @@ services:
6968
lazy: true
7069
autowire: true
7170
arguments:
72-
$db: '@ibexa.persistence.connection'
71+
$connection: '@ibexa.persistence.connection'
7372
tags:
7473
- { name: ibexa.system_info.collector, identifier: repository }
7574

76-
Ibexa\Bundle\SystemInfo\SystemInfo\Collector\EzcHardwareSystemInfoCollector:
75+
Ibexa\Bundle\SystemInfo\SystemInfo\Collector\HardwareSystemInfoCollector:
7776
arguments:
78-
- '@Ibexa\Bundle\SystemInfo\SystemInfo\EzcSystemInfoWrapper'
77+
- '@Ibexa\Bundle\SystemInfo\SystemInfo\SystemInfoWrapper'
7978
tags:
8079
- { name: ibexa.system_info.collector, identifier: hardware }
8180

82-
Ibexa\Bundle\SystemInfo\SystemInfo\Collector\EzcPhpSystemInfoCollector:
81+
Ibexa\Bundle\SystemInfo\SystemInfo\Collector\PhpSystemInfoCollector:
8382
arguments:
84-
- '@Ibexa\Bundle\SystemInfo\SystemInfo\EzcSystemInfoWrapper'
83+
- '@Ibexa\Bundle\SystemInfo\SystemInfo\SystemInfoWrapper'
8584
tags:
8685
- { name: ibexa.system_info.collector, identifier: php }
8786

@@ -108,7 +107,7 @@ services:
108107

109108
Ibexa\SystemInfo\Storage\AggregateMetricsProvider:
110109
arguments:
111-
$metrics: !tagged_locator
110+
$metricsLocator: !tagged_locator
112111
tag: !php/const \Ibexa\Bundle\SystemInfo\DependencyInjection\IbexaSystemInfoExtension::METRICS_TAG
113112
index_by: identifier
114113

@@ -158,7 +157,7 @@ services:
158157

159158
Ibexa\SystemInfo\Service\AggregateServiceProvider:
160159
arguments:
161-
$service: !tagged_locator
160+
$serviceLocator: !tagged_locator
162161
tag: !php/const \Ibexa\Bundle\SystemInfo\DependencyInjection\IbexaSystemInfoExtension::SERVICE_TAG
163162
index_by: identifier
164163

0 commit comments

Comments
 (0)