From 2576aa83c4ac43fd3f7ab261b3334f2154cedd30 Mon Sep 17 00:00:00 2001 From: Matthieu Napoli Date: Thu, 15 Jan 2026 10:20:56 +0100 Subject: [PATCH 1/5] Upgrade dependencies --- composer.json | 14 +++++++------- src/FpmRuntime/FpmHandler.php | 2 +- src/Runtime/LambdaRuntime.php | 6 ++---- tests/Event/Http/CommonHttpTest.php | 2 +- tests/FpmRuntime/FpmHandlerTest.php | 4 ++-- tests/Runtime/LambdaRuntimeTest.php | 4 ++-- tests/RuntimeTestCase.php | 4 ++-- 7 files changed, 17 insertions(+), 19 deletions(-) diff --git a/composer.json b/composer.json index 5c497701b..68080bb2e 100644 --- a/composer.json +++ b/composer.json @@ -29,20 +29,20 @@ "psr/http-message": "^1.0|^2.0", "psr/http-server-handler": "^1.0", "riverline/multipart-parser": "^2.1.2", - "symfony/process": "^5.4|^6.4|^7.0|^8.0" + "symfony/process": "^6.4|^7.0|^8.0" }, "require-dev": { "async-aws/core": "^1.0", - "async-aws/lambda": "^1.0", + "async-aws/lambda": "^2.0", "aws/aws-sdk-php": "^3.172", "bref/secrets-loader": "^1.0", - "dms/phpunit-arraysubset-asserts": "^0.4", + "dms/phpunit-arraysubset-asserts": "^0.5", "doctrine/coding-standard": "^8.0", "guzzlehttp/guzzle": "^7.5", - "phpstan/phpstan": "^1.10.26", - "phpunit/phpunit": "^9.6.10", - "symfony/console": "^5.4|^6.4|^7.0|^8.0", - "symfony/yaml": "^5.4|^6.4|^7.0|^8.0" + "phpstan/phpstan": "^2", + "phpunit/phpunit": "^10", + "symfony/console": "^6.4|^7.0|^8.0", + "symfony/yaml": "^6.4|^7.0|^8.0" }, "scripts": { "test": [ diff --git a/src/FpmRuntime/FpmHandler.php b/src/FpmRuntime/FpmHandler.php index 1f91d1387..6931b9caa 100644 --- a/src/FpmRuntime/FpmHandler.php +++ b/src/FpmRuntime/FpmHandler.php @@ -43,7 +43,7 @@ final class FpmHandler extends HttpHandler */ private const SIGTERM = 15; - private ?Client $client; + private ?Client $client = null; private UnixDomainSocket $connection; private string $handler; private string $configFile; diff --git a/src/Runtime/LambdaRuntime.php b/src/Runtime/LambdaRuntime.php index e08219809..4b9412ca7 100755 --- a/src/Runtime/LambdaRuntime.php +++ b/src/Runtime/LambdaRuntime.php @@ -35,10 +35,8 @@ */ final class LambdaRuntime { - /** @var resource|CurlHandle|null */ - private $curlHandleNext; - /** @var resource|CurlHandle|null */ - private $curlHandleResult; + private ?CurlHandle $curlHandleNext = null; + private ?CurlHandle $curlHandleResult = null; private string $apiUrl; private Invoker $invoker; private string $layer; diff --git a/tests/Event/Http/CommonHttpTest.php b/tests/Event/Http/CommonHttpTest.php index 1c4805901..e283076a2 100644 --- a/tests/Event/Http/CommonHttpTest.php +++ b/tests/Event/Http/CommonHttpTest.php @@ -232,7 +232,7 @@ public function test POST request with form data and content type(int $v ]); } - public function provideHttpMethodsWithRequestBodySupport(): array + public static function provideHttpMethodsWithRequestBodySupport(): array { return [ 'POST v1' => [ diff --git a/tests/FpmRuntime/FpmHandlerTest.php b/tests/FpmRuntime/FpmHandlerTest.php index b332a4bc0..1ae4a32bf 100644 --- a/tests/FpmRuntime/FpmHandlerTest.php +++ b/tests/FpmRuntime/FpmHandlerTest.php @@ -480,7 +480,7 @@ public function test POST request with form data and content type(int $v ]); } - public function provideHttpMethodsWithRequestBodySupport(): array + public static function provideHttpMethodsWithRequestBodySupport(): array { return [ 'POST v1' => [ @@ -1133,7 +1133,7 @@ public function test response with status code(int $expectedStatusCode) self::assertEquals($expectedStatusCode, $statusCode); } - public function provideStatusCodes(): array + public static function provideStatusCodes(): array { return [[200], [301], [302], [400], [401], [403], [404], [500], [504]]; } diff --git a/tests/Runtime/LambdaRuntimeTest.php b/tests/Runtime/LambdaRuntimeTest.php index aecc7d89a..ba568b78c 100644 --- a/tests/Runtime/LambdaRuntimeTest.php +++ b/tests/Runtime/LambdaRuntimeTest.php @@ -428,7 +428,7 @@ public function afterInvoke(mixed ...$params): void // The error response was already sent, it contains the handler error $this->assertInvocationErrorResult('Exception', 'Invocation error'); // The logs should contain both the handler error and the afterInvoke error - $this->assertStringContainsString('Invoke Error {"errorType":"Exception","errorMessage":"Invocation error","stack":', $this->getActualOutput()); - $this->assertStringContainsString('Invoke Error {"errorType":"Exception","errorMessage":"This is an exception in afterInvoke","stack":', $this->getActualOutput()); + $this->assertStringContainsString('Invoke Error {"errorType":"Exception","errorMessage":"Invocation error","stack":', $this->output()); + $this->assertStringContainsString('Invoke Error {"errorType":"Exception","errorMessage":"This is an exception in afterInvoke","stack":', $this->output()); } } diff --git a/tests/RuntimeTestCase.php b/tests/RuntimeTestCase.php index 9cf2602b0..de9469709 100644 --- a/tests/RuntimeTestCase.php +++ b/tests/RuntimeTestCase.php @@ -80,7 +80,7 @@ protected function assertInvocationErrorResult(string $errorClass, string $error protected function assertErrorInLogs(string $errorClass, string $errorMessage): void { // Decode the logs from stdout - $stdout = $this->getActualOutput(); + $stdout = $this->output(); [$requestId, $message, $json] = explode("\t", $stdout); @@ -108,7 +108,7 @@ protected function assertErrorInLogs(string $errorClass, string $errorMessage): protected function assertPreviousErrorsInLogs(array $previousErrors): void { // Decode the logs from stdout - $stdout = $this->getActualOutput(); + $stdout = $this->output(); [, , $json] = explode("\t", $stdout); From 65168a7d51bc18791cbaf4462d7b614c630090f8 Mon Sep 17 00:00:00 2001 From: Matthieu Napoli Date: Thu, 15 Jan 2026 11:06:54 +0100 Subject: [PATCH 2/5] Fixes --- .gitignore | 2 +- phpunit.xml | 16 +++++++++------- tests/Event/Http/CommonHttpTest.php | 2 +- tests/Event/Http/HttpRequestEventTest.php | 4 ++-- tests/FpmRuntime/FpmHandlerTest.php | 2 +- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 6f891b3ba..672c7d39e 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,6 @@ /website/node_modules/ .DS_Store /.serverless/ -.phpunit.result.cache +.phpunit.cache node_modules/ package-lock.json diff --git a/phpunit.xml b/phpunit.xml index f8a3f2026..e8e4f4094 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,21 +1,23 @@ - - - - src - - + ./tests/ ./tests/Sam ./tests/Fixtures + ./tests/HttpRequestProxyTest.php + ./tests/Event/Http/CommonHttpTest.php ./tests/Sam - + + + + src + + diff --git a/tests/Event/Http/CommonHttpTest.php b/tests/Event/Http/CommonHttpTest.php index e283076a2..c3940b5fa 100644 --- a/tests/Event/Http/CommonHttpTest.php +++ b/tests/Event/Http/CommonHttpTest.php @@ -7,7 +7,7 @@ abstract class CommonHttpTest extends TestCase implements HttpRequestProxyTest { - public function provide API Gateway versions(): array + public static function provide API Gateway versions(): array { return [ 'v1' => [1], diff --git a/tests/Event/Http/HttpRequestEventTest.php b/tests/Event/Http/HttpRequestEventTest.php index 925a324f9..bf9868450 100644 --- a/tests/Event/Http/HttpRequestEventTest.php +++ b/tests/Event/Http/HttpRequestEventTest.php @@ -168,7 +168,7 @@ public function test query string to array(string $query, array $expectedOut $this->assertEquals($expectedOutput, $result); } - public function provide query strings(): iterable + public static function provide query strings(): iterable { yield ['', []]; @@ -248,7 +248,7 @@ public function test query string will be parsed correctly(array $expected self::assertSame($normalizedQs, $event->getQueryString()); } - public function provide query strings for event(): array + public static function provide query strings for event(): array { return [ [['foo' => 'bar'], 'foo=bar', 'foo=bar'], diff --git a/tests/FpmRuntime/FpmHandlerTest.php b/tests/FpmRuntime/FpmHandlerTest.php index 1ae4a32bf..ae79a40a5 100644 --- a/tests/FpmRuntime/FpmHandlerTest.php +++ b/tests/FpmRuntime/FpmHandlerTest.php @@ -30,7 +30,7 @@ public function tearDown(): void ob_end_clean(); } - public function provide API Gateway versions(): array + public static function provide API Gateway versions(): array { return [ 'v1' => [1], From ea476399d68327fdafb64af25cdd35b9f10ce0b2 Mon Sep 17 00:00:00 2001 From: Matthieu Napoli Date: Thu, 15 Jan 2026 15:41:31 +0100 Subject: [PATCH 3/5] Fix PHPUnit 10.1 compatibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Require phpunit ^10.1 (for element support) - Remove manual ob_start/ob_end_clean (conflicts with PHPUnit output buffering) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .claude/settings.local.json | 8 ++++++++ composer.json | 2 +- tests/FpmRuntime/FpmHandlerLoadBalancerTest.php | 2 -- tests/FpmRuntime/FpmHandlerTest.php | 2 -- tests/RuntimeTestCase.php | 2 -- 5 files changed, 9 insertions(+), 7 deletions(-) create mode 100644 .claude/settings.local.json diff --git a/.claude/settings.local.json b/.claude/settings.local.json new file mode 100644 index 000000000..57aa488c0 --- /dev/null +++ b/.claude/settings.local.json @@ -0,0 +1,8 @@ +{ + "permissions": { + "allow": [ + "Bash(docker run:*)", + "Bash(vendor/bin/phpunit:*)" + ] + } +} diff --git a/composer.json b/composer.json index 68080bb2e..725a6786a 100644 --- a/composer.json +++ b/composer.json @@ -40,7 +40,7 @@ "doctrine/coding-standard": "^8.0", "guzzlehttp/guzzle": "^7.5", "phpstan/phpstan": "^2", - "phpunit/phpunit": "^10", + "phpunit/phpunit": "^10.1", "symfony/console": "^6.4|^7.0|^8.0", "symfony/yaml": "^6.4|^7.0|^8.0" }, diff --git a/tests/FpmRuntime/FpmHandlerLoadBalancerTest.php b/tests/FpmRuntime/FpmHandlerLoadBalancerTest.php index a41701783..49d6f7fc0 100644 --- a/tests/FpmRuntime/FpmHandlerLoadBalancerTest.php +++ b/tests/FpmRuntime/FpmHandlerLoadBalancerTest.php @@ -15,14 +15,12 @@ public function setUp(): void { parent::setUp(); - ob_start(); $this->fakeContext = new Context('abc', time(), 'abc', 'abc'); } public function tearDown(): void { $this->fpm->stop(); - ob_end_clean(); } /** diff --git a/tests/FpmRuntime/FpmHandlerTest.php b/tests/FpmRuntime/FpmHandlerTest.php index ae79a40a5..b59a524cf 100644 --- a/tests/FpmRuntime/FpmHandlerTest.php +++ b/tests/FpmRuntime/FpmHandlerTest.php @@ -20,14 +20,12 @@ public function setUp(): void { parent::setUp(); - ob_start(); $this->fakeContext = new Context('abc', time(), 'abc', 'abc'); } public function tearDown(): void { $this->fpm->stop(); - ob_end_clean(); } public static function provide API Gateway versions(): array diff --git a/tests/RuntimeTestCase.php b/tests/RuntimeTestCase.php index de9469709..51db0a194 100644 --- a/tests/RuntimeTestCase.php +++ b/tests/RuntimeTestCase.php @@ -15,7 +15,6 @@ abstract class RuntimeTestCase extends TestCase protected function setUp(): void { Bref::reset(); - ob_start(); Server::start(); putenv('AWS_LAMBDA_RUNTIME_API=localhost:8126'); } @@ -23,7 +22,6 @@ protected function setUp(): void protected function tearDown(): void { Server::stop(); - ob_end_clean(); } protected function givenAnEvent(mixed $event): void From d7644fe4eefb9a6d3895a277dd07739e4e206dd7 Mon Sep 17 00:00:00 2001 From: Matthieu Napoli Date: Thu, 15 Jan 2026 16:57:34 +0100 Subject: [PATCH 4/5] Ignore --- .claude/settings.local.json | 8 -------- .gitignore | 1 + 2 files changed, 1 insertion(+), 8 deletions(-) delete mode 100644 .claude/settings.local.json diff --git a/.claude/settings.local.json b/.claude/settings.local.json deleted file mode 100644 index 57aa488c0..000000000 --- a/.claude/settings.local.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "permissions": { - "allow": [ - "Bash(docker run:*)", - "Bash(vendor/bin/phpunit:*)" - ] - } -} diff --git a/.gitignore b/.gitignore index 672c7d39e..d6c95a099 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ .phpunit.cache node_modules/ package-lock.json +.claude From 451f1f5e7fbc6318abaf4fd9f976db1f5f388e08 Mon Sep 17 00:00:00 2001 From: Matthieu Napoli Date: Thu, 15 Jan 2026 16:59:24 +0100 Subject: [PATCH 5/5] Restore ob_start/ob_end_clean to prevent test timeouts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- tests/FpmRuntime/FpmHandlerLoadBalancerTest.php | 2 ++ tests/FpmRuntime/FpmHandlerTest.php | 2 ++ tests/RuntimeTestCase.php | 2 ++ 3 files changed, 6 insertions(+) diff --git a/tests/FpmRuntime/FpmHandlerLoadBalancerTest.php b/tests/FpmRuntime/FpmHandlerLoadBalancerTest.php index 49d6f7fc0..a41701783 100644 --- a/tests/FpmRuntime/FpmHandlerLoadBalancerTest.php +++ b/tests/FpmRuntime/FpmHandlerLoadBalancerTest.php @@ -15,12 +15,14 @@ public function setUp(): void { parent::setUp(); + ob_start(); $this->fakeContext = new Context('abc', time(), 'abc', 'abc'); } public function tearDown(): void { $this->fpm->stop(); + ob_end_clean(); } /** diff --git a/tests/FpmRuntime/FpmHandlerTest.php b/tests/FpmRuntime/FpmHandlerTest.php index b59a524cf..ae79a40a5 100644 --- a/tests/FpmRuntime/FpmHandlerTest.php +++ b/tests/FpmRuntime/FpmHandlerTest.php @@ -20,12 +20,14 @@ public function setUp(): void { parent::setUp(); + ob_start(); $this->fakeContext = new Context('abc', time(), 'abc', 'abc'); } public function tearDown(): void { $this->fpm->stop(); + ob_end_clean(); } public static function provide API Gateway versions(): array diff --git a/tests/RuntimeTestCase.php b/tests/RuntimeTestCase.php index 51db0a194..de9469709 100644 --- a/tests/RuntimeTestCase.php +++ b/tests/RuntimeTestCase.php @@ -15,6 +15,7 @@ abstract class RuntimeTestCase extends TestCase protected function setUp(): void { Bref::reset(); + ob_start(); Server::start(); putenv('AWS_LAMBDA_RUNTIME_API=localhost:8126'); } @@ -22,6 +23,7 @@ protected function setUp(): void protected function tearDown(): void { Server::stop(); + ob_end_clean(); } protected function givenAnEvent(mixed $event): void