Skip to content

Commit 641d066

Browse files
authored
fix: Revert incorrect requirement bump (#183)
I intended to bump the minimum required Composer version in #177, unfortunately I missed to adjust the actual constraint `composer-plugin-api` there, resulting in issues to users. This PR restores support for older Composer versions. Closes #182.
1 parent f6af6be commit 641d066

4 files changed

Lines changed: 15 additions & 4 deletions

File tree

.github/workflows/tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
dependency-versions: [ "highest" ]
3131
include:
3232
- php: "7.2"
33-
tools: "composer:v2.6"
33+
tools: "composer:v2.2"
3434
dependency-versions: "lowest"
3535

3636
steps:

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818
"require-dev": {
1919
"ext-json": "*",
20-
"composer/composer": "^2.6",
20+
"composer/composer": "^2.2.26",
2121
"phpstan/extension-installer": "^1.1",
2222
"phpstan/phpstan": "^1.8 || ^2.0",
2323
"phpstan/phpstan-phpunit": "^1.1 || ^2.0",

src/Command/BinCommand.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
use function file_put_contents;
2727
use function getcwd;
2828
use function glob;
29+
use function method_exists;
2930
use function min;
3031
use function mkdir;
3132
use function putenv;
@@ -96,7 +97,11 @@ public function isProxyCommand(): bool
9697

9798
public function execute(InputInterface $input, OutputInterface $output): int
9899
{
99-
$composer = $this->requireComposer();
100+
// Switch to requireComposer() once Composer 2.3 is set as the minimum
101+
// @phpstan-ignore function.alreadyNarrowedType
102+
$composer = method_exists($this, 'requireComposer')
103+
? $this->requireComposer()
104+
: $this->getComposer();
100105

101106
$config = Config::fromComposer($composer);
102107
$currentWorkingDir = getcwd();

tests/Fixtures/MyTestCommand.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
use Composer\Factory;
1313
use Composer\IO\NullIO;
1414

15+
use function method_exists;
16+
1517
class MyTestCommand extends BaseCommand
1618
{
1719
/**
@@ -39,7 +41,11 @@ public function __construct()
3941

4042
public function execute(InputInterface $input, OutputInterface $output): int
4143
{
42-
$this->composer = $this->tryComposer();
44+
// Switch to tryComposer() once Composer 2.3 is set as the minimum
45+
// @phpstan-ignore function.alreadyNarrowedType
46+
$this->composer = method_exists($this, 'tryComposer')
47+
? $this->tryComposer()
48+
: $this->getComposer(false);
4349

4450
$factory = Factory::create(new NullIO());
4551
$config = $factory->getConfig();

0 commit comments

Comments
 (0)