Skip to content

ArgvInput throws an exception that does not link back to offending code #38105

Closed
@bilogic

Description

@bilogic

Symfony version(s) affected:
symfony/console v4.4.13 Symfony Console Component

Description

Referring to this class, https://github.com/symfony/console/blob/master/Input/ArgvInput.php, I ran into a situation where $argv is NULL by default and in turn caused $this->tokens to be NULL. This will cause an exception to be thrown when foreach() is applied on $this->tokens below:

How to reproduce

Many have reported about it in the past decade:

Possible Solution

Never allow $this->tokens to be NULL, at minimum, it should be an empty array.

  1. In __construct(), change the assign to call $this->setTokens($argv);
  2. In setTokens(), if (null == $tokens) $tokens = [];

Additional context

In the cases above (including my own), this exception does not link back to the offending code and becomes a real challenge to trace. I can submit a PR. Thank you.

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