From ed8643fe03ffe23e9a5dee4bf544d83dedb75bfc Mon Sep 17 00:00:00 2001 From: Manfred Egger Date: Thu, 29 Aug 2024 11:00:37 +0200 Subject: [PATCH] Add support for psr/log 2.0 and 3.0 --- bin/serve.php | 2 +- composer.json | 3 ++- phpstan.neon | 5 +++++ tests/Unit/Core/Service/ServiceManagerTest.php | 2 +- tests/Unit/Middleware/ErrorHandlingMiddlewareTest.php | 2 +- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/bin/serve.php b/bin/serve.php index 895bcbf..e620c53 100755 --- a/bin/serve.php +++ b/bin/serve.php @@ -82,7 +82,7 @@ public function __construct() $this->log = fopen('phpactor-lsp.log', 'w'); } - public function log($level, $message, array $context = []) + public function log($level, $message, array $context = []): void { $message = json_encode( [ diff --git a/composer.json b/composer.json index a515386..bb31af3 100644 --- a/composer.json +++ b/composer.json @@ -15,12 +15,13 @@ "dantleech/invoke": "^2.0", "phpactor/language-server-protocol": "^3.17", "psr/event-dispatcher": "^1.0", - "psr/log": "^1.0", + "psr/log": "^1.0 || ^2.0 || ^3.0", "ramsey/uuid": "^4.0", "thecodingmachine/safe": "^1.1" }, "require-dev": { "amphp/phpunit-util": "^1.3", + "colinodell/psr-testlogger": "^1.0", "ergebnis/composer-normalize": "^2.0", "friendsofphp/php-cs-fixer": "^3.0", "jangregor/phpstan-prophecy": "^1.0", diff --git a/phpstan.neon b/phpstan.neon index 65942c8..4961030 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -6,6 +6,11 @@ parameters: - lib - example - bin + ignoreErrors: + - + message: '#has parameter \$(context|message) with no (value )?type specified#' + path: 'bin/serve.php' + reportUnmatched: false includes: - phpstan-baseline.neon diff --git a/tests/Unit/Core/Service/ServiceManagerTest.php b/tests/Unit/Core/Service/ServiceManagerTest.php index 38e5fed..8209748 100644 --- a/tests/Unit/Core/Service/ServiceManagerTest.php +++ b/tests/Unit/Core/Service/ServiceManagerTest.php @@ -8,6 +8,7 @@ use Amp\PHPUnit\AsyncTestCase; use Amp\Promise; use Amp\Success; +use ColinODell\PsrTestLogger\TestLogger; use Exception; use Generator; use Phpactor\LanguageServer\Core\Dispatcher\ArgumentResolver; @@ -15,7 +16,6 @@ use Phpactor\LanguageServer\Core\Service\ServiceManager; use Phpactor\LanguageServer\Core\Service\ServiceProviders; use Prophecy\PhpUnit\ProphecyTrait; -use Psr\Log\Test\TestLogger; use RuntimeException; class ServiceManagerTest extends AsyncTestCase diff --git a/tests/Unit/Middleware/ErrorHandlingMiddlewareTest.php b/tests/Unit/Middleware/ErrorHandlingMiddlewareTest.php index 853fda4..447ef41 100644 --- a/tests/Unit/Middleware/ErrorHandlingMiddlewareTest.php +++ b/tests/Unit/Middleware/ErrorHandlingMiddlewareTest.php @@ -4,6 +4,7 @@ use Amp\PHPUnit\AsyncTestCase; use Amp\Success; +use ColinODell\PsrTestLogger\TestLogger; use Generator; use Phpactor\LanguageServer\Core\Handler\HandlerNotFound; use Phpactor\LanguageServer\Core\Middleware\RequestHandler; @@ -15,7 +16,6 @@ use Phpactor\LanguageServer\Core\Server\Exception\ExitSession; use Phpactor\LanguageServer\Middleware\ClosureMiddleware; use Phpactor\LanguageServer\Middleware\ErrorHandlingMiddleware; -use Psr\Log\Test\TestLogger; use RuntimeException; class ErrorHandlingMiddlewareTest extends AsyncTestCase