Skip to content

Commit 0dc50b0

Browse files
committed
Replace usages of branch status and date functions
1 parent b30ae19 commit 0dc50b0

7 files changed

Lines changed: 26 additions & 21 deletions

File tree

bin/bumpRelease

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#!/usr/bin/env php
22
<?php
3+
4+
use phpweb\Releases\Branches;
5+
36
(PHP_SAPI === 'cli') or die("Please run this script using the cli sapi");
47

5-
require_once __DIR__ . "/../include/branches.inc";
6-
require_once __DIR__ . "/../include/version.inc";
7-
require_once __DIR__ . "/../include/releases.inc";
8+
require_once __DIR__ . "/../src/Releases/Branches.php";
89

910
if ($_SERVER['argc'] < 1) {
1011
fwrite(STDERR, "Usage: {$_SERVER['argv'][0]} major_version [ minor_version ]\n");
@@ -15,7 +16,7 @@ $major = (int) $_SERVER['argv'][1];
1516
isset($RELEASES[$major]) or die("Unknown major version $major");
1617
$minor = isset($_SERVER['argv'][2]) ? (int) $_SERVER['argv'][2] : null;
1718

18-
$version = get_current_release_for_branch($major, $minor);
19+
$version = Branches::get_current_release_for_branch($major, $minor);
1920
$info = $RELEASES[$major][$version] ?? null;
2021

2122
if ($info === null) {

images/supported-versions.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ function date_horiz_coord(DateTime $date) {
137137
<g class="branches">
138138
<?php foreach ($branches as $branch => $version): ?>
139139
<?php
140-
$x_release = date_horiz_coord(get_branch_release_date($branch));
141-
$x_bug = date_horiz_coord(get_branch_bug_eol_date($branch));
142-
$x_eol = date_horiz_coord(get_branch_security_eol_date($branch));
140+
$x_release = date_horiz_coord(Branches::getBranchReleaseDate($branch));
141+
$x_bug = date_horiz_coord(Branches::getBranchBugsEOLDate($branch));
142+
$x_eol = date_horiz_coord(Branches::getBranchSecurityEOLDate($branch));
143143
?>
144144
<rect class="stable" x="<?php echo $x_release ?>" y="<?php echo $version['top'] ?>" width="<?php echo $x_bug - $x_release ?>" height="<?php echo $branch_height ?>" />
145145
<rect class="security" x="<?php echo $x_bug ?>" y="<?php echo $version['top'] ?>" width="<?php echo $x_eol - $x_bug ?>" height="<?php echo $branch_height ?>" />

include/branches.inc

Lines changed: 6 additions & 2 deletions
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__ . '/releases.inc';
46
include_once __DIR__ . '/version.inc';
57

@@ -219,6 +221,7 @@ function get_eol_branches($always_include = null) {
219221
* MAJOR.MINOR.REVISION (the REVISION will be ignored if provided). This will
220222
* return either null (if no release exists on the given branch), or the usual
221223
* version metadata from $RELEASES for a single release. */
224+
#[Deprecated('Use Branches::getInitialRelease')]
222225
function get_initial_release($branch) {
223226
$branch = version_number_to_branch($branch);
224227
if (!$branch) {
@@ -247,6 +250,7 @@ function get_initial_release($branch) {
247250
return null;
248251
}
249252

253+
#[Deprecated('Use Branches::getFinalRelease')]
250254
function get_final_release($branch) {
251255
$branch = version_number_to_branch($branch);
252256
if (!$branch) {
@@ -418,7 +422,7 @@ function get_current_release_for_branch(int $major, ?int $minor): ?string {
418422

419423
// Get latest release version and info.
420424
function release_get_latest() {
421-
global $RELEASES;
425+
$RELEASES = Branches::getReleaseData();
422426

423427
$version = '0.0.0';
424428
$current = null;
@@ -436,7 +440,7 @@ function release_get_latest() {
436440

437441
function show_source_releases()
438442
{
439-
global $RELEASES;
443+
$RELEASES = Branches::getReleaseData();
440444

441445
$SHOW_COUNT = 4;
442446

releases/branches.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ function formatDate($date = null) {
1818
'branch' => $branch,
1919
'latest' => ($release['version'] ?? null),
2020
'state' => get_branch_support_state($branch),
21-
'initial_release' => formatDate(get_branch_release_date($branch)),
22-
'active_support_end' => formatDate(get_branch_bug_eol_date($branch)),
23-
'security_support_end' => formatDate(get_branch_security_eol_date($branch)),
21+
'initial_release' => formatDate(Branches::getBranchReleaseDate($branch)),
22+
'active_support_end' => formatDate(Branches::getBranchBugsEOLDate($branch)),
23+
'security_support_end' => formatDate(Branches::getBranchSecurityEOLDate($branch)),
2424
];
2525
}
2626
}

releases/states.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ function formatDate($date = null) {
2222
$states[$major] = [];
2323
foreach ($releases as $branch => $release) {
2424
$states[$major][$branch] = [
25-
'state' => get_branch_support_state($branch),
26-
'initial_release' => formatDate(get_branch_release_date($branch)),
27-
'active_support_end' => formatDate(get_branch_bug_eol_date($branch)),
28-
'security_support_end' => formatDate(get_branch_security_eol_date($branch)),
25+
'state' => Branches::getBranchSupportStatus($branch),
26+
'initial_release' => formatDate(Branches::getBranchReleaseDate($branch)),
27+
'active_support_end' => formatDate(Branches::getBranchBugsEOLDate($branch)),
28+
'security_support_end' => formatDate(Branches::getBranchSecurityEOLDate($branch)),
2929
];
3030
}
3131
krsort($states[$major]);

src/Releases/Branches.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ public static function getBranchReleaseDate(string $branch): ?DateTime
407407
return isset($initial['date']) ? new DateTime($initial['date']) : null;
408408
}
409409

410-
public static function findBranchSupportStatus(string $branch): ?string
410+
public static function getBranchSupportStatus(string $branch): ?string
411411
{
412412
$initial = self::getBranchReleaseDate($branch);
413413
$bug = self::getBranchBugsEOLDate($branch);

supported-versions.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@
5858
<?php ksort($releases) ?>
5959
<?php foreach ($releases as $branch => $release): ?>
6060
<?php
61-
$state = get_branch_support_state($branch);
62-
$initial = get_branch_release_date($branch);
63-
$until = get_branch_bug_eol_date($branch);
64-
$eol = get_branch_security_eol_date($branch);
61+
$state = Branches::getBranchSupportStatus($branch);
62+
$initial = Branches::getBranchReleaseDate($branch);
63+
$until = Branches::getBranchBugsEOLDate($branch);
64+
$eol = Branches::getBranchSecurityEOLDate($branch);
6565
$now = new DateTime('now');
6666
?>
6767
<tr class="<?php echo $state ?>">

0 commit comments

Comments
 (0)