Skip to content
This repository was archived by the owner on Jan 21, 2020. It is now read-only.

Commit 828c97e

Browse files
committed
Convert questions to a string, fixes #243
Since symfony/console 4 questions only accept a question string. Looking at its history, this was always the case and is wrong in the composer docblock. see: https://github.com/symfony/console/blob/4.0/Question/Question.php#L37 see: https://github.com/composer/composer/blob/1.6/src/Composer/IO/IOInterface.php#L106
1 parent b3103e0 commit 828c97e

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

src/ExpressiveInstaller/OptionalPackages.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ public function requestInstallType() : string
251251
];
252252

253253
while (true) {
254-
$answer = $this->io->ask($query, '2');
254+
$answer = $this->io->ask(implode($query), '2');
255255

256256
switch (true) {
257257
case ($answer === '1'):
@@ -621,7 +621,7 @@ private function askQuestion(array $question, $defaultOption)
621621

622622
while (true) {
623623
// Ask for user input
624-
$answer = $this->io->ask($ask, (string) $defaultOption);
624+
$answer = $this->io->ask(implode($ask), (string) $defaultOption);
625625

626626
// Handle none of the options
627627
if ($answer === 'n' && $question['required'] !== true) {

test/ExpressiveInstallerTest/PromptForOptionalPackagesTest.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,16 @@ public function testPromptForOptionalPackage(
9090

9191
public static function assertPromptText($expected, $argument)
9292
{
93-
$argument = is_array($argument) ? array_shift($argument) : $argument;
94-
$message = sprintf('Expected prompt not received: "%s"', $expected);
95-
self::assertThat(false !== strpos($argument, $expected), self::isTrue(), $message);
93+
self::assertInternalType(
94+
'string',
95+
$argument,
96+
'Questions must be a string since symfony/console:4.0'
97+
);
98+
99+
self::assertThat(
100+
false !== strpos($argument, $expected),
101+
self::isTrue(),
102+
sprintf('Expected prompt not received: "%s"', $expected)
103+
);
96104
}
97105
}

test/ExpressiveInstallerTest/RequestInstallTypeTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ public function testWillContinueToPromptUntilValidAnswerPresented()
7878

7979
public static function assertQueryPrompt($value)
8080
{
81-
$value = is_array($value) ? array_shift($value) : $value;
81+
self::assertInternalType(
82+
'string',
83+
$value,
84+
'Questions must be a string since symfony/console:4.0'
85+
);
8286

8387
self::assertThat(
8488
false !== strpos($value, 'What type of installation would you like?'),

0 commit comments

Comments
 (0)