Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,25 +1,7 @@
parameters:
ignoreErrors:
-
message: '#^Binary operation "\." between array\|bool\|float\|int\|string\|null and ''/vendor/'' results in an error\.$#'
identifier: binaryOp.invalid
count: 1
path: src/bundle/DependencyInjection/IbexaSystemInfoExtension.php

-
message: '#^Method Ibexa\\Bundle\\SystemInfo\\DependencyInjection\\IbexaSystemInfoExtension\:\:getConfiguration\(\) has parameter \$config with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/bundle/DependencyInjection/IbexaSystemInfoExtension.php

-
message: '#^Parameter \#4 \$condition of method Doctrine\\DBAL\\Query\\QueryBuilder\:\:innerJoin\(\) expects string\|null, Doctrine\\DBAL\\Query\\Expression\\CompositeExpression given\.$#'
identifier: argument.type
count: 1
path: src/lib/Storage/Metrics/DraftsCountMetrics.php

-
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\.$#'
identifier: argument.type
count: 3
path: tests/bundle/SystemInfo/Registry/IdentifierBasedTest.php
29 changes: 10 additions & 19 deletions src/bundle/Command/SystemInfoDumpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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\SystemInfo\Command;

Expand All @@ -22,15 +23,10 @@
)]
final class SystemInfoDumpCommand extends Command
{
private SystemInfoCollectorRegistry $systemInfoCollectorRegistry;

private OutputFormatRegistry $outputFormatRegistry;

public function __construct(SystemInfoCollectorRegistry $systemInfoCollectorRegistry, OutputFormatRegistry $outputFormatRegistry)
{
$this->systemInfoCollectorRegistry = $systemInfoCollectorRegistry;
$this->outputFormatRegistry = $outputFormatRegistry;

public function __construct(
private readonly SystemInfoCollectorRegistry $systemInfoCollectorRegistry,
private readonly OutputFormatRegistry $outputFormatRegistry
) {
parent::__construct();
}

Expand All @@ -39,10 +35,10 @@ protected function configure(): void
$this
->setHelp(
<<<'EOD'
By default it dumps information from all available information collectors.
You can specify one or more collectors as arguments, e.g. 'php database hardware'.
To get a list if available collectors, use '--list-info-collectors'
EOD
By default it dumps information from all available information collectors.
You can specify one or more collectors as arguments, e.g. 'php database hardware'.
To get a list if available collectors, use '--list-info-collectors'
EOD
)
->addOption(
'list-info-collectors',
Expand All @@ -65,16 +61,11 @@ protected function configure(): void
;
}

/**
* Execute the Command.
*
* @param $input InputInterface
* @param $output OutputInterface
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
if ($input->getOption('list-info-collectors')) {
$output->writeln('Available info collectors:', OutputInterface::OUTPUT_NORMAL);

foreach ($this->systemInfoCollectorRegistry->getIdentifiers() as $identifier) {
$output->writeln(" $identifier", OutputInterface::OUTPUT_NORMAL);
}
Expand Down
23 changes: 6 additions & 17 deletions src/bundle/Controller/SystemInfoController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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\SystemInfo\Controller;

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

class SystemInfoController extends AdminUiController
final class SystemInfoController extends AdminUiController
{
protected SystemInfoCollectorRegistry $collectorRegistry;

/**
* @param \Ibexa\Bundle\SystemInfo\SystemInfo\SystemInfoCollectorRegistry $collectorRegistry
*/
public function __construct(SystemInfoCollectorRegistry $collectorRegistry)
{
$this->collectorRegistry = $collectorRegistry;
public function __construct(
private readonly SystemInfoCollectorRegistry $collectorRegistry
) {
}

public function performAccessCheck(): void
{
parent::performAccessCheck();

$this->denyAccessUnlessGranted(new Attribute('setup', 'system_info'));
}

/**
* Renders the system information page.
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function infoAction(): Response
{
return $this->render('@ibexadesign/system_info/info.html.twig', [
Expand All @@ -48,9 +40,6 @@ public function viewInfoAction(SystemInfoView $view): SystemInfoView
return $view;
}

/**
* Renders a PHP info page.
*/
public function phpinfoAction(): Response
{
ob_start();
Expand Down
8 changes: 2 additions & 6 deletions src/bundle/DependencyInjection/Compiler/OutputFormatPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -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\SystemInfo\DependencyInjection\Compiler;

Expand All @@ -12,13 +13,8 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;

class OutputFormatPass implements CompilerPassInterface
final readonly class OutputFormatPass implements CompilerPassInterface
{
/**
* Registers the OutputFormat tagged services into the output format registry.
*
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
*/
public function process(ContainerBuilder $container): void
{
if (!$container->has(OutputFormatRegistry::class)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;

class SystemInfoCollectorPass implements CompilerPassInterface
final readonly class SystemInfoCollectorPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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\SystemInfo\DependencyInjection\Compiler;

Expand All @@ -13,10 +14,7 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;

/**
* {@inheritdoc}
*/
class SystemInfoTabGroupPass implements CompilerPassInterface
final readonly class SystemInfoTabGroupPass implements CompilerPassInterface
{
/**
* @throws \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
Expand Down
24 changes: 13 additions & 11 deletions src/bundle/DependencyInjection/IbexaSystemInfoExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,20 @@
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\DependencyInjection\Loader;

class IbexaSystemInfoExtension extends Extension implements PrependExtensionInterface
final class IbexaSystemInfoExtension extends Extension implements PrependExtensionInterface
{
public const EXTENSION_NAME = 'ibexa_system_info';
public const METRICS_TAG = 'ibexa.system_info.metrics';
public const SERVICE_TAG = 'ibexa.system_info.service';
public const string EXTENSION_NAME = 'ibexa_system_info';
public const string METRICS_TAG = 'ibexa.system_info.metrics';
public const string SERVICE_TAG = 'ibexa.system_info.service';

public function getAlias(): string
{
return self::EXTENSION_NAME;
}

/**
* @param array<string, mixed> $config
*/
public function getConfiguration(array $config, ContainerBuilder $container): Configuration
{
return new Configuration();
Expand All @@ -54,7 +57,6 @@ public function load(array $configs, ContainerBuilder $container): void
$container->setParameter(
'ibexa.system_info.powered_by.name',
$this->getPoweredByName(
$container,
$config['system_info']['powered_by']['release']
)
);
Expand All @@ -66,12 +68,10 @@ public function prepend(ContainerBuilder $container): void
$this->prependJMSTranslation($container);
}

private function getPoweredByName(ContainerBuilder $container, ?string $release): string
private function getPoweredByName(?string $release): string
{
$vendor = $container->getParameter('kernel.project_dir') . '/vendor/';

// Autodetect product name
$name = self::getNameByPackages($vendor);
$name = self::getNameByPackages();

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

public static function getNameByPackages(string $vendor = null): string
public static function getNameByPackages(): string
{
return IbexaSystemInfo::PRODUCT_NAME_VARIANTS[self::getEditionByPackages()];
return IbexaSystemInfo::PRODUCT_NAME_VARIANTS[
self::getEditionByPackages()
];
}
}
10 changes: 2 additions & 8 deletions src/bundle/EventSubscriber/AddXPoweredByHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,10 @@
/**
* Sets X-Powered-By header to promote use of Platform.
*/
class AddXPoweredByHeader implements EventSubscriberInterface
final readonly class AddXPoweredByHeader implements EventSubscriberInterface
{
/**
* @var string If empty, this powered by header is skipped.
*/
private string $installationName;

public function __construct(string $installationName)
public function __construct(private string $installationName)
{
$this->installationName = $installationName;
}

public static function getSubscribedEvents(): array
Expand Down
7 changes: 3 additions & 4 deletions src/bundle/IbexaSystemInfoBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -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\SystemInfo;

Expand All @@ -15,19 +16,17 @@
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
use Symfony\Component\HttpKernel\Bundle\Bundle;

class IbexaSystemInfoBundle extends Bundle
final class IbexaSystemInfoBundle extends Bundle
{
public function build(ContainerBuilder $container): void
{
parent::build($container);

$container->addCompilerPass(new SystemInfoCollectorPass());
$container->addCompilerPass(new OutputFormatPass());
$container->addCompilerPass(new SystemInfoTabGroupPass());
}

/**
* {@inheritdoc}
*/
public function getContainerExtension(): ExtensionInterface
{
return new IbexaSystemInfoExtension();
Expand Down
19 changes: 9 additions & 10 deletions src/bundle/Resources/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,13 @@ services:

Ibexa\Bundle\SystemInfo\SystemInfo\OutputFormatRegistry: ~

Ibexa\Bundle\SystemInfo\SystemInfo\EzcSystemInfoWrapper:
Ibexa\Bundle\SystemInfo\SystemInfo\SystemInfoWrapper:
lazy: true

# SystemInfoCollectors
Ibexa\Bundle\SystemInfo\SystemInfo\Collector\IbexaSystemInfoCollector:
arguments:
$composerCollector: '@Ibexa\Bundle\SystemInfo\SystemInfo\Collector\JsonComposerLockSystemInfoCollector'
$kernelProjectDir: '%kernel.project_dir%'
$collector: '@Ibexa\Bundle\SystemInfo\SystemInfo\Collector\JsonComposerLockSystemInfoCollector'
tags:
- { name: ibexa.system_info.collector, identifier: ibexa }

Expand All @@ -69,19 +68,19 @@ services:
lazy: true
autowire: true
arguments:
$db: '@ibexa.persistence.connection'
$connection: '@ibexa.persistence.connection'
tags:
- { name: ibexa.system_info.collector, identifier: repository }

Ibexa\Bundle\SystemInfo\SystemInfo\Collector\EzcHardwareSystemInfoCollector:
Ibexa\Bundle\SystemInfo\SystemInfo\Collector\HardwareSystemInfoCollector:
arguments:
- '@Ibexa\Bundle\SystemInfo\SystemInfo\EzcSystemInfoWrapper'
- '@Ibexa\Bundle\SystemInfo\SystemInfo\SystemInfoWrapper'
tags:
- { name: ibexa.system_info.collector, identifier: hardware }

Ibexa\Bundle\SystemInfo\SystemInfo\Collector\EzcPhpSystemInfoCollector:
Ibexa\Bundle\SystemInfo\SystemInfo\Collector\PhpSystemInfoCollector:
arguments:
- '@Ibexa\Bundle\SystemInfo\SystemInfo\EzcSystemInfoWrapper'
- '@Ibexa\Bundle\SystemInfo\SystemInfo\SystemInfoWrapper'
tags:
- { name: ibexa.system_info.collector, identifier: php }

Expand All @@ -108,7 +107,7 @@ services:

Ibexa\SystemInfo\Storage\AggregateMetricsProvider:
arguments:
$metrics: !tagged_locator
$metricsLocator: !tagged_locator
tag: !php/const \Ibexa\Bundle\SystemInfo\DependencyInjection\IbexaSystemInfoExtension::METRICS_TAG
index_by: identifier

Expand Down Expand Up @@ -158,7 +157,7 @@ services:

Ibexa\SystemInfo\Service\AggregateServiceProvider:
arguments:
$service: !tagged_locator
$serviceLocator: !tagged_locator
tag: !php/const \Ibexa\Bundle\SystemInfo\DependencyInjection\IbexaSystemInfoExtension::SERVICE_TAG
index_by: identifier

Expand Down
1 change: 0 additions & 1 deletion src/bundle/Resources/config/view.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ services:
public: true

Ibexa\Bundle\SystemInfo\View\SystemInfoViewBuilder:
class: Ibexa\Bundle\SystemInfo\View\SystemInfoViewBuilder
arguments:
- '@Ibexa\Core\MVC\Symfony\View\Configurator\ViewProvider'
- '@Ibexa\Bundle\SystemInfo\SystemInfo\Registry\IdentifierBased'
Expand Down
Loading
Loading