Skip to content

Commit

Permalink
Update to remove superfluous override- prefix and pull latest compose…
Browse files Browse the repository at this point in the history
…r/composer
  • Loading branch information
asgrim committed Feb 5, 2025
1 parent 504aa88 commit 36da7b2
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 33 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
],
"require": {
"php": "8.1.*||8.2.*||8.3.*||8.4.*",
"composer/composer": "^2.8.5",
"composer/composer": "dev-main",
"composer/pcre": "^3.3.2",
"composer/semver": "^3.4.3",
"fidry/cpu-core-counter": "^1.2",
Expand Down
21 changes: 12 additions & 9 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/extension-maintainers.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,9 @@ The `build-path` may contain some templated values which are replaced:
with version 1.2.3 with a `build-path` of `myext-{version}` the actual build
path would become `myext-1.2.3`.

#### `override-download-url-method`
#### `download-url-method`

The `override-download-url-method` directive allows extension maintainers to
The `download-url-method` directive allows extension maintainers to
change the behaviour of downloading the source package.

* Setting this to `composer-default`, which is the default value if not
Expand Down
2 changes: 1 addition & 1 deletion resources/composer-json-php-ext-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"example": "my-extension-source",
"default": null
},
"override-download-url-method": {
"download-url-method": {
"type": "string",
"description": "If specified, this technique will be used to override the URL that PIE uses to download the asset. The default, if not specified, is composer-default.",
"enum": ["composer-default", "pre-packaged-source"],
Expand Down
31 changes: 13 additions & 18 deletions src/DependencyResolver/Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use function array_slice;
use function explode;
use function implode;
use function is_string;
use function parse_url;
use function str_contains;
use function str_starts_with;
Expand All @@ -43,7 +42,7 @@ final class Package
private array|null $incompatibleOsFamilies;
private bool $supportZts;
private bool $supportNts;
private DownloadUrlMethod|null $overrideDownloadUrlMethod;
private DownloadUrlMethod|null $downloadUrlMethod;

public function __construct(
private readonly CompletePackageInterface $composerPackage,
Expand All @@ -53,14 +52,14 @@ public function __construct(
private readonly string $version,
private readonly string|null $downloadUrl,
) {
$this->configureOptions = [];
$this->supportZts = true;
$this->supportNts = true;
$this->buildPath = null;
$this->compatibleOsFamilies = null;
$this->incompatibleOsFamilies = null;
$this->priority = 80;
$this->overrideDownloadUrlMethod = null;
$this->configureOptions = [];
$this->supportZts = true;
$this->supportNts = true;
$this->buildPath = null;
$this->compatibleOsFamilies = null;
$this->incompatibleOsFamilies = null;
$this->priority = 80;
$this->downloadUrlMethod = null;
}

public static function fromComposerCompletePackage(CompletePackageInterface $completePackage): self
Expand Down Expand Up @@ -99,12 +98,8 @@ public static function fromComposerCompletePackage(CompletePackageInterface $com

$package->priority = $phpExtOptions['priority'] ?? 80;

if (
$phpExtOptions !== null
&& array_key_exists('override-download-url-method', $phpExtOptions)
&& is_string($phpExtOptions['override-download-url-method'])
) {
$package->overrideDownloadUrlMethod = DownloadUrlMethod::tryFrom($phpExtOptions['override-download-url-method']);
if ($phpExtOptions !== null && array_key_exists('download-url-method', $phpExtOptions)) {
$package->downloadUrlMethod = DownloadUrlMethod::tryFrom($phpExtOptions['download-url-method']);
}

return $package;
Expand Down Expand Up @@ -227,8 +222,8 @@ public function supportNts(): bool
return $this->supportNts;
}

public function overrideDownloadUrlMethod(): DownloadUrlMethod|null
public function downloadUrlMethod(): DownloadUrlMethod|null
{
return $this->overrideDownloadUrlMethod;
return $this->downloadUrlMethod;
}
}
2 changes: 1 addition & 1 deletion src/Downloading/DownloadUrlMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static function fromPackage(Package $package, TargetPlatform $targetPlatf
* external dependencies in Git submodules that otherwise aren't
* included in GitHub/Gitlab/etc "dist" downloads
*/
if ($package->overrideDownloadUrlMethod() === DownloadUrlMethod::PrePackagedSourceDownload) {
if ($package->downloadUrlMethod() === DownloadUrlMethod::PrePackagedSourceDownload) {
return self::PrePackagedSourceDownload;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public function testDistUrlIsUpdatedForPrePackagedTgzSource(): void
$composerPackage->setDistUrl('https://example.com/git-archive-zip-url');
$composerPackage->setPhpExt([
'extension-name' => 'foobar',
'override-download-url-method' => 'pre-packaged-source',
'download-url-method' => 'pre-packaged-source',
]);

/**
Expand Down

0 comments on commit 36da7b2

Please sign in to comment.