Skip to content

Commit c613d80

Browse files
committed
minor #18596 [Console] Corrected return type of anonymous functions (mwansinck)
This PR was merged into the 6.2 branch. Discussion ---------- [Console] Corrected return type of anonymous functions Fixes wrong return type (void) for anonymous functions clearly returning a string value When copying the current example from the docs it results in the following error; ``` Symfony\Component\ErrorHandler\Error\FatalError {#506 #message: "Compile Error: A void function must not return a value" #code: 0 #file: "./src/Command/ExampleCommand.php" #line: 58 -error: array:4 [ "type" => 64 "message" => "A void function must not return a value" "file" => "../src/Command/Debug/OverrideUserCommand.php" "line" => 58 ] } ``` Commits ------- d2e78f1 Corrected return type of anonymous functions
2 parents de29081 + d2e78f1 commit c613d80

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

components/console/helpers/questionhelper.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ provide a callback function to dynamically generate suggestions::
217217
// where files and dirs can be found
218218
$foundFilesAndDirs = @scandir($inputPath) ?: [];
219219

220-
return array_map(function (string $dirOrFile) use ($inputPath): void {
220+
return array_map(function (string $dirOrFile) use ($inputPath): string {
221221
return $inputPath.$dirOrFile;
222222
}, $foundFilesAndDirs);
223223
};
@@ -462,7 +462,7 @@ You can also use a validator with a hidden question::
462462
$question->setNormalizer(function (?string $value): string {
463463
return $value ?? '';
464464
});
465-
$question->setValidator(function (string $value): void {
465+
$question->setValidator(function (string $value): string {
466466
if ('' === trim($value)) {
467467
throw new \Exception('The password cannot be empty');
468468
}

0 commit comments

Comments
 (0)