If Symfony Console reports that an option property must declare a default value even though a constructor-promoted parameter has one, use explicit public DTO properties. This matches the documented MapInput structure and avoids relying on reflection behavior that is under review.
Last updated: November 17, 2026.
<?php
use Symfony\Component\Console\Attribute\Argument;
use Symfony\Component\Console\Attribute\MapInput;
use Symfony\Component\Console\Attribute\Option;
use Symfony\Component\Console\Command\Command;
final class ExportInput
{
#[Argument]
public string $path;
#[Option]
public bool $verbose = false;
}
final class ExportCommand
{
public function __invoke(#[MapInput] ExportInput $input): int
{
// Run the export using $input->path and $input->verbose.
return Command::SUCCESS;
}
}The option default is visible directly on the reflected property. Symfony can create the input definition before it constructs the DTO or invokes the command.
Why constructor promotion can fail here
Symfony’s Console input documentation shows #[Argument] and #[Option] on public DTO properties, then applies #[MapInput] to the command parameter. A current Symfony issue reports that defaults declared through constructor property promotion are not detected correctly in affected Symfony 7.4-and-later builds.
The failure happens while the command definition is assembled, before ordinary constructor execution can supply the promoted parameter default. Declaring the property and its default explicitly gives the Console component the metadata it expects during reflection.
Verify arguments, options and defaults
Run the command with and without the option and inspect bin/console help your:command. Confirm that required arguments, option names, shortcuts, accepted values and defaults match the DTO. Add a Console test for the omitted-option case because that is where an undetected default usually appears.
Record the exact Symfony Console version when reporting the problem. If a later maintenance release resolves the reflection behavior, test constructor promotion before switching back; do not assume all supported minor versions serialize DTO metadata identically. Keep validation or normalization inside the command boundary rather than hiding it in a default expression with unrelated side effects.