Skip to content

Commit 83c2aec

Browse files
minor symfony#61568 [Console] Harden array type for test-related user inputs (eliashaeussler)
This PR was submitted for the 6.4 branch but it was merged into the 7.4 branch instead. Discussion ---------- [Console] Harden array type for test-related user inputs | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #... | License | MIT User inputs must be strings, otherwise they cannot be properly written to the `php://memory` stream (because of the `str_contains` check here: https://github.com/symfony/symfony/blob/v6.4.25/src/Symfony/Component/Console/Tester/TesterTrait.php#L173). Using the hardened typed annotation, static code analyzers may assist developers in using correct array values. Commits ------- e8ca032 [Console] Harden array type for test-related user inputs
2 parents 9e86767 + e8ca032 commit 83c2aec

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Symfony/Component/Console/Tester/TesterTrait.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
trait TesterTrait
2525
{
2626
private StreamOutput $output;
27+
28+
/**
29+
* @var list<string>
30+
*/
2731
private array $inputs = [];
2832
private bool $captureStreamsIndependently = false;
2933
private InputInterface $input;
@@ -107,8 +111,8 @@ public function assertCommandIsSuccessful(string $message = ''): void
107111
/**
108112
* Sets the user inputs.
109113
*
110-
* @param array $inputs An array of strings representing each input
111-
* passed to the command input stream
114+
* @param list<string> $inputs An array of strings representing each input
115+
* passed to the command input stream
112116
*
113117
* @return $this
114118
*/
@@ -161,6 +165,8 @@ private function initOutput(array $options): void
161165
}
162166

163167
/**
168+
* @param list<string> $inputs
169+
*
164170
* @return resource
165171
*/
166172
private static function createStream(array $inputs)

0 commit comments

Comments
 (0)