Skip to content

Commit f733a4f

Browse files
committed
Merge branch '7.4' into 8.0
* 7.4: fix merge skip hidden question tests on Windows fix compatibility with symfony/dependency-injection 8 Issue #51941 galician translation RedisTagAwareAdapter Add Predis2 Interface checks (fix #60050) fix deprecation version fixup! [Console] Specify types of interactive question choices fix using lock from service when previous locks used env vars
2 parents 0dca39b + b7dfa98 commit f733a4f

File tree

4 files changed

+60
-5
lines changed

4 files changed

+60
-5
lines changed

Question/ChoiceQuestion.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ class ChoiceQuestion extends Question
2525
private string $errorMessage = 'Value "%s" is invalid';
2626

2727
/**
28-
* @param string $question The question to ask to the user
29-
* @param array<string|bool|int|float> $choices The list of available choices
30-
* @param string|bool|int|float|null $default The default answer to return
28+
* @param string $question The question to ask to the user
29+
* @param array<string|bool|int|float|\Stringable> $choices The list of available choices
30+
* @param string|bool|int|float|null $default The default answer to return
3131
*/
3232
public function __construct(
3333
string $question,
@@ -45,7 +45,7 @@ public function __construct(
4545
}
4646

4747
/**
48-
* @return array<string|bool|int|float>
48+
* @return array<string|bool|int|float|\Stringable>
4949
*/
5050
public function getChoices(): array
5151
{

Tests/Fixtures/InvokableWithInteractiveAttributesTestCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class DummyDto
5656
public Arg2 $arg2;
5757

5858
#[Argument]
59-
#[Ask('Enter arg3', hidden: true)]
59+
#[Ask('Enter arg3')]
6060
public string $arg3;
6161

6262
#[Argument]
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Console\Tests\Fixtures;
13+
14+
use Symfony\Component\Console\Attribute\Argument;
15+
use Symfony\Component\Console\Attribute\AsCommand;
16+
use Symfony\Component\Console\Attribute\Ask;
17+
use Symfony\Component\Console\Attribute\MapInput;
18+
use Symfony\Component\Console\Command\Command;
19+
use Symfony\Component\Console\Style\SymfonyStyle;
20+
21+
#[AsCommand('invokable:interactive:question')]
22+
class InvokableWithInteractiveHiddenQuestionAttributeTestCommand
23+
{
24+
public function __invoke(
25+
SymfonyStyle $io,
26+
#[MapInput] DtoWithHiddenQuestionArg $dto,
27+
): int {
28+
$io->writeln('Arg1: '.$dto->arg1);
29+
30+
return Command::SUCCESS;
31+
}
32+
}
33+
34+
class DtoWithHiddenQuestionArg
35+
{
36+
#[Argument]
37+
#[Ask('Enter arg1', hidden: true)]
38+
public string $arg1;
39+
}

Tests/Tester/CommandTesterTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
use Symfony\Component\Console\Tests\Fixtures\InvokableTestCommand;
3131
use Symfony\Component\Console\Tests\Fixtures\InvokableWithInputTestCommand;
3232
use Symfony\Component\Console\Tests\Fixtures\InvokableWithInteractiveAttributesTestCommand;
33+
use Symfony\Component\Console\Tests\Fixtures\InvokableWithInteractiveHiddenQuestionAttributeTestCommand;
3334

3435
class CommandTesterTest extends TestCase
3536
{
@@ -490,4 +491,19 @@ public function testInvokableWithInteractiveQuestionParameter()
490491
self::assertStringContainsString('Enter arg5', $tester->getDisplay());
491492
self::assertStringContainsString('Arg5: arg5-value', $tester->getDisplay());
492493
}
494+
495+
public function testInvokableWithInteractiveHiddenQuestionParameter()
496+
{
497+
if ('\\' === \DIRECTORY_SEPARATOR) {
498+
$this->markTestSkipped('Cannot test hidden questions on Windows');
499+
}
500+
501+
$tester = new CommandTester(new InvokableWithInteractiveHiddenQuestionAttributeTestCommand());
502+
$tester->setInputs(['arg1-value']);
503+
$tester->execute([], ['interactive' => true]);
504+
$tester->assertCommandIsSuccessful();
505+
506+
self::assertStringContainsString('Enter arg1', $tester->getDisplay());
507+
self::assertStringContainsString('Arg1: arg1-value', $tester->getDisplay());
508+
}
493509
}

0 commit comments

Comments
 (0)