Symfony InputInterface providing type-specific getters for options and arguments

0.6 2021-02-18 14:29 UTC

This package is auto-updated.

Last update: 2022-11-18 18:31:55 UTC


A wrapper for Symfony\Component\Console\Input\InputInterface adding integer- and boolean-specific argument and option getters.

For fans of strongly-typed PHP, or just those tired of battling with phpstan --level max when analysing Symfony console commands.


public function getIntegerArgument(string $name): int;
public function getIntegerOption(string $name): int;
public function getBooleanArgument(string $name): bool;
public function getBooleanOption(string $name): bool;

All other InputInterface method calls are proxied to the wrapped InputInterface instance.


use webignition\SymfonyConsole\TypedInput\TypedInput;

// Assuming we're in a console command and $input is an InputInterface instance

$typedInput = new TypedInput($input);

// Guaranteed to return an integer
$integerArgument = $typedInput->getIntegerArgument('integer-argument-name');
$integerOption = $typedInput->getIntegerOption('integer-option-name');

// Guaranteed to return a boolean
$booleanArgument = $typedInput->getBooleanArgument('boolean-argument-name');
$booleanOption = $typedInput->getBooleanOption('boolean-option-name');