Skip to content

Commit f04d0a8

Browse files
feat: ecs, rector
1 parent 058aad4 commit f04d0a8

10 files changed

Lines changed: 35 additions & 46 deletions

File tree

src/Components/Elasticsearch/AdminInfoSubscriber.php renamed to src/Components/Elasticsearch/AdminInfoSubscriberEventListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Symfony\Component\HttpKernel\Event\ResponseEvent;
99

1010
#[AutoconfigureTag('kernel.event_listener')]
11-
final class AdminInfoSubscriber
11+
final class AdminInfoSubscriberEventListener
1212
{
1313
public function __construct(
1414
#[Autowire('%frosh_tools.elasticsearch.enabled%')] private readonly bool $elasticsearchEnabled

src/Components/Health/Checker/HealthChecker/MysqlChecker.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function collect(HealthCollection $collection): void
1818
{
1919
$version = $this->connection->fetchOne('SELECT VERSION()');
2020
if (!\is_string($version)) {
21-
$collection->add(SettingsResult::error('mysql', 'MySQL Version', 'unknown'));
21+
$collection->add(SettingsResult::error('mysql', 'MySQL Version', 'unknown'));
2222

2323
return;
2424
}

src/Components/Health/Checker/HealthChecker/QueueChecker.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function collect(HealthCollection $collection): void
2525
/** @var string|false $oldestMessageAt */
2626
$oldestMessageAt = $this->connection->fetchOne('SELECT available_at FROM messenger_messages ORDER BY available_at ASC LIMIT 1');
2727

28-
if (is_string($oldestMessageAt)) {
28+
if (\is_string($oldestMessageAt)) {
2929
$diff = round(abs(
3030
((new \DateTime($oldestMessageAt . ' UTC'))->getTimestamp() - $oldMessageLimit->getTimestamp()) / 60
3131
));

src/Components/Health/Checker/HealthChecker/SystemInfoChecker.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
declare(strict_types=1);
23

34
namespace Frosh\Tools\Components\Health\Checker\HealthChecker;
45

@@ -30,15 +31,16 @@ private function checkPath(HealthCollection $collection): void
3031
);
3132
}
3233

33-
private function getDatabaseInfo(HealthCollection $collection)
34+
private function getDatabaseInfo(HealthCollection $collection): void
3435
{
3536
$databaseConnectionInfo = (new DatabaseConnectionInformation())->fromEnv();
3637

3738
$collection->add(
3839
SettingsResult::ok(
3940
'database-info',
4041
'Database',
41-
\sprintf('%s@%s:%s',
42+
\sprintf(
43+
'%s@%s:%d',
4244
$databaseConnectionInfo->getDatabaseName(),
4345
$databaseConnectionInfo->getHostname(),
4446
$databaseConnectionInfo->getPort()

src/Components/Health/Checker/HealthChecker/TaskChecker.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,6 @@ public function collect(HealthCollection $collection): void
5959
($maxTaskNextExecTime - $taskDateLimit->getTimestamp()) / 60
6060
));
6161

62-
$collection->add(SettingsResult::warning('scheduled_task', 'Scheduled tasks', \sprintf('%d mins',$diff), $recommended));
62+
$collection->add(SettingsResult::warning('scheduled_task', 'Scheduled tasks', \sprintf('%d mins', $diff), $recommended));
6363
}
6464
}

src/Components/Health/Checker/PerformanceChecker/MailOverQueueChecker.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ public function collect(HealthCollection $collection): void
2727
'https://developer.shopware.com/docs/guides/hosting/infrastructure/message-queue#sending-mails-over-the-message-queue'
2828
)
2929
);
30-
3130
}
3231
}
3332
}

src/Controller/ShopwareFilesController.php

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
declare(strict_types=1);
23

34
namespace Frosh\Tools\Controller;
45

56
use Shopware\Core\Kernel;
7+
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
68
use Symfony\Component\DependencyInjection\Attribute\Autowire;
79
use Symfony\Component\HttpFoundation\JsonResponse;
810
use Symfony\Component\HttpFoundation\Request;
911
use Symfony\Component\Routing\Annotation\Route;
1012

1113
#[Route(path: '/api/_action/frosh-tools', defaults: ['_routeScope' => ['api'], '_acl' => ['frosh_tools:read']])]
12-
class ShopwareFilesController
14+
class ShopwareFilesController extends AbstractController
1315
{
1416
private const STATUS_OK = 0;
1517
private const STATUS_IGNORED_ALL = 1;
1618
private const STATUS_IGNORED_IN_PROJECT = 2;
17-
private bool $isPlatform;
19+
20+
private readonly bool $isPlatform;
1821

1922
public function __construct(
2023
#[Autowire('%kernel.shopware_version%')] private readonly string $shopwareVersion,
21-
#[Autowire('%kernel.project_dir%<')] private readonly string $projectDir,
22-
#[Autowire('%frosh_tools.file_checker.exclude_files%')] private readonly array $projectIgnoredFiles
23-
)
24-
{
24+
#[Autowire('%kernel.project_dir%')] private readonly string $projectDir,
25+
#[Autowire('%frosh_tools.file_checker.exclude_files%')] private readonly array $projectExcludeFiles
26+
) {
2527
$this->isPlatform = !is_dir($this->projectDir . '/vendor/shopware/core') && is_dir($this->projectDir . '/src/Core');
2628
}
2729

@@ -45,9 +47,7 @@ public function listShopwareFiles(): JsonResponse
4547

4648
foreach (explode("\n", $data) as $row) {
4749
if ($this->isPlatform) {
48-
$row = preg_replace_callback('/vendor\/shopware\/(.)/', function ($matches) {
49-
return 'src/' . strtoupper($matches[1]);
50-
}, $row);
50+
$row = preg_replace_callback('/vendor\/shopware\/(.)/', fn ($matches): string => 'src/' . strtoupper($matches[1]), $row);
5151
}
5252

5353
[$expectedMd5Sum, $file] = explode(' ', trim($row));
@@ -77,8 +77,8 @@ public function listShopwareFiles(): JsonResponse
7777
];
7878
}
7979

80-
//WE SHOULD STOP HERE, WHILE THERE MIGHT BE ANY BIG PROBLEM!
81-
if (count($invalidFiles) > 100) {
80+
// WE SHOULD STOP HERE, WHILE THERE MIGHT BE ANY BIG PROBLEM!
81+
if (\count($invalidFiles) > 100) {
8282
break;
8383
}
8484
}
@@ -148,22 +148,18 @@ public function restoreShopwareFile(Request $request): JsonResponse
148148

149149
private function getShopwareUrl(string $name): ?string
150150
{
151-
if ($this->isPlatform) {
152-
$name = preg_replace('/^src\//', '', $name);
153-
} else {
154-
$name = preg_replace('/^vendor\/shopware\//', '', $name);
155-
}
151+
$name = $this->isPlatform ? preg_replace('/^src\//', '', $name) : preg_replace('/^vendor\/shopware\//', '', $name);
156152

157153
$pathParts = \explode('/', $name);
158154
$repo = $pathParts[0];
159155
array_shift($pathParts);
160156

161-
return 'https://github.com/shopware/' .
162-
$repo .
163-
'/blob/v' .
164-
$this->shopwareVersion .
165-
'/' .
166-
\implode('/', $pathParts);
157+
return 'https://github.com/shopware/'
158+
. $repo
159+
. '/blob/v'
160+
. $this->shopwareVersion
161+
. '/'
162+
. \implode('/', $pathParts);
167163
}
168164

169165
private function getOriginalFileContent(string $name): ?string
@@ -173,19 +169,10 @@ private function getOriginalFileContent(string $name): ?string
173169

174170
private function isIgnoredFileHash(string $file): int
175171
{
176-
if (in_array($file, $this->projectIgnoredFiles, true)) {
172+
if (\in_array($file, $this->projectExcludeFiles, true)) {
177173
return self::STATUS_IGNORED_IN_PROJECT;
178174
}
179175

180176
return self::STATUS_OK;
181177
}
182-
183-
private function assertNoGitVersion(): ?JsonResponse
184-
{
185-
if ($this->shopwareVersion === Kernel::SHOPWARE_FALLBACK_VERSION) {
186-
return new JsonResponse(['error' => 'Git version is not supported']);
187-
}
188-
189-
return null;
190-
}
191178
}

src/DependencyInjection/Configuration.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
declare(strict_types=1);
23

34
namespace Frosh\Tools\DependencyInjection;
45

src/DependencyInjection/FroshToolsExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
declare(strict_types=1);
23

34
namespace Frosh\Tools\DependencyInjection;
45

@@ -29,7 +30,6 @@ private function addConfig(ContainerBuilder $container, string $alias, array $op
2930
}
3031
}
3132

32-
/** @phpstan-ignore-next-line */
3333
if (!$container->hasParameter('frosh_tools.file_checker.exclude_files')) {
3434
$container->setParameter('frosh_tools.file_checker.exclude_files', []);
3535
}

src/FroshTools.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
use Frosh\Tools\DependencyInjection\CacheCompilerPass;
77
use Frosh\Tools\DependencyInjection\DisableElasticsearchCompilerPass;
8-
use Frosh\Tools\DependencyInjection\SymfonyConfigCompilerPass;
98
use Frosh\Tools\DependencyInjection\FroshToolsExtension;
9+
use Frosh\Tools\DependencyInjection\SymfonyConfigCompilerPass;
1010
use Shopware\Core\Framework\Plugin;
1111
use Symfony\Component\DependencyInjection\ContainerBuilder;
1212

@@ -20,7 +20,7 @@ public function build(ContainerBuilder $container): void
2020
$container->addCompilerPass(new DisableElasticsearchCompilerPass());
2121
}
2222

23-
public function createContainerExtension(): FroshToolsExtension
23+
protected function createContainerExtension(): FroshToolsExtension
2424
{
2525
return new FroshToolsExtension();
2626
}

0 commit comments

Comments
 (0)