Skip to content

Commit

Permalink
Correct the Symfony constraints (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry authored Aug 3, 2022
1 parent 3d40285 commit e12e976
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ jobs:
- "8.0"
- "8.1"
tools: [ "composer" ]
dependency-versions: [ "highest" ]
include:
- php: "7.2"
tools: "composer:v2.0"
dependency-versions: "lowest"

steps:
- name: "Check out repository code"
Expand All @@ -38,7 +40,7 @@ jobs:
- name: "Install Composer dependencies"
uses: "ramsey/composer-install@v2"
with:
dependency-versions: "highest"
dependency-versions: "${{ matrix.dependency-versions }}"

- name: "Validate composer.json"
run: "composer validate --strict --no-check-lock"
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
"phpstan/phpstan": "^1.8",
"phpstan/phpstan-phpunit": "^1.1",
"phpunit/phpunit": "^8.5 || ^9.5",
"symfony/console": "^5.4.7 || ^6.0.7",
"symfony/finder": "^5.4.7 || ^6.0.7",
"symfony/process": "^5.4.7 || ^6.0.7"
"symfony/console": "^2.8.52 || ^3.4.35 || ^4.4 || ^5.0 || ^6.0",
"symfony/finder": "^2.8.52 || ^3.4.35 || ^4.4 || ^5.0 || ^6.0",
"symfony/process": "^2.8.52 || ^3.4.35 || ^4.4 || ^5.0 || ^6.0"
},
"autoload": {
"psr-4": {
Expand Down
6 changes: 3 additions & 3 deletions src/Command/BinCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,10 @@ private function executeAllNamespaces(

// Is a valid scenario: the user may not have set up any bin
// namespace yet
return self::SUCCESS;
return 0;
}

$exitCode = self::SUCCESS;
$exitCode = 0;

foreach ($namespaces as $namespace) {
$exitCode += $this->executeInNamespace(
Expand Down Expand Up @@ -200,7 +200,7 @@ private function executeInNamespace(
)
);

return self::FAILURE;
return 1;
}

// Use a new application: this avoids a variety of issues:
Expand Down
5 changes: 4 additions & 1 deletion tests/Config/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Bamarni\Composer\Bin\Config\Config;
use Bamarni\Composer\Bin\Config\InvalidBamarniComposerExtraConfig;
use PHPUnit\Framework\TestCase;
use function function_exists;

/**
* @covers \Bamarni\Composer\Bin\Config\Config
Expand Down Expand Up @@ -118,7 +119,9 @@ public static function provideInvalidExtraConfig(): iterable
Config::TARGET_DIRECTORY => false,
],
],
'Expected setting "bamarni-bin.target-directory" to be a string. Got "bool".',
function_exists('get_debug_type')
? 'Expected setting "bamarni-bin.target-directory" to be a string. Got "bool".'
: 'Expected setting "bamarni-bin.target-directory" to be a string. Got "boolean".',
];

yield 'non bool forward command' => [
Expand Down
8 changes: 6 additions & 2 deletions tests/Fixtures/MyTestCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Composer\Command\BaseCommand;
use Composer\Factory;
use Composer\IO\NullIO;
use function method_exists;

class MyTestCommand extends BaseCommand
{
Expand Down Expand Up @@ -39,7 +40,10 @@ public function __construct()

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

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

return self::SUCCESS;
return 0;
}
}

0 comments on commit e12e976

Please sign in to comment.