From 35e23a7cbc5346b6dce5a07aa49b4c2f11f42e32 Mon Sep 17 00:00:00 2001 From: sunxyw Date: Tue, 3 May 2022 16:13:13 +0800 Subject: [PATCH] simplify command help example --- src/Module/Example/Hello.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Module/Example/Hello.php b/src/Module/Example/Hello.php index 1746a9a9..2bcafa91 100644 --- a/src/Module/Example/Hello.php +++ b/src/Module/Example/Hello.php @@ -236,10 +236,9 @@ class Hello { $util = resolve(CommandInfoUtil::class); $commands = $util->get(); - $helps = []; - foreach ($commands as $command) { - $helps[] = $util->getHelp($command['id']); - } + $helps = array_map(static function ($command) use ($util) { + return $util->getHelp($command['id']); + }, $commands); array_unshift($helps, '帮助:'); return implode("\n", $helps); }