Skip to content

Commit 7fb1756

Browse files
committed
Replace usages of get_all_branches and get_active_branches
1 parent c575b0b commit 7fb1756

9 files changed

Lines changed: 29 additions & 9 deletions

File tree

images/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
include_once __DIR__ . '/../include/prepend.inc';
36
include_once __DIR__ . '/../include/branches.inc';
47

@@ -15,7 +18,7 @@ function branches_to_show() {
1518
$branches = [];
1619

1720
// Flatten out the majors.
18-
foreach (get_all_branches() as $major_branches) {
21+
foreach (Branches::get_all_branches() as $major_branches) {
1922
foreach ($major_branches as $branch => $version) {
2023
if (version_compare($branch, '5.3', 'ge') && get_branch_security_eol_date($branch) > min_date()) {
2124
$branches[$branch] = $version;

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]);

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);

releases/active.php

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

3+
use phpweb\Releases\Branches;
4+
35
$_SERVER['BASE_PAGE'] = 'releases/active.php';
46

57
include_once __DIR__ . '/../include/prepend.inc';
68
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/branches.inc';
79

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

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

releases/branches.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
include_once __DIR__ . '/../include/prepend.inc';
46
include_once __DIR__ . '/../include/branches.inc';
57

@@ -10,7 +12,7 @@ function formatDate($date = null) {
1012
}
1113

1214
$current = [];
13-
foreach (get_all_branches() as $major => $releases) {
15+
foreach (Branches::get_all_branches() as $major => $releases) {
1416
foreach ($releases as $branch => $release) {
1517
$current[$branch] = [
1618
'branch' => $branch,

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
include_once __DIR__ . '/../include/prepend.inc';
57
include_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

releases/states.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
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;
7+
68
$_SERVER['BASE_PAGE'] = 'releases/active.php';
79

810
include_once __DIR__ . '/../include/prepend.inc';
@@ -16,7 +18,7 @@ function formatDate($date = null) {
1618
return $date !== null ? $date->format('c') : null;
1719
}
1820

19-
foreach (get_all_branches() as $major => $releases) {
21+
foreach (Branches::get_all_branches() as $major => $releases) {
2022
$states[$major] = [];
2123
foreach ($releases as $branch => $release) {
2224
$states[$major][$branch] = [

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
include_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)