Skip to content

Commit e7795ba

Browse files
committed
Updated feedback.
1 parent e934c5e commit e7795ba

File tree

8 files changed

+21
-16
lines changed

8 files changed

+21
-16
lines changed

.vortex/installer/src/Command/InstallCommand.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use DrevOps\VortexInstaller\Runner\CommandRunnerAwareTrait;
1212
use DrevOps\VortexInstaller\Runner\ExecutableFinderAwareInterface;
1313
use DrevOps\VortexInstaller\Runner\ExecutableFinderAwareTrait;
14+
use DrevOps\VortexInstaller\Runner\RunnerInterface;
1415
use DrevOps\VortexInstaller\Task\Task;
1516
use DrevOps\VortexInstaller\Utils\Config;
1617
use DrevOps\VortexInstaller\Utils\Env;
@@ -452,7 +453,7 @@ protected function runBuildCommand(OutputInterface $output): bool {
452453
$runner = $this->getCommandRunner();
453454
$runner->run('build', args: $is_profile ? ['--profile' => '1'] : [], output: $output);
454455

455-
return $runner->getExitCode() === Command::SUCCESS;
456+
return $runner->getExitCode() === RunnerInterface::EXIT_SUCCESS;
456457
}
457458

458459
protected function header(): void {
@@ -721,7 +722,7 @@ public function cleanup(): void {
721722
* The downloader.
722723
*/
723724
protected function getDownloader(): Downloader {
724-
return $this->downloader ?? new Downloader();
725+
return $this->downloader ??= new Downloader();
725726
}
726727

727728
/**

.vortex/installer/src/Runner/AbstractRunner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public function getOutput(bool $as_array = FALSE, ?int $lines = NULL): string |
205205
protected function reset(): void {
206206
$this->command = NULL;
207207
$this->output = '';
208-
$this->exitCode = self::EXIT_SUCCESS;
208+
$this->exitCode = RunnerInterface::EXIT_SUCCESS;
209209
}
210210

211211
/**

.vortex/installer/src/Runner/CommandRunnerAwareTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ trait CommandRunnerAwareTrait {
2525
*/
2626
public function getCommandRunner(): CommandRunner {
2727
// @phpstan-ignore-next-line
28-
return $this->commandRunner ?? new CommandRunner($this->getApplication());
28+
return $this->commandRunner ??= new CommandRunner($this->getApplication());
2929
}
3030

3131
/**

.vortex/installer/src/Runner/ProcessRunner.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,11 @@ protected function resolveCommand(string $command): array {
141141
protected function prepareArguments(array $parsed_args, array $additional_args): array {
142142
$all_args = array_merge($parsed_args, $this->formatArgs($additional_args));
143143

144-
foreach ($all_args as &$arg) {
144+
foreach ($all_args as $key => &$arg) {
145+
if (!is_scalar($arg)) {
146+
$value_repr = get_debug_type($arg);
147+
throw new \InvalidArgumentException(sprintf('Argument at index "%s" must be a scalar value, %s given.', $key, $value_repr));
148+
}
145149
$arg = (string) $arg;
146150
}
147151
unset($arg);
@@ -159,9 +163,10 @@ protected function prepareArguments(array $parsed_args, array $additional_args):
159163
* When an environment variable is not a scalar value.
160164
*/
161165
protected function validateEnvironmentVars(array $env): void {
162-
foreach ($env as $env_value) {
166+
foreach ($env as $key => $env_value) {
163167
if (!is_scalar($env_value)) {
164-
throw new \InvalidArgumentException('All environment variables must be scalar values.');
168+
$value_repr = get_debug_type($env_value);
169+
throw new \InvalidArgumentException(sprintf('Environment variable "%s" must be a scalar value, %s given.', $key, $value_repr));
165170
}
166171
}
167172
}

.vortex/installer/src/Runner/ProcessRunnerAwareTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ trait ProcessRunnerAwareTrait {
2323
* The process runner instance.
2424
*/
2525
public function getProcessRunner(): ProcessRunner {
26-
return $this->processRunner ?? new ProcessRunner();
26+
return $this->processRunner ??= new ProcessRunner();
2727
}
2828

2929
/**

.vortex/installer/tests/Functional/Command/CheckRequirementsCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function testCheckRequirementsCommand(
7272
}
7373

7474
/**
75-
* Data provider for testCheckWithMockedRunner.
75+
* Data provider for testCheckRequirementsCommand.
7676
*
7777
* @return array<string, array{
7878
* executable_finder_callback: \Closure,

.vortex/installer/tests/Unit/Runner/ProcessRunnerTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,7 @@ public function testValidateEnvironmentVars(array $env, ?string $expected_except
136136
$runner->validateEnvironmentVarsPublic($env);
137137

138138
if ($expected_exception === NULL) {
139-
// @phpstan-ignore-next-line
140-
$this->assertTrue(TRUE, 'Validation passed');
139+
$this->addToAssertionCount(1);
141140
}
142141
}
143142

.vortex/tests/phpunit/Traits/SutTrait.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ protected function runInstaller(array $arguments = []): void {
7474

7575
if (!is_dir(static::$root . '/.vortex/installer/vendor')) {
7676
$this->logNote('Installing dependencies of the Vortex installer');
77-
$this->cmd('composer --working-dir=' . static::$root . '/.vortex/installer install --no-interaction --no-progress');
77+
$this->cmd('composer --working-dir=' . escapeshellarg(static::$root . '/.vortex/installer') . ' install --no-interaction --no-progress');
7878
}
7979

8080
// @todo Convert options to $arguments once
8181
// ProcessTrait::processParseCommand() is fixed.
82-
$cmd = sprintf('php .vortex/installer/installer.php --no-interaction --destination=%s', static::locationsSut());
82+
$cmd = sprintf('php .vortex/installer/installer.php --no-interaction --destination=%s', escapeshellarg(static::locationsSut()));
8383

8484
$this->logNote('Run the installer script');
8585
$this->cmd(
@@ -134,14 +134,14 @@ protected function buildInstaller(): string {
134134

135135
if (!is_dir($installer_dir)) {
136136
$this->logNote('Installing dependencies of the Vortex installer');
137-
$this->cmd('composer --working-dir=' . $installer_dir . ' install --no-interaction --no-progress');
137+
$this->cmd('composer --working-dir=' . escapeshellarg($installer_dir) . ' install --no-interaction --no-progress');
138138
$this->assertDirectoryExists($installer_dir . '/vendor', 'Vortex installer vendor directory should exist after installing dependencies');
139139
}
140140

141-
$this->cmd('composer --working-dir=' . $installer_dir . ' build', env: ['SHELL_VERBOSITY' => -1], txt: 'Build the Vortex installer PHAR');
141+
$this->cmd('composer --working-dir=' . escapeshellarg($installer_dir) . ' build', env: ['SHELL_VERBOSITY' => -1], txt: 'Build the Vortex installer PHAR');
142142
$this->assertFileExists($installer_phar, 'Installer PHAR should be built');
143143

144-
$this->cmd('php ' . $installer_phar . ' --version');
144+
$this->cmd('php ' . escapeshellarg($installer_phar) . ' --version');
145145
$this->logNote('Built Vortex installer: ' . trim($this->processGet()->getOutput()));
146146

147147
return $installer_phar;

0 commit comments

Comments
 (0)