Skip to content

Commit

Permalink
minor #54149 [Console] Document argv arrays for static analysis (derr…
Browse files Browse the repository at this point in the history
…abus)

This PR was merged into the 7.1 branch.

Discussion
----------

[Console] Document argv arrays for static analysis

| Q             | A
| ------------- | ---
| Branch?       | 7.1
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Issues        | Part of #53836
| License       | MIT

This PR adds PHPDoc blocks for static analyzers that should make mistakes like the ones described in #53836 more discoverable.

Commits
-------

a84f39a [Console] Document argv arrays for static analysis
  • Loading branch information
fabpot committed Mar 9, 2024
2 parents fabdf04 + a84f39a commit d7b9240
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Symfony/Component/Console/Input/ArgvInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@
*/
class ArgvInput extends Input
{
/** @var list<string> */
private array $tokens;
private array $parsed;

/** @param list<string>|null $argv */
public function __construct(?array $argv = null, ?InputDefinition $definition = null)
{
$argv ??= $_SERVER['argv'] ?? [];
Expand All @@ -55,6 +57,7 @@ public function __construct(?array $argv = null, ?InputDefinition $definition =
parent::__construct($definition);
}

/** @param list<string> $tokens */
protected function setTokens(array $tokens): void
{
$this->tokens = $tokens;
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Component/Console/Input/StringInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public function __construct(string $input)
/**
* Tokenizes a string.
*
* @return list<string>
*
* @throws InvalidArgumentException When unable to parse input (should never happen)
*/
private function tokenize(string $input): array
Expand Down

0 comments on commit d7b9240

Please sign in to comment.