composer require michaelpetri/typed-input
$typedInput = TypedInput::fromInput($input);
echo $typedInput->getOption('my-option')->asNonEmptyString();
echo $typedInput->getArgument('my-argument')->asInteger();
asBoolean
asBooleanOrNull
asInteger
asIntegerOrNull
asPositiveInteger
asPositiveIntegerOrNull
asNaturalInteger
asNaturalIntegerOrNull
asString
asStringOrNull
asNonEmptyString
asNonEmptyStringOrNull
asNonEmptyStrings
asDateTimeImmutable