From 6b0e069cb0a85c8a029898fb3540a71e14fecff8 Mon Sep 17 00:00:00 2001 From: LVMade01 <99674685+LVMade01@users.noreply.github.com> Date: Fri, 17 Feb 2023 14:17:01 +0100 Subject: [PATCH] Add Laravel 10 support (#13) * Add Laravel 10 support * Fix Laravel 10 for NonConsole * Repair test by allowing dependencies upgrade --------- Co-authored-by: Mitchell M --- .github/workflows/laravel-test.yaml | 4 +++- README.md | 9 +++++---- src/LogHandlers/ConsoleApp.php | 18 ++++++++++++++---- src/LogHandlers/NonConsole.php | 15 ++++++++++++--- 4 files changed, 34 insertions(+), 12 deletions(-) diff --git a/.github/workflows/laravel-test.yaml b/.github/workflows/laravel-test.yaml index c9e0eeb..aee0e1d 100644 --- a/.github/workflows/laravel-test.yaml +++ b/.github/workflows/laravel-test.yaml @@ -35,6 +35,8 @@ jobs: laravel: ^8.0 - php: 8.1 laravel: ^9.0 + - php: 8.2 + laravel: ^10.0 name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} @@ -87,7 +89,7 @@ jobs: cd laravel-app ls -lha cat composer.json - composer update --no-interaction --no-progress + composer update --no-interaction --no-progress --with-all-dependencies php artisan package:discover --ansi php artisan clear-compiled diff --git a/README.md b/README.md index f69a9cc..e2335b4 100644 --- a/README.md +++ b/README.md @@ -78,10 +78,11 @@ php artisan my:command -vvv | Compatible | Laravel | |--------------------|---------| -| :heavy_check_mark: | 9.* | -| :heavy_check_mark: | 8.* | -| :heavy_check_mark: | 7.* | -| :heavy_check_mark: | 6.* | +| :heavy_check_mark: | 10.* | +| :heavy_check_mark: | 9.* | +| :heavy_check_mark: | 8.* | +| :heavy_check_mark: | 7.* | +| :heavy_check_mark: | 6.* | --- diff --git a/src/LogHandlers/ConsoleApp.php b/src/LogHandlers/ConsoleApp.php index c33964f..97534b4 100644 --- a/src/LogHandlers/ConsoleApp.php +++ b/src/LogHandlers/ConsoleApp.php @@ -19,19 +19,29 @@ public function getProcessors(): array return []; } - public function isHandling(array $record): bool + /** + * @param array|Monolog\LogRecord $record + */ + public function isHandling($record): bool { return true; } - public function handle(array $record): bool + /** + * @param array|Monolog\LogRecord $record + */ + public function handle($record): bool { - $this->log(strtolower($record['level_name'] ?? ''), $record['message'] ?? '', $record['context'] ?? []); + $recordArray = is_array($record) ? $record : $record->toArray(); + $this->log(strtolower($recordArray['level_name'] ?? ''), $recordArray['message'] ?? '', $recordArray['context'] ?? []); return true; } - public function handleBatch(array $records): void + /** + * @param array|Monolog\LogRecord $record + */ + public function handleBatch($records): void { foreach ($records as $record) { $this->handle($record); diff --git a/src/LogHandlers/NonConsole.php b/src/LogHandlers/NonConsole.php index 6f1edf7..5e4c0ae 100644 --- a/src/LogHandlers/NonConsole.php +++ b/src/LogHandlers/NonConsole.php @@ -15,7 +15,10 @@ public function getHandlers(): array return []; } - public function isHandling(array $record): bool + /** + * @param array|Monolog\LogRecord $record + */ + public function isHandling($record): bool { return false; } @@ -25,12 +28,18 @@ public function getProcessors(): array return []; } - public function handle(array $record): bool + /** + * @param array|Monolog\LogRecord $record + */ + public function handle($record): bool { return false; } - public function handleBatch(array $records): void + /** + * @param array|Monolog\LogRecord $record + */ + public function handleBatch($records): void { }