Skip to content

Commit 3235a67

Browse files
Merge branch '7.4' into 8.0
* 7.4: (28 commits) [Console] Rename `#[Input]` to `#[MapInput]` [FrameworkBundle] Fix support of dumping workflow when workflow is decorated by TraceableWorkflow [JsonStreamer] Fix documentation link in README [Meta] Better exception when symfony link cannot read a JSON [Form] Add new `active_at`, `not_active_at` and `legal_tender` options to `CurrencyType` [Intl] Support time in generated data in currencies validity [Validator] Improve and complete Japanese translations [HtmlSanitizer] Remove redundant assignment to promoted property $config in constructor [Validator] Fix Polish translation for word count validation message [DependencyInjection][Routing] Deprecate XML configuration format [Validator] Review and fix Czech translation [DependencyInjection][Routing] Handle declaring services and routes using PHP arrays that follow the same shape as corresponding yaml files [Mailer][MailJet] Fix forbidden headers case-sensitive comparison [DependencyInjection][Config][Routing] Deprecate using `$this` or the internal scope of the loader from PHP config files [Config] Add array-shapes to generated config builders [DependencyInjection] Handle returning arrays and config-builders from config files [WebProfilerBundle] Simplify toolbar CSS do not use deprecated PHPUnit features replace PHPUnit annotation with attribute [Serializer] xml empty array encoding ...
2 parents 89368f8 + 8035299 commit 3235a67

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@
1515
use Symfony\Component\Console\Exception\LogicException;
1616
use Symfony\Component\Console\Input\InputInterface;
1717

18+
/**
19+
* Maps a command input into an object (DTO).
20+
*/
1821
#[\Attribute(\Attribute::TARGET_PARAMETER | \Attribute::TARGET_PROPERTY)]
19-
final class Input
22+
final class MapInput
2023
{
2124
/**
2225
* @var array<string, Argument|Option|self>

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ CHANGELOG
2121
* Add `BackedEnum` support with `#[Argument]` and `#[Option]` inputs in invokable commands
2222
* Allow Usages to be specified via `#[AsCommand]` attribute.
2323
* Allow passing invokable commands to `Symfony\Component\Console\Tester\CommandTester`
24-
* Add `#[Input]` attribute to support DTOs in commands
24+
* Add `#[MapInput]` attribute to support DTOs in commands
2525
* Add optional timeout for interaction in `QuestionHelper`
2626

2727
7.3

Command/InvokableCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
use Symfony\Component\Console\Application;
1515
use Symfony\Component\Console\Attribute\Argument;
16-
use Symfony\Component\Console\Attribute\Input;
16+
use Symfony\Component\Console\Attribute\MapInput;
1717
use Symfony\Component\Console\Attribute\Option;
1818
use Symfony\Component\Console\Exception\LogicException;
1919
use Symfony\Component\Console\Exception\RuntimeException;
@@ -80,7 +80,7 @@ public function configure(InputDefinition $definition): void
8080
continue;
8181
}
8282

83-
if ($input = Input::tryFrom($parameter)) {
83+
if ($input = MapInput::tryFrom($parameter)) {
8484
$inputArguments = array_map(fn (Argument $a) => $a->toInputArgument(), iterator_to_array($input->getArguments(), false));
8585

8686
// make sure optional arguments are defined after required ones
@@ -140,7 +140,7 @@ private function getParameters(InputInterface $input, OutputInterface $output):
140140
continue;
141141
}
142142

143-
if ($in = Input::tryFrom($parameter)) {
143+
if ($in = MapInput::tryFrom($parameter)) {
144144
$parameters[] = $in->resolveValue($input);
145145

146146
continue;

Tests/Fixtures/InvokableWithInputTestCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313

1414
use Symfony\Component\Console\Attribute\Argument;
1515
use Symfony\Component\Console\Attribute\AsCommand;
16-
use Symfony\Component\Console\Attribute\Input;
16+
use Symfony\Component\Console\Attribute\MapInput;
1717
use Symfony\Component\Console\Attribute\Option;
1818
use Symfony\Component\Console\Command\Command;
1919
use Symfony\Component\Console\Style\SymfonyStyle;
2020

2121
#[AsCommand('invokable:input:test')]
2222
class InvokableWithInputTestCommand
2323
{
24-
public function __invoke(SymfonyStyle $io, #[Input] UserDto $user): int
24+
public function __invoke(SymfonyStyle $io, #[MapInput] UserDto $user): int
2525
{
2626
$io->writeln($user->name);
2727
$io->writeln($user->email);
@@ -47,7 +47,7 @@ final class UserDto
4747
#[Argument]
4848
public string $password;
4949

50-
#[Input]
50+
#[MapInput]
5151
public UserGroupDto $group;
5252

5353
#[Option]

0 commit comments

Comments
 (0)