Skip to content

Commit 5bc2ef7

Browse files
author
Mark Randall
committed
Trailing commas
1 parent 5bad3df commit 5bc2ef7

2 files changed

Lines changed: 18 additions & 21 deletions

File tree

src/Releases/Branches.php

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,6 @@
3232
*/
3333
class Branches
3434
{
35-
private static function versionToBranch(string $version): string
36-
{
37-
$parts = explode('.', $version);
38-
if (count($parts) > 1) {
39-
return "$parts[0].$parts[1]";
40-
}
41-
42-
throw new ValueError("Unexpected version '$version'");
43-
}
44-
4535
/**
4636
* @return array<int, array<string, NormalizedReleaseStruct>>
4737
*/
@@ -60,7 +50,7 @@ public static function getOldReleaseData(): array
6050
{
6151
static $cache = null;
6252

63-
return $cache ??= (function() {
53+
return $cache ??= (function () {
6454
$original = require __DIR__ . '/../../include/releases.inc';
6555

6656
foreach ($original as &$releases) {
@@ -105,7 +95,7 @@ public static function getBranchOverrides(): array
10595
public static function all(): array
10696
{
10797
static $cache = null;
108-
return $cache ??= (function() {
98+
return $cache ??= (function () {
10999
$results = [];
110100
foreach (self::getReleaseData() as $majorVersion => $releases) {
111101
foreach ($releases as $releaseId => $release) {
@@ -141,7 +131,6 @@ public static function get_all_branches(): array
141131
foreach ($releases as $version => $release) {
142132
$branch = self::versionToBranch($version);
143133

144-
145134
if (!isset($branches[$major][$branch])
146135
|| version_compare($version, $branches[$major][$branch]['version'], 'gt')
147136
) {
@@ -154,7 +143,6 @@ public static function get_all_branches(): array
154143
foreach ($releases as $version => $release) {
155144
$branch = self::versionToBranch($version);
156145

157-
158146
if (!isset($branches[$major][$branch])
159147
|| version_compare($version, $branches[$major][$branch]['version'], 'gt')
160148
) {
@@ -280,7 +268,7 @@ public static function getInitialReleaseForBranch(string $branch): ?array
280268

281269
/* it seems that 8.4.0 is completely missing from the data */
282270
for ($patch = 0; $patch < 5; $patch++) {
283-
$release = $all[$major][$branch . '.'. $patch] ?? null;
271+
$release = $all[$major][$branch . '.' . $patch] ?? null;
284272
if ($release) {
285273
return $release;
286274
}
@@ -434,4 +422,13 @@ public static function getCurrentReleaseForBranch(int $major, ?int $minor): ?str
434422
return null;
435423
}
436424

425+
private static function versionToBranch(string $version): string
426+
{
427+
$parts = explode('.', $version);
428+
if (count($parts) > 1) {
429+
return "$parts[0].$parts[1]";
430+
}
431+
432+
throw new ValueError("Unexpected version '$version'");
433+
}
437434
}

tests/Unit/Releases/LegacyReleaseHelpersTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function testAllReleasesContainsRecent(): void
3737
foreach (array_keys($releases) as $releaseId) {
3838
self::assertTrue(
3939
isset($all[$majorId][$releaseId]),
40-
"Missing recent release data for '$releaseId' in all()"
40+
"Missing recent release data for '$releaseId' in all()",
4141
);
4242
}
4343
}
@@ -51,7 +51,7 @@ public function testAllReleasesContainsOld(): void
5151
foreach (array_keys($releases) as $releaseId) {
5252
self::assertTrue(
5353
isset($all[$majorId][$releaseId]),
54-
"Missing old release data for '$releaseId' in all()"
54+
"Missing old release data for '$releaseId' in all()",
5555
);
5656
}
5757
}
@@ -94,14 +94,14 @@ public function testNormalizationForAllData(): void
9494
self::assertTrue(
9595
/* @phpstan-ignore-next-line */
9696
isset($source['filename']),
97-
"Release '$releaseId' source $idx does not have a filename"
97+
"Release '$releaseId' source $idx does not have a filename",
9898
);
9999

100100
/* @phpstan-ignore-next-line */
101101
self::assertTrue(
102102
/* @phpstan-ignore-next-line */
103103
isset($source['name']),
104-
"Release '$releaseId' source $idx does not have a name"
104+
"Release '$releaseId' source $idx does not have a name",
105105
);
106106
}
107107
}
@@ -117,12 +117,12 @@ public function testInitialReleases(): void
117117
{
118118
self::assertNotEmpty(
119119
Branches::getInitialReleaseForBranch('8.5'),
120-
'Unable to find initial branch for 8.5'
120+
'Unable to find initial branch for 8.5',
121121
);
122122

123123
self::assertNotEmpty(
124124
Branches::getInitialReleaseForBranch('8.4'),
125-
'Unable to find initial branch for 8.4 (aborted release)'
125+
'Unable to find initial branch for 8.4 (aborted release)',
126126
);
127127
}
128128

0 commit comments

Comments
 (0)