Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Php documentation for methods "setOption()/setArgument()" doesn't allow arrays as values #28354

Copy link
Copy link
Closed
@liarco

Description

@liarco
Issue body actions

Hi, I'm working on a console application that deals with options registered as InputOption::VALUE_IS_ARRAY, but when I call $input->setOptions('my-option', ['value1', 'value2']) during initialization/validation my IDE complains about the second argument not matching the documentation (string|bool). The same applies to the setArgument($name, $value) method which is set to string only.

Since I might have array values for both options and arguments, should it be included into the documentation? Is it right to set array values for options/arguments in a this way?

Here is my proposal for the doc update: (I don't know if "array" is better than "string[]" here...)

    // File: symfony/console/Input/InputInterface.php

    // ...

    /**
     * Sets an argument value by name.
     *
     * @param string          $name  The argument name
     * @param string|string[] $value The argument value
     *
     * @throws InvalidArgumentException When argument given doesn't exist
     */
    public function setArgument($name, $value);

    // ...

    /**
     * Sets an option value by name.
     *
     * @param string               $name  The option name
     * @param string|string[]|bool $value The option value
     *
     * @throws InvalidArgumentException When option given doesn't exist
     */
    public function setOption($name, $value);

    // ...

Thank you for your time, please let me know if you want me to send a pull request for this.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.