From 8acf82ee280008ce1dd58576185026f380c32037 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Fri, 4 Aug 2023 08:20:26 +0800 Subject: [PATCH 1/4] [10.x] Fixes `artisan about --only` should be case insensitive. fixes #47950 Signed-off-by: Mior Muhammad Zaki --- .../Foundation/Console/AboutCommand.php | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/Illuminate/Foundation/Console/AboutCommand.php b/src/Illuminate/Foundation/Console/AboutCommand.php index 1d1b47e96863..a2348b22ccd2 100644 --- a/src/Illuminate/Foundation/Console/AboutCommand.php +++ b/src/Illuminate/Foundation/Console/AboutCommand.php @@ -91,7 +91,7 @@ public function handle() return $index === false ? 99 : $index; }) ->filter(function ($data, $key) { - return $this->option('only') ? in_array(Str::of($key)->lower()->snake(), $this->sections()) : true; + return $this->option('only') ? in_array($this->toSearchKeyword($key), $this->sections()) : true; }) ->pipe(fn ($data) => $this->display($data)); @@ -141,7 +141,11 @@ protected function displayDetail($data) protected function displayJson($data) { $output = $data->flatMap(function ($data, $section) { - return [(string) Str::of($section)->snake() => $data->mapWithKeys(fn ($item, $key) => [(string) Str::of($item[0])->lower()->snake() => value($item[1])])]; + return [ + (string) Str::of($section)->snake() => $data->mapWithKeys(fn ($item, $key) => [ + $this->toSearchKeyword($item[0]) => value($item[1]) + ]) + ]; }); $this->output->writeln(strip_tags(json_encode($output))); @@ -250,6 +254,20 @@ protected static function addToSection(string $section, $data, string $value = n */ protected function sections() { - return array_filter(explode(',', $this->option('only') ?? '')); + return collect(explode(',', $this->option('only') ?? '')) + ->filter() + ->map(fn ($only) => $this->toSearchKeyword($only)) + ->all(); + } + + /** + * Convert to search keyword. + * + * @param string $value + * @return string + */ + protected function toSearchKeyword(string $value): string + { + return (string) Str::of($value)->lower()->snake(); } } From cf7628e0f066ae2bca1ae5490350561c502fa4be Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Fri, 4 Aug 2023 00:22:22 +0000 Subject: [PATCH 2/4] Apply fixes from StyleCI --- src/Illuminate/Foundation/Console/AboutCommand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Foundation/Console/AboutCommand.php b/src/Illuminate/Foundation/Console/AboutCommand.php index a2348b22ccd2..c291a05b3c41 100644 --- a/src/Illuminate/Foundation/Console/AboutCommand.php +++ b/src/Illuminate/Foundation/Console/AboutCommand.php @@ -143,8 +143,8 @@ protected function displayJson($data) $output = $data->flatMap(function ($data, $section) { return [ (string) Str::of($section)->snake() => $data->mapWithKeys(fn ($item, $key) => [ - $this->toSearchKeyword($item[0]) => value($item[1]) - ]) + $this->toSearchKeyword($item[0]) => value($item[1]), + ]), ]; }); From 54681fba6f4c03cf775e27d35906e7b2360ceb47 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Fri, 4 Aug 2023 08:56:41 +0800 Subject: [PATCH 3/4] wip Signed-off-by: Mior Muhammad Zaki --- src/Illuminate/Foundation/Console/AboutCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Foundation/Console/AboutCommand.php b/src/Illuminate/Foundation/Console/AboutCommand.php index c291a05b3c41..c3a454ab144a 100644 --- a/src/Illuminate/Foundation/Console/AboutCommand.php +++ b/src/Illuminate/Foundation/Console/AboutCommand.php @@ -266,7 +266,7 @@ protected function sections() * @param string $value * @return string */ - protected function toSearchKeyword(string $value): string + protected function toSearchKeyword(string $value) { return (string) Str::of($value)->lower()->snake(); } From 13eb092788e3851f72c4b7fe559c8940a446a606 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Fri, 4 Aug 2023 09:30:45 -0500 Subject: [PATCH 4/4] Update AboutCommand.php --- src/Illuminate/Foundation/Console/AboutCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Foundation/Console/AboutCommand.php b/src/Illuminate/Foundation/Console/AboutCommand.php index c3a454ab144a..3b632b3ae36d 100644 --- a/src/Illuminate/Foundation/Console/AboutCommand.php +++ b/src/Illuminate/Foundation/Console/AboutCommand.php @@ -261,7 +261,7 @@ protected function sections() } /** - * Convert to search keyword. + * Format the given string for searching. * * @param string $value * @return string