diff --git a/.gitignore b/.gitignore index 6f891b3ba..d6c95a099 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ /website/node_modules/ .DS_Store /.serverless/ -.phpunit.result.cache +.phpunit.cache node_modules/ package-lock.json +.claude diff --git a/composer.json b/composer.json index 5c497701b..725a6786a 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.1", + "symfony/console": "^6.4|^7.0|^8.0", + "symfony/yaml": "^6.4|^7.0|^8.0" }, "scripts": { "test": [ 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/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..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], @@ -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/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 b332a4bc0..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], @@ -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);