Skip to content

Commit 85d3010

Browse files
committed
Merge branch '1.3.x' into 1.4.x
2 parents 4de048f + bfb859a commit 85d3010

File tree

10 files changed

+177
-152
lines changed

10 files changed

+177
-152
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
],
2929
"require": {
3030
"php": "8.1.*||8.2.*||8.3.*||8.4.*||8.5.*",
31-
"composer/composer": "^2.9.2",
31+
"composer/composer": "^2.9.5",
3232
"composer/pcre": "^3.3.2",
3333
"composer/semver": "^3.4.4",
3434
"fidry/cpu-core-counter": "^1.3.0",

composer.lock

Lines changed: 104 additions & 127 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

features/download-extensions.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Feature: Extensions can be downloaded with PIE
1313
Examples:
1414
| constraint | version |
1515
| 2.0.5 | 2.0.5 |
16-
| ^2.0 | 2.0.5 |
16+
| ^2.0 | 2.0.8 |
1717

1818
# pie download <ext>:dev-main
1919
@non-windows

phpstan-baseline.neon

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -414,26 +414,14 @@ parameters:
414414
count: 1
415415
path: test/unit/ComposerIntegration/VendorCleanupTest.php
416416

417-
-
418-
message: '#^Parameter \#1 \$phpExt of method Composer\\Package\\Package\:\:setPhpExt\(\) expects array\{extension\-name\?\: string, priority\?\: int, support\-zts\?\: bool, support\-nts\?\: bool, build\-path\?\: string\|null, download\-url\-method\?\: string, os\-families\?\: non\-empty\-list\<non\-empty\-string\>, os\-families\-exclude\?\: non\-empty\-list\<non\-empty\-string\>, \.\.\.\}\|null, array\{download\-url\-method\: array\{''composer\-default''\}\} given\.$#'
419-
identifier: argument.type
420-
count: 1
421-
path: test/unit/DependencyResolver/PackageTest.php
422-
423-
-
424-
message: '#^Parameter \#1 \$phpExt of method Composer\\Package\\Package\:\:setPhpExt\(\) expects array\{extension\-name\?\: string, priority\?\: int, support\-zts\?\: bool, support\-nts\?\: bool, build\-path\?\: string\|null, download\-url\-method\?\: string, os\-families\?\: non\-empty\-list\<non\-empty\-string\>, os\-families\-exclude\?\: non\-empty\-list\<non\-empty\-string\>, \.\.\.\}\|null, array\{download\-url\-method\: array\{''pre\-packaged\-source'', ''composer\-default''\}\} given\.$#'
425-
identifier: argument.type
426-
count: 1
427-
path: test/unit/DependencyResolver/PackageTest.php
428-
429417
-
430418
message: '#^Parameter \#2 \$extractedSourcePath of static method Php\\Pie\\Downloading\\DownloadedPackage\:\:fromPackageAndExtractedPath\(\) expects string, string\|false given\.$#'
431419
identifier: argument.type
432420
count: 3
433421
path: test/unit/Downloading/DownloadedPackageTest.php
434422

435423
-
436-
message: '#^Parameter \#1 \$phpExt of method Composer\\Package\\Package\:\:setPhpExt\(\) expects array\{extension\-name\?\: string, priority\?\: int, support\-zts\?\: bool, support\-nts\?\: bool, build\-path\?\: string\|null, download\-url\-method\?\: string, os\-families\?\: non\-empty\-list\<non\-empty\-string\>, os\-families\-exclude\?\: non\-empty\-list\<non\-empty\-string\>, \.\.\.\}\|null, array\{extension\-name\: null\} given\.$#'
424+
message: '#^Parameter \#1 \$phpExt of method Composer\\Package\\Package\:\:setPhpExt\(\) expects array\{extension\-name\?\: string, priority\?\: int, support\-zts\?\: bool, support\-nts\?\: bool, build\-path\?\: string\|null, download\-url\-method\?\: list\<string\>\|string, os\-families\?\: non\-empty\-list\<non\-empty\-string\>, os\-families\-exclude\?\: non\-empty\-list\<non\-empty\-string\>, \.\.\.\}\|null, array\{extension\-name\: null\} given\.$#'
437425
identifier: argument.type
438426
count: 1
439427
path: test/unit/ExtensionNameTest.php

src/DependencyResolver/Package.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ public static function fromComposerCompletePackage(CompletePackageInterface $com
9494
/** @var string|list<string> $method */
9595
$method = $phpExtOptions['download-url-method'];
9696
if (is_array($method)) {
97-
if (count($method) !== 1) {
98-
throw new InvalidArgumentException('This extension requires a newer version of PIE. Multiple download-url-methods are not supported until PIE 1.4.0.');
97+
if (count($method) === 1) {
98+
$method = $method[0];
99+
} else {
100+
$method = DownloadUrlMethod::ComposerDefaultDownload->value;
99101
}
100-
101-
$method = $method[0];
102102
}
103103

104104
$package->downloadUrlMethod = DownloadUrlMethod::tryFrom($method);

src/SelfManage/Update/FetchPieReleaseFromGitHub.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Webmozart\Assert\Assert;
1212

1313
use function array_filter;
14+
use function array_key_exists;
1415
use function array_map;
1516
use function count;
1617
use function file_put_contents;
@@ -85,7 +86,10 @@ static function (array $asset): bool {
8586
$firstAssetNamedPiePhar['browser_download_url'],
8687
);
8788
},
88-
$decodedResponse,
89+
array_filter(
90+
$decodedResponse,
91+
static fn (array $releaseResponse): bool => (! array_key_exists('draft', $releaseResponse) || ! $releaseResponse['draft']),
92+
),
8993
),
9094
static function (ReleaseMetadata|null $releaseMetadata) use ($updateChannel): bool {
9195
if ($releaseMetadata === null) {

test/integration/Command/DownloadCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#[CoversClass(DownloadCommand::class)]
2424
class DownloadCommandTest extends TestCase
2525
{
26-
private const TEST_PACKAGE_LATEST = '2.0.5';
26+
private const TEST_PACKAGE_LATEST = '2.0.8';
2727
private const TEST_PACKAGE = 'asgrim/example-pie-extension';
2828

2929
private CommandTester $commandTester;

test/integration/DependencyResolver/ResolveDependencyWithComposerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#[CoversClass(ResolveDependencyWithComposer::class)]
2727
final class ResolveDependencyWithComposerTest extends TestCase
2828
{
29-
private const TEST_PACKAGE_LATEST = '2.0.5';
29+
private const TEST_PACKAGE_LATEST = '2.0.8';
3030
private const DOWNLOAD_URL_ANY = 'https://api.github.com/repos/asgrim/example-pie-extension/zipball/%s';
3131
private const DOWNLOAD_URL_1_0_1_ALPHA_3 = 'https://api.github.com/repos/asgrim/example-pie-extension/zipball/115f8f8e01ee098a18ec2f47af4852be51ebece7';
3232
private const DOWNLOAD_URL_1_0_1 = 'https://api.github.com/repos/asgrim/example-pie-extension/zipball/769f906413d6d1e12152f6d34134cbcd347ca253';

test/unit/DependencyResolver/PackageTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ public function testDownloadUrlMethodWithMultiItemListIsNotYetSupported(): void
173173
$composerCompletePackage = new CompletePackage('vendor/foo', '1.2.3.0', '1.2.3');
174174
$composerCompletePackage->setPhpExt(['download-url-method' => ['pre-packaged-source', 'composer-default']]);
175175

176-
$this->expectException(InvalidArgumentException::class);
177-
$this->expectExceptionMessage('This extension requires a newer version of PIE. Multiple download-url-methods are not supported until PIE 1.4.0.');
178-
Package::fromComposerCompletePackage($composerCompletePackage);
176+
$package = Package::fromComposerCompletePackage($composerCompletePackage);
177+
178+
self::assertSame(DownloadUrlMethod::ComposerDefaultDownload, $package->downloadUrlMethod());
179179
}
180180
}

test/unit/SelfManage/Update/FetchPieReleaseFromGitHubTest.php

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,4 +207,60 @@ public function testDownloadContent(): void
207207
self::assertSame($pharContent, file_get_contents($file->filePath));
208208
self::assertSame($expectedDigest, $file->checksum);
209209
}
210+
211+
public function testDraftReleasesAreNotReturnedForStableChannel(): void
212+
{
213+
$httpDownloader = $this->createMock(HttpDownloader::class);
214+
215+
$url = self::TEST_GITHUB_URL . '/repos/php/pie/releases';
216+
$httpDownloader->expects(self::once())
217+
->method('get')
218+
->with(
219+
$url,
220+
[
221+
'retry-auth-failure' => true,
222+
'http' => [
223+
'method' => 'GET',
224+
'header' => [],
225+
],
226+
],
227+
)
228+
->willReturn(
229+
new Response(
230+
['url' => $url],
231+
200,
232+
[],
233+
(string) json_encode([
234+
235+
[
236+
'draft' => true,
237+
'tag_name' => '1.2.4',
238+
'assets' => [
239+
[
240+
'name' => 'pie.phar',
241+
'browser_download_url' => self::TEST_GITHUB_URL . '/path/to/pie.phar',
242+
],
243+
],
244+
],
245+
[
246+
'draft' => false,
247+
'tag_name' => '1.2.3',
248+
'assets' => [
249+
[
250+
'name' => 'pie.phar',
251+
'browser_download_url' => self::TEST_GITHUB_URL . '/path/to/pie.phar',
252+
],
253+
],
254+
],
255+
]),
256+
),
257+
);
258+
259+
$fetch = new FetchPieReleaseFromGitHub(self::TEST_GITHUB_URL, $httpDownloader);
260+
261+
$latestRelease = $fetch->latestReleaseMetadata(Channel::Stable);
262+
263+
self::assertSame('1.2.3', $latestRelease->tag);
264+
self::assertSame(self::TEST_GITHUB_URL . '/path/to/pie.phar', $latestRelease->downloadUrl);
265+
}
210266
}

0 commit comments

Comments
 (0)