3232 */
3333class 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}
0 commit comments