Skip to content

Commit 0bc7cce

Browse files
committed
Update DownloadLinkFetcher to determine the VS version from a hardcoded pattern list
1 parent c5227a5 commit 0bc7cce

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

src/DownloadLinkFetcher.php

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,19 @@ public function getLinksForTag(string $tag): array {
2222
return $return;
2323
}
2424

25+
private static function determineVCVersion(string $tag): string {
26+
if (preg_match('/^php-7\.2\./', $tag)) {
27+
return 'VC15';
28+
}
29+
if (preg_match('/^php-7\.3\./', $tag)) {
30+
return 'VC15';
31+
}
32+
if (preg_match('/^php-7\.4\./', $tag)) {
33+
return 'vc15';
34+
}
35+
return 'vs16';
36+
}
37+
2538
private function getWindowsLinks(string $tag): array {
2639
$folder = 'releases/archives';
2740
$folder_alt = 'releases';
@@ -31,22 +44,24 @@ private function getWindowsLinks(string $tag): array {
3144
$folder_alt = 'qa';
3245
}
3346

47+
$vsVersion = self::determineVCVersion($tag);
48+
3449
return [
3550
'x64NTS' => [
36-
'https://windows.php.net/downloads/' . $folder . '/' . $tag . '-nts-Win32-vs16-x64.zip',
37-
'https://windows.php.net/downloads/' . $folder_alt . '/' . $tag . '-nts-Win32-vs16-x64.zip',
51+
'https://windows.php.net/downloads/' . $folder . '/' . $tag . '-nts-Win32-'. $vsVersion .'-x64.zip',
52+
'https://windows.php.net/downloads/' . $folder_alt . '/' . $tag . '-nts-Win32-'. $vsVersion .'-x64.zip',
3853
],
3954
'x64TS' => [
40-
'https://windows.php.net/downloads/' . $folder . '/' . $tag . '-Win32-vs16-x64.zip',
41-
'https://windows.php.net/downloads/' . $folder_alt . '/' . $tag . '-Win32-vs16-x64.zip',
55+
'https://windows.php.net/downloads/' . $folder . '/' . $tag . '-Win32-' . $vsVersion . '-x64.zip',
56+
'https://windows.php.net/downloads/' . $folder_alt . '/' . $tag . '-Win32-' . $vsVersion . '-x64.zip',
4257
],
4358
'x86NTS' => [
44-
'https://windows.php.net/downloads/' . $folder . '/' . $tag . '-nts-Win32-vs16-x86.zip',
45-
'https://windows.php.net/downloads/' . $folder_alt . '/' . $tag . '-nts-Win32-vs16-x86.zip',
59+
'https://windows.php.net/downloads/' . $folder . '/' . $tag . '-nts-Win32-' . $vsVersion . '-x86.zip',
60+
'https://windows.php.net/downloads/' . $folder_alt . '/' . $tag . '-nts-Win32-' . $vsVersion . '-x86.zip',
4661
],
4762
'x86TS' => [
48-
'https://windows.php.net/downloads/' . $folder . '/' . $tag . '-Win32-vs16-x86.zip',
49-
'https://windows.php.net/downloads/' . $folder_alt . '/' . $tag . '-Win32-vs16-x86.zip',
63+
'https://windows.php.net/downloads/' . $folder . '/' . $tag . '-Win32-' . $vsVersion . '-x86.zip',
64+
'https://windows.php.net/downloads/' . $folder_alt . '/' . $tag . '-Win32-' . $vsVersion . '-x86.zip',
5065
],
5166
];
5267
}

0 commit comments

Comments
 (0)