Skip to content

Commit 1be144f

Browse files
committed
Add --php-versions parameters
1 parent f075f50 commit 1be144f

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

docker/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
FROM ubuntu:18.04
44

55
# Everything is not compatible with Composer 2
6-
COPY --from=composer:1.10.17 /usr/bin/composer /usr/local/bin/composer
6+
COPY --from=composer:1.10.19 /usr/bin/composer /usr/local/bin/composer
77

88
RUN \
99
# Update and instal some dependencies

src/Command/Configure/ConfigureBenchmarkCommand.php

+13-1
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,25 @@ protected function configure(): void
3535
foreach ($this->configurePhpBenchmarksConfigParameters as $name => $description) {
3636
$this->addOption($name, null, InputOption::VALUE_REQUIRED, $description);
3737
}
38+
$this->addOption(
39+
'php-versions',
40+
null,
41+
InputOption::VALUE_REQUIRED,
42+
'PHP version separated by "," (exemple: 7.1,7.2)'
43+
);
3844
}
3945

4046
protected function doExecute(): int
4147
{
48+
$phpCompatibleVersionsParams = [];
49+
$phpVersions = $this->getInput()->getOption('php-versions');
50+
if (is_string($phpVersions)) {
51+
$phpCompatibleVersionsParams['--php-versions'] = $phpVersions;
52+
}
53+
4254
$this
4355
->runConfigurePhpBenchmarksConfigCommand()
44-
->runCommand(ConfigurePhpCompatibleVersionCommand::getDefaultName())
56+
->runCommand(ConfigurePhpCompatibleVersionCommand::getDefaultName(), $phpCompatibleVersionsParams)
4557
->runCommand(ConfigureInitBenchmarkCommand::getDefaultName())
4658
->runCommand(ConfigureNginxVhostCommand::getDefaultName())
4759
->runCommand(ConfigureResponseBodyCommand::getDefaultName())

src/Command/Configure/Php/ConfigurePhpCompatibleVersionCommand.php

+20-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
PhpVersion\PhpVersionArray,
1212
Utils\Path
1313
};
14+
use Symfony\Component\Console\Input\InputOption;
1415

1516
final class ConfigurePhpCompatibleVersionCommand extends AbstractCommand
1617
{
@@ -23,7 +24,14 @@ protected function configure(): void
2324
{
2425
parent::configure();
2526

26-
$this->setDescription('Create configuration for each compatible PHP version');
27+
$this
28+
->setDescription('Create configuration for each compatible PHP version')
29+
->addOption(
30+
'php-versions',
31+
null,
32+
InputOption::VALUE_REQUIRED,
33+
'PHP version separated by "," (exemple: 7.1,7.2)'
34+
);
2735
}
2836

2937
protected function doExecute(): int
@@ -55,6 +63,17 @@ protected function doExecute(): int
5563

5664
private function getCompatiblesPhpVersions(): ?PhpVersionArray
5765
{
66+
$phpVersions = $this->getInput()->getOption('php-versions');
67+
if (is_string($phpVersions)) {
68+
$return = new PhpVersionArray();
69+
foreach (explode(',', $phpVersions) as $phpVersion) {
70+
[$major, $minor] = explode('.', $phpVersion);
71+
$return[] = new PhpVersion((int) $major, (int) $minor);
72+
}
73+
74+
return $return;
75+
}
76+
5877
$composerConfiguration = $this->getComposerConfiguration();
5978
/** @var string|null $phpVersionConfiguration */
6079
$phpVersionConfiguration = $composerConfiguration['require']['php'] ?? null;

0 commit comments

Comments
 (0)