Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Missing handling of array-type in ArrayInput::getFirstArgument #52580

Closed
@niklaswolf

Description

@niklaswolf

Symfony version(s) affected

7.0

Description

In contrast to other methods in this class, in ArrayInput::getFirstArgument there is no handling of the case that the value of the first parameter is of type Array.

if ($param && \is_string($param) && '-' === $param[0]) {

If this is the case, there is a type error:

Symfony\Component\Console\Input\ArrayInput::getFirstArgument(): Return value must be of type ?string, array returned

How to reproduce

Initialize ArrayInput with an array-value as the first argument, e.g.

$input = new ArrayInput(['foo' => ['value']]);
$value = $input->getFirstArgument()

Possible Solution

  • change the return type to mixed or allow array as a return type
  • handle arrays another way

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions