Skip to content

Commit 48e3ad9

Browse files
committed
Replace usages of get_all_branches and get_active_branches
1 parent 392dbcc commit 48e3ad9

9 files changed

Lines changed: 32 additions & 9 deletions

File tree

include/branches.inc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ function version_number_to_branch(string $version): ?string {
6868
return null;
6969
}
7070

71+
#[Deprecated('Use Branches::get_all_branches()')]
7172
function get_all_branches() {
7273
$branches = [];
7374

@@ -105,7 +106,8 @@ function get_all_branches() {
105106
return $branches;
106107
}
107108

108-
function get_active_branches($include_recent_eols = true) {
109+
#[DEprecated('Use Branches::active()')]
110+
function get_active_branches(bool $include_recent_eols = true) {
109111
$branches = [];
110112
$now = new DateTime();
111113

include/gpg-keys.inc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<?php
2+
3+
use phpweb\Releases\Branches;
4+
25
require __DIR__ . '/branches.inc';
36

47
// GPG keys used for signing releases.
@@ -224,7 +227,7 @@ function gpg_key_get_branches(bool $activeOnly): array {
224227

225228
if (!$activeOnly) { return $branches; }
226229

227-
$active = get_active_branches();
230+
$active = Branches::active();
228231
return array_filter($branches, function ($branch) use ($active) {
229232
[$major] = explode('.', $branch, 2);
230233
return isset($active[$major][$branch]);

public/images/supported-versions.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
<?php
2+
3+
use phpweb\Releases\Branches;
4+
5+
include_once __DIR__ . '/../include/prepend.inc';
6+
include_once __DIR__ . '/../include/branches.inc';
27
require_once __DIR__ . '/../include/prepend.inc';
38
require_once __DIR__ . '/../include/branches.inc';
49

@@ -15,7 +20,7 @@ function branches_to_show() {
1520
$branches = [];
1621

1722
// Flatten out the majors.
18-
foreach (get_all_branches() as $major_branches) {
23+
foreach (Branches::get_all_branches() as $major_branches) {
1924
foreach ($major_branches as $branch => $version) {
2025
if (version_compare($branch, '5.3', 'ge') && get_branch_security_eol_date($branch) > min_date()) {
2126
$branches[$branch] = $version;

public/index.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
use phpweb\News\NewsHandler;
4+
use phpweb\Releases\Branches;
45

56
(function ($uri): void {
67
// Special redirect cases not able to be captured in error.php
@@ -92,7 +93,7 @@
9293
EOF;
9394

9495
$intro .= "<ul class='hero__versions'>\n";
95-
$active_branches = get_active_branches();
96+
$active_branches = Branches::active();
9697
krsort($active_branches);
9798
foreach ($active_branches as $major => $releases) {
9899
krsort($releases);

public/releases/active.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
use phpweb\Releases\Branches;
4+
35
use phpweb\ProjectGlobals;
46

57
$_SERVER['BASE_PAGE'] = 'releases/active.php';
@@ -9,4 +11,4 @@
911

1012
header('Content-Type: application/json; charset=UTF-8');
1113

12-
echo json_encode(get_active_branches());
14+
echo json_encode(Branches::active());

public/releases/branches.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<?php
22

3+
use phpweb\Releases\Branches;
4+
5+
include_once __DIR__ . '/../include/prepend.inc';
6+
include_once __DIR__ . '/../include/branches.inc';
37
require_once __DIR__ . '/../../include/prepend.inc';
48
require_once __DIR__ . '/../../include/branches.inc';
59

@@ -10,7 +14,7 @@ function formatDate($date = null) {
1014
}
1115

1216
$current = [];
13-
foreach (get_all_branches() as $major => $releases) {
17+
foreach (Branches::get_all_branches() as $major => $releases) {
1418
foreach ($releases as $branch => $release) {
1519
$current[$branch] = [
1620
'branch' => $branch,

public/releases/index.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
use phpweb\Releases\Branches;
4+
35
$_SERVER['BASE_PAGE'] = 'releases/index.php';
46
require_once __DIR__ . '/../../include/prepend.inc';
57
require_once __DIR__ . "/../../include/branches.inc";
@@ -10,7 +12,7 @@
1012
$machineReadable = [];
1113

1214
$supportedVersions = [];
13-
foreach (get_active_branches(false) as $major => $releases) {
15+
foreach (Branches::active(false) as $major => $releases) {
1416
$supportedVersions[$major] = array_keys($releases);
1517
}
1618

public/releases/states.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Please use /releases/branches.php instead.
44
# This API *may* be removed at an indeterminate point in the future.
55

6+
use phpweb\Releases\Branches;
67
use phpweb\ProjectGlobals;
78

89
$_SERVER['BASE_PAGE'] = 'releases/active.php';
@@ -18,7 +19,7 @@ function formatDate($date = null) {
1819
return $date !== null ? $date->format('c') : null;
1920
}
2021

21-
foreach (get_all_branches() as $major => $releases) {
22+
foreach (Branches::get_all_branches() as $major => $releases) {
2223
$states[$major] = [];
2324
foreach ($releases as $branch => $release) {
2425
$states[$major][$branch] = [

public/supported-versions.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<?php
2+
3+
use phpweb\Releases\Branches;
4+
25
$_SERVER['BASE_PAGE'] = 'supported-versions.php';
36

47
require_once __DIR__ . '/../include/prepend.inc';
@@ -51,7 +54,7 @@
5154
</tr>
5255
</thead>
5356
<tbody>
54-
<?php foreach (get_active_branches(false) as $major => $releases): ?>
57+
<?php foreach (Branches::active(false) as $major => $releases): ?>
5558
<?php ksort($releases) ?>
5659
<?php foreach ($releases as $branch => $release): ?>
5760
<?php

0 commit comments

Comments
 (0)