8000 CS Fixer · symfony/symfony@9f64774 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9f64774

Browse files
CS Fixer
1 parent 1385da0 commit 9f64774

File tree

5 files changed

+35
-42
lines changed

5 files changed

+35
-42
lines changed

src/Symfony/Component/AssetMapper/Command/ImportMapOutdatedCommand.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ final class ImportMapOutdatedCommand extends Command
3131

3232
public function __construct(
3333
protected readonly ImportMapUpdateChecker $updateChecker,
34-
)
35-
{
34+
) {
3635
parent::__construct();
3736
}
3837

@@ -103,7 +102,7 @@ protected function configure(): void
103102
protected function execute(InputInterface $input, OutputInterface $output): int
104103
{
105104
$io = new SymfonyStyle($input, $output);
106-
if (count(array_filter([$input->getOption('patch-only'), $input->getOption('minor-only'), $input->getOption('major-only')])) > 1) {
105+
if (\count(array_filter([$input->getOption('patch-only'), $input->getOption('minor-only'), $input->getOption('major-only')])) > 1) {
107106
$io->error('Only one of --major-only, --minor-only or --patch-only can be used at once');
108107

109108
return 1;
@@ -114,31 +113,31 @@ protected function execute(InputInterface $input, OutputInterface $output): int
114113
return Command::SUCCESS;
115114
}
116115
if (!$input->getOption('all')) {
117-
$packagesUpdateInfos = array_filter($packagesUpdateInfos, fn($packageUpdateInfo) => $packageUpdateInfo->hasUpdate());
116+
$packagesUpdateInfos = array_filter($packagesUpdateInfos, fn ($packageUpdateInfo) => $packageUpdateInfo->hasUpdate());
118117
}
119118
if ($input->getOption('ignore')) {
120119
$ignoredPackages = explode(',', $input->getOption('ignore'));
121-
$packagesUpdateInfos = array_filter($packagesUpdateInfos, fn($packageUpdateInfo) => !in_array($packageUpdateInfo->importName, $ignoredPackages));
120+
$packagesUpdateInfos = array_filter($packagesUpdateInfos, fn ($packageUpdateInfo) => !in_array($packageUpdateInfo->importName, $ignoredPackages));
122121
}
123122
if($input->getOption('major-only')) {
124-
$packagesUpdateInfos = array_filter($packagesUpdateInfos, fn($packageUpdateInfo) => $packageUpdateInfo->majorUpdate);
123+
$packagesUpdateInfos = array_filter($packagesUpdateInfos, fn( $packageUpdateInfo) => $packageUpdateInfo->majorUpdate);
125124
}
126125
if($input->getOption('minor-only')) {
127-
$packagesUpdateInfos = array_filter($packagesUpdateInfos, fn($packageUpdateInfo) => $packageUpdateInfo->minorUpdate);
126+
$packagesUpdateInfos = array_filter($packagesUpdateInfos, fn ($packageUpdateInfo) => $packageUpdateInfo->minorUpdate);
128127
}
129128
if($input->getOption('patch-only')) {
130-
$packagesUpdateInfos = array_filter($packagesUpdateInfos, fn($packageUpdateInfo) => $packageUpdateInfo->patchUpdate);
129+
$packagesUpdateInfos = array_filter($packagesUpdateInfos, fn ($packageUpdateInfo) => $packageUpdateInfo->patchUpdate);
131130
}
132131

133-
$displayData = array_map(fn($packageUpdateInfo) => [
132+
$displayData = array_map(fn ($packageUpdateInfo) => [
134133
'name' => $packageUpdateInfo->importName,
135134
'current' => $packageUpdateInfo->currentVersion,
136135
'latest' => $packageUpdateInfo->majorUpdate ?? $packageUpdateInfo->minorUpdate ?? $packageUpdateInfo->patchUpdate,
137136
'latest-status' => $packageUpdateInfo->majorUpdate ? 'update-possible' : ($packageUpdateInfo->minorUpdate || $packageUpdateInfo->patchUpdate ? 'semver-safe-update' : 'up-to-date'),
138137
], array_values($packagesUpdateInfos));
139138

140139
if ('json' === $input->getOption('format')) {
141-
$io->writeln(json_encode($displayData, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
140+
$io->writeln(json_encode($displayData, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES));
142141
} else {
143142
foreach ($displayData as $datum) {
144143
$io->writeln(sprintf(
@@ -151,9 +150,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
151150
}
152151
}
153152

154-
if($input->getOption('strict') && count(array_filter($packagesUpdateInfos, fn($packageUpdateInfo) => $packageUpdateInfo->hasUpdate()))) {
153+
if ($input->getOption('strict') && \count(array_filter($packagesUpdateInfos, fn ($packageUpdateInfo) => $packageUpdateInfo->hasUpdate()))) {
155154
return Command::FAILURE;
156155
}
156+
157157
return Command::SUCCESS;
158158
}
159159

src/Symfony/Component/AssetMapper/ImportMap/ImportMapUpdateChecker.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@ class ImportMapUpdateChecker
1818
{
1919
private const URL_PACKAGE_METADATA = 'https://registry.npmjs.org/%s';
2020
public function __construct(
21-
private readonly ImportMapConfigReader $importMapConfigReader,
21+
private readonly ImportMapConfigReader $importMapConfigReader,
2222
private readonly PackageResolverInterface $resolver,
23-
private readonly HttpClientInterface $httpClient,
24-
)
25-
{
23+
private readonly HttpClientInterface $httpClient,
24+
) {
2625
}
2726

2827
/**
@@ -55,15 +54,15 @@ private function getAvailableUpdateForEntry(ImportMapEntry $entry): PackageUpdat
5554
return $updatesInfo;
5655
}
5756
$latestVersion = $this->getLatestPackageVersion($entry->importName);
58-
if($this->isMajorUpdate($version, $latestVersion)) {
57+
if ($this->isMajorUpdate($version, $latestVersion)) {
5958
$updatesInfo->addMajorUpdate($latestVersion);
6059
return $updatesInfo;
6160
}
62-
if($this->isMinorUpdate($version, $latestVersion)) {
61+
if ($this->isMinorUpdate($version, $latestVersion)) {
6362
$updatesInfo->addMinorUpdate($latestVersion);
6463
return $updatesInfo;
6564
}
66-
if($this->isPatchUpdate($version, $latestVersion)) {
65+
if ($this->isPatchUpdate($version, $latestVersion)) {
6766
$updatesInfo->addPatchUpdate($latestVersion);
6867
return $updatesInfo;
6968
}

src/Symfony/Component/AssetMapper/ImportMap/PackageUpdateInfo.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,39 +13,39 @@
1313

1414
class PackageUpdateInfo
1515
{
16-
public function __construct(public readonly string $importName,
17-
public readonly string $url,
18-
public readonly string $currentVersion,
19-
public ?string $majorUpdate = null,
20-
public ?string $minorUpdate = null,
21-
public ?string $patchUpdate = null,
22-
)
23-
{
16+
public function __construct(
17+
public readonly string $importName,
18+
public readonly string $url,
19+
public readonly string $currentVersion,
20+
public ?string $majorUpdate = null,
21+
public ?string $minorUpdate = null,
22+
public ?string $patchUpdate = null,
23+
) {
2424
}
2525

2626
public function addMajorUpdate(string $version): void
2727
{
28-
if(is_null($this->majorUpdate)) {
28+
if (null === $this->majorUpdate) {
2929
$this->majorUpdate = $version;
3030
}
3131
}
3232

3333
public function addMinorUpdate(string $version): void
3434
{
35-
if(is_null($this->minorUpdate)) {
35+
if (null === $this->minorUpdate) {
3636
$this->minorUpdate = $version;
3737
}
3838
}
3939

4040
public function addPatchUpdate(string $version): void
4141
{
42-
if(is_null($this->patchUpdate)) {
42+
if (null === $this->patchUpdate) {
4343
$this->patchUpdate = $version;
4444
}
4545
}
4646

4747
public function hasUpdate(): bool
4848
{
49-
return !(is_null($this->majorUpdate) && is_null($this->minorUpdate) && is_null($this->patchUpdate));
49+
return !(null === $this->majorUpdate && null === $this->minorUpdate && null === $this->patchUpdate);
5050
}
5151
}

src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapUpdateCheckerTest.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,17 @@ public function testGetAvailableUpdates()
108108

109109
/**
110110
* @dataProvider provideImportMapEntry
111-
* @param ImportMapEntry[] $entries
111+
* @param ImportMapEntry[] $entries
112112
* @param PackageUpdateInfo[] $expectedUpdateInfo
113113
*/
114114
public function testGetAvailableUpdatesForSinglePackage(array $entries, array $expectedUpdateInfo, ?\Exception $expectedException)
115115
{
116116
$this->importMapConfigReader->method('getEntries')->willReturn(new ImportMapEntries($entries));
117117
if (null !== $expectedException) {
118-
$this->expectException(get_class($expectedException));
119-
$this->updateChecker->getAvailableUpdates(array_map(fn($entry) => $entry->importName, $entries));
118+
$this->expectException($expectedException::class);
119+
$this->updateChecker->getAvailableUpdates(array_map(fn ($entry) => $entry->importName, $entries));
120120
} else {
121-
$update = $this->updateChecker->getAvailableUpdates(array_map(fn($entry) => $entry->importName, $entries));
121+
$update = $this->updateChecker->getAvailableUpdates(array_map(fn ($entry) => $entry->importName, $entries));
122122
$this->assertEquals($expectedUpdateInfo, $update);
123123
}
124124
}
@@ -138,8 +138,7 @@ private function provideImportMapEntry()
138138
url: 'https://unpkg.com/@hotwired/stimulus@3.2.1/dist/stimulus.js',
139139
currentVersion: '3.2.1',
140140
majorUpdate: '4.0.1',
141-
),]
142-
,
141+
),],
143142
null
144143
];
145144
yield [
@@ -155,8 +154,7 @@ private function provideImportMapEntry()
155154
url: 'https://cdn.jsdelivr.net/npm/package_with_no_version_in_url/+esm',
156155
currentVersion: '5.3.1',
157156
patchUpdate: '5.3.2',
158-
),]
159-
,
157+
),],
160158
null,
161159
];
162160
yield [
@@ -192,5 +190,4 @@ private function responseFactory($method, $url): MockResponse
192190

193191
return $map[$url] ?? new MockResponse('Not found', ['http_code' => 404]);
194192
}
195-
196193
}

src/Symfony/Component/AssetMapper/Tests/ImportMap/PackageUpdateInfoTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
class PackageUpdateInfoTest extends TestCase
1818
{
19-
2019
/**
2120
* @dataProvider provideValidConstructorArguments
2221
*/
@@ -100,6 +99,4 @@ public function provideHasUpdateArguments()
10099
['2.0.0', '1.1.0', '1.0.1', true],
101100
];
102101
}
103-
104-
105102
}

0 commit comments

Comments
 (0)
0