Skip to content

Commit e12e976

Browse files
authored
Correct the Symfony constraints (#137)
1 parent 3d40285 commit e12e976

File tree

5 files changed

+19
-10
lines changed

5 files changed

+19
-10
lines changed

.github/workflows/tests.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ jobs:
2121
- "8.0"
2222
- "8.1"
2323
tools: [ "composer" ]
24+
dependency-versions: [ "highest" ]
2425
include:
2526
- php: "7.2"
2627
tools: "composer:v2.0"
28+
dependency-versions: "lowest"
2729

2830
steps:
2931
- name: "Check out repository code"
@@ -38,7 +40,7 @@ jobs:
3840
- name: "Install Composer dependencies"
3941
uses: "ramsey/composer-install@v2"
4042
with:
41-
dependency-versions: "highest"
43+
dependency-versions: "${{ matrix.dependency-versions }}"
4244

4345
- name: "Validate composer.json"
4446
run: "composer validate --strict --no-check-lock"

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
"phpstan/phpstan": "^1.8",
2323
"phpstan/phpstan-phpunit": "^1.1",
2424
"phpunit/phpunit": "^8.5 || ^9.5",
25-
"symfony/console": "^5.4.7 || ^6.0.7",
26-
"symfony/finder": "^5.4.7 || ^6.0.7",
27-
"symfony/process": "^5.4.7 || ^6.0.7"
25+
"symfony/console": "^2.8.52 || ^3.4.35 || ^4.4 || ^5.0 || ^6.0",
26+
"symfony/finder": "^2.8.52 || ^3.4.35 || ^4.4 || ^5.0 || ^6.0",
27+
"symfony/process": "^2.8.52 || ^3.4.35 || ^4.4 || ^5.0 || ^6.0"
2828
},
2929
"autoload": {
3030
"psr-4": {

src/Command/BinCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,10 @@ private function executeAllNamespaces(
160160

161161
// Is a valid scenario: the user may not have set up any bin
162162
// namespace yet
163-
return self::SUCCESS;
163+
return 0;
164164
}
165165

166-
$exitCode = self::SUCCESS;
166+
$exitCode = 0;
167167

168168
foreach ($namespaces as $namespace) {
169169
$exitCode += $this->executeInNamespace(
@@ -200,7 +200,7 @@ private function executeInNamespace(
200200
)
201201
);
202202

203-
return self::FAILURE;
203+
return 1;
204204
}
205205

206206
// Use a new application: this avoids a variety of issues:

tests/Config/ConfigTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Bamarni\Composer\Bin\Config\Config;
88
use Bamarni\Composer\Bin\Config\InvalidBamarniComposerExtraConfig;
99
use PHPUnit\Framework\TestCase;
10+
use function function_exists;
1011

1112
/**
1213
* @covers \Bamarni\Composer\Bin\Config\Config
@@ -118,7 +119,9 @@ public static function provideInvalidExtraConfig(): iterable
118119
Config::TARGET_DIRECTORY => false,
119120
],
120121
],
121-
'Expected setting "bamarni-bin.target-directory" to be a string. Got "bool".',
122+
function_exists('get_debug_type')
123+
? 'Expected setting "bamarni-bin.target-directory" to be a string. Got "bool".'
124+
: 'Expected setting "bamarni-bin.target-directory" to be a string. Got "boolean".',
122125
];
123126

124127
yield 'non bool forward command' => [

tests/Fixtures/MyTestCommand.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Composer\Command\BaseCommand;
1212
use Composer\Factory;
1313
use Composer\IO\NullIO;
14+
use function method_exists;
1415

1516
class MyTestCommand extends BaseCommand
1617
{
@@ -39,7 +40,10 @@ public function __construct()
3940

4041
public function execute(InputInterface $input, OutputInterface $output): int
4142
{
42-
$this->composer = $this->tryComposer();
43+
// Switch to tryComposer() once Composer 2.3 is set as the minimum
44+
$this->composer = method_exists($this, 'tryComposer')
45+
? $this->tryComposer()
46+
: $this->getComposer(false);
4347

4448
$factory = Factory::create(new NullIO());
4549
$config = $factory->getConfig();
@@ -53,6 +57,6 @@ public function execute(InputInterface $input, OutputInterface $output): int
5357
$this->resetComposer();
5458
$this->getApplication()->resetComposer();
5559

56-
return self::SUCCESS;
60+
return 0;
5761
}
5862
}

0 commit comments

Comments
 (0)