From 4509345075399bc49ebc8aba31f00f4487275271 Mon Sep 17 00:00:00 2001 From: Michael Hoffmann Date: Mon, 29 Sep 2025 10:25:12 +0200 Subject: [PATCH 1/9] meta: Run CI on PHP 8.5 --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6dee415f4..2d3e248bf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,6 +35,7 @@ jobs: - { version: '8.2', phpunit: '^9.6.21' } - { version: '8.3', phpunit: '^9.6.21' } - { version: '8.4', phpunit: '^9.6.21' } + - { version: '8.5', phpunit: '^9.6.21' } dependencies: - lowest - highest From 8b7501bdefce5fb2ec6f4454528882cc7863eba9 Mon Sep 17 00:00:00 2001 From: Martin Linzmayer Date: Mon, 20 Oct 2025 16:51:40 +0200 Subject: [PATCH 2/9] fix php 8.5 pipeline --- .../out_of_memory_fatal_error_increases_memory_limit.phpt | 6 ++++-- tests/phpt/error_handler_captures_fatal_error.phpt | 6 ++++-- .../error_handler_captures_out_of_memory_fatal_error.phpt | 7 +++++-- .../fatal_error_integration_captures_fatal_error.phpt | 8 +++++--- ...tal_error_integration_respects_error_types_option.phpt | 4 ++-- 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/tests/phpt-oom/out_of_memory_fatal_error_increases_memory_limit.phpt b/tests/phpt-oom/out_of_memory_fatal_error_increases_memory_limit.phpt index acef1edd9..ab992bf61 100644 --- a/tests/phpt-oom/out_of_memory_fatal_error_increases_memory_limit.phpt +++ b/tests/phpt-oom/out_of_memory_fatal_error_increases_memory_limit.phpt @@ -70,8 +70,10 @@ $array = []; for ($i = 0; $i < 100000000; ++$i) { $array[] = 'sentry'; } ---EXPECTF-- +--EXPECTREGEX-- Before OOM memory limit: 67108864 -Fatal error: Allowed memory size of %d bytes exhausted (tried to allocate %d bytes) in %s on line %d +Fatal error: Allowed memory size of 67108864 bytes exhausted \(tried to allocate 67108872 bytes\) in Standard input code on line 66 +(Stack trace:)? +(#0 {main})? Transport called After OOM memory limit: 72351744 diff --git a/tests/phpt/error_handler_captures_fatal_error.phpt b/tests/phpt/error_handler_captures_fatal_error.phpt index e7b457d2b..be787914c 100644 --- a/tests/phpt/error_handler_captures_fatal_error.phpt +++ b/tests/phpt/error_handler_captures_fatal_error.phpt @@ -67,7 +67,9 @@ final class TestClass implements \JsonSerializable { } ?> ---EXPECTF-- -Fatal error: Class Sentry\Tests\TestClass contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (JsonSerializable::jsonSerialize) in %s on line %d +--EXPECTREGEX-- +Fatal error: Class Sentry\\Tests\\TestClass contains 1 abstract method and must therefore be declared abstract or implement the remaining methods? \(JsonSerializable::jsonSerialize\) in Standard input code on line 63 +(Stack trace:)? +(#0 {main})? Transport called Fatal error listener called diff --git a/tests/phpt/error_handler_captures_out_of_memory_fatal_error.phpt b/tests/phpt/error_handler_captures_out_of_memory_fatal_error.phpt index bcc62e32b..f9261e285 100644 --- a/tests/phpt/error_handler_captures_out_of_memory_fatal_error.phpt +++ b/tests/phpt/error_handler_captures_out_of_memory_fatal_error.phpt @@ -32,8 +32,11 @@ echo 'Before OOM memory limit: ' . ini_get('memory_limit'); $foo = str_repeat('x', 1024 * 1024 * 1024); ?> ---EXPECTF-- +--EXPECTREGEX-- Before OOM memory limit: 67108864 -Fatal error: Allowed memory size of %d bytes exhausted (tried to allocate %d bytes) in %s on line %d +Fatal error: Allowed memory size of 67108864 bytes exhausted \(tried to allocate 1073741856 bytes\) in Standard input code on line 28 +(Stack trace:)? +(#0 Standard input code\(28\): str_repeat\('x', 1073741824\))? +(#1 {main})? Fatal error listener called After OOM memory limit: 67108864 diff --git a/tests/phpt/fatal_error_integration_captures_fatal_error.phpt b/tests/phpt/fatal_error_integration_captures_fatal_error.phpt index ba82e9bca..ccb4f1c4d 100644 --- a/tests/phpt/fatal_error_integration_captures_fatal_error.phpt +++ b/tests/phpt/fatal_error_integration_captures_fatal_error.phpt @@ -57,6 +57,8 @@ final class TestClass implements \JsonSerializable { } ?> ---EXPECTF-- -Fatal error: Class Sentry\Tests\TestClass contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (JsonSerializable::jsonSerialize) in %s on line %d -Transport called +--EXPECTREGEX-- +^Fatal error: Class Sentry\\Tests\\TestClass contains 1 abstract methods? and must therefore be declared abstract or implement the remaining methods? \(JsonSerializable::jsonSerialize\) in Standard input code on line 53 +(Stack trace:)? +(#0 {main})? +Transport called\R?$ diff --git a/tests/phpt/fatal_error_integration_respects_error_types_option.phpt b/tests/phpt/fatal_error_integration_respects_error_types_option.phpt index 8010b35b2..6c3c06f59 100644 --- a/tests/phpt/fatal_error_integration_respects_error_types_option.phpt +++ b/tests/phpt/fatal_error_integration_respects_error_types_option.phpt @@ -58,5 +58,5 @@ final class TestClass implements \JsonSerializable { } ?> ---EXPECTF-- -Fatal error: Class Sentry\Tests\TestClass contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (JsonSerializable::jsonSerialize) in %s on line %d +--EXPECTREGEX-- +Fatal error: Class Sentry\\Tests\\TestClass contains 1 abstract method and must therefore be declared abstract or implement the remaining methods? \(JsonSerializable::jsonSerialize\) in Standard input code on line 54 From 24028f3063139c5e6f6ac8a88d7c0c7840c1b900 Mon Sep 17 00:00:00 2001 From: Martin Linzmayer Date: Mon, 20 Oct 2025 16:54:40 +0200 Subject: [PATCH 3/9] wip --- .../out_of_memory_fatal_error_increases_memory_limit.phpt | 2 +- tests/phpt/error_handler_captures_fatal_error.phpt | 2 +- .../phpt/error_handler_captures_out_of_memory_fatal_error.phpt | 2 +- tests/phpt/fatal_error_integration_captures_fatal_error.phpt | 2 +- .../fatal_error_integration_respects_error_types_option.phpt | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/phpt-oom/out_of_memory_fatal_error_increases_memory_limit.phpt b/tests/phpt-oom/out_of_memory_fatal_error_increases_memory_limit.phpt index ab992bf61..982ab8475 100644 --- a/tests/phpt-oom/out_of_memory_fatal_error_increases_memory_limit.phpt +++ b/tests/phpt-oom/out_of_memory_fatal_error_increases_memory_limit.phpt @@ -72,7 +72,7 @@ for ($i = 0; $i < 100000000; ++$i) { } --EXPECTREGEX-- Before OOM memory limit: 67108864 -Fatal error: Allowed memory size of 67108864 bytes exhausted \(tried to allocate 67108872 bytes\) in Standard input code on line 66 +Fatal error: Allowed memory size of 67108864 bytes exhausted \(tried to allocate 67108872 bytes\) in .* on line 66 (Stack trace:)? (#0 {main})? Transport called diff --git a/tests/phpt/error_handler_captures_fatal_error.phpt b/tests/phpt/error_handler_captures_fatal_error.phpt index be787914c..a7ad8e001 100644 --- a/tests/phpt/error_handler_captures_fatal_error.phpt +++ b/tests/phpt/error_handler_captures_fatal_error.phpt @@ -68,7 +68,7 @@ final class TestClass implements \JsonSerializable } ?> --EXPECTREGEX-- -Fatal error: Class Sentry\\Tests\\TestClass contains 1 abstract method and must therefore be declared abstract or implement the remaining methods? \(JsonSerializable::jsonSerialize\) in Standard input code on line 63 +Fatal error: Class Sentry\\Tests\\TestClass contains 1 abstract method and must therefore be declared abstract or implement the remaining methods? \(JsonSerializable::jsonSerialize\) in .* on line 63 (Stack trace:)? (#0 {main})? Transport called diff --git a/tests/phpt/error_handler_captures_out_of_memory_fatal_error.phpt b/tests/phpt/error_handler_captures_out_of_memory_fatal_error.phpt index f9261e285..dda9b4ef4 100644 --- a/tests/phpt/error_handler_captures_out_of_memory_fatal_error.phpt +++ b/tests/phpt/error_handler_captures_out_of_memory_fatal_error.phpt @@ -34,7 +34,7 @@ $foo = str_repeat('x', 1024 * 1024 * 1024); ?> --EXPECTREGEX-- Before OOM memory limit: 67108864 -Fatal error: Allowed memory size of 67108864 bytes exhausted \(tried to allocate 1073741856 bytes\) in Standard input code on line 28 +Fatal error: Allowed memory size of 67108864 bytes exhausted \(tried to allocate 1073741856 bytes\) in .* on line 28 (Stack trace:)? (#0 Standard input code\(28\): str_repeat\('x', 1073741824\))? (#1 {main})? diff --git a/tests/phpt/fatal_error_integration_captures_fatal_error.phpt b/tests/phpt/fatal_error_integration_captures_fatal_error.phpt index ccb4f1c4d..39ef6c803 100644 --- a/tests/phpt/fatal_error_integration_captures_fatal_error.phpt +++ b/tests/phpt/fatal_error_integration_captures_fatal_error.phpt @@ -58,7 +58,7 @@ final class TestClass implements \JsonSerializable } ?> --EXPECTREGEX-- -^Fatal error: Class Sentry\\Tests\\TestClass contains 1 abstract methods? and must therefore be declared abstract or implement the remaining methods? \(JsonSerializable::jsonSerialize\) in Standard input code on line 53 +^Fatal error: Class Sentry\\Tests\\TestClass contains 1 abstract methods? and must therefore be declared abstract or implement the remaining methods? \(JsonSerializable::jsonSerialize\) in .* on line 53 (Stack trace:)? (#0 {main})? Transport called\R?$ diff --git a/tests/phpt/fatal_error_integration_respects_error_types_option.phpt b/tests/phpt/fatal_error_integration_respects_error_types_option.phpt index 6c3c06f59..bb8cb6944 100644 --- a/tests/phpt/fatal_error_integration_respects_error_types_option.phpt +++ b/tests/phpt/fatal_error_integration_respects_error_types_option.phpt @@ -59,4 +59,4 @@ final class TestClass implements \JsonSerializable } ?> --EXPECTREGEX-- -Fatal error: Class Sentry\\Tests\\TestClass contains 1 abstract method and must therefore be declared abstract or implement the remaining methods? \(JsonSerializable::jsonSerialize\) in Standard input code on line 54 +Fatal error: Class Sentry\\Tests\\TestClass contains 1 abstract method and must therefore be declared abstract or implement the remaining methods? \(JsonSerializable::jsonSerialize\) in .* on line 54 From 0a8971d214e2ea3eefeeabcd1a13270090b2e7bf Mon Sep 17 00:00:00 2001 From: Martin Linzmayer Date: Mon, 20 Oct 2025 17:22:03 +0200 Subject: [PATCH 4/9] wip --- .../out_of_memory_fatal_error_increases_memory_limit.phpt | 8 +++----- tests/phpt/error_handler_captures_fatal_error.phpt | 4 +--- .../error_handler_captures_out_of_memory_fatal_error.phpt | 5 +---- .../fatal_error_integration_captures_fatal_error.phpt | 4 +--- 4 files changed, 6 insertions(+), 15 deletions(-) diff --git a/tests/phpt-oom/out_of_memory_fatal_error_increases_memory_limit.phpt b/tests/phpt-oom/out_of_memory_fatal_error_increases_memory_limit.phpt index 982ab8475..73e82ed61 100644 --- a/tests/phpt-oom/out_of_memory_fatal_error_increases_memory_limit.phpt +++ b/tests/phpt-oom/out_of_memory_fatal_error_increases_memory_limit.phpt @@ -71,9 +71,7 @@ for ($i = 0; $i < 100000000; ++$i) { $array[] = 'sentry'; } --EXPECTREGEX-- -Before OOM memory limit: 67108864 -Fatal error: Allowed memory size of 67108864 bytes exhausted \(tried to allocate 67108872 bytes\) in .* on line 66 -(Stack trace:)? -(#0 {main})? +^Before OOM memory limit: 67108864 +Fatal error: Allowed memory size of 67108864 bytes exhausted \(tried to allocate \d+ bytes\) in [^\r\n]+ on line \d+(?:\RStack trace:\R(?:#\d+[^\r\n]*)+)? Transport called -After OOM memory limit: 72351744 +After OOM memory limit: 72351744$ diff --git a/tests/phpt/error_handler_captures_fatal_error.phpt b/tests/phpt/error_handler_captures_fatal_error.phpt index a7ad8e001..4cd3fa493 100644 --- a/tests/phpt/error_handler_captures_fatal_error.phpt +++ b/tests/phpt/error_handler_captures_fatal_error.phpt @@ -68,8 +68,6 @@ final class TestClass implements \JsonSerializable } ?> --EXPECTREGEX-- -Fatal error: Class Sentry\\Tests\\TestClass contains 1 abstract method and must therefore be declared abstract or implement the remaining methods? \(JsonSerializable::jsonSerialize\) in .* on line 63 -(Stack trace:)? -(#0 {main})? +Fatal error: Class Sentry\\Tests\\TestClass contains 1 abstract method and must therefore be declared abstract or implement the remaining methods? \(JsonSerializable::jsonSerialize\) in .* on line 63(?:\RStack trace:\R(?:#\d+[^\r\n]*)+)? Transport called Fatal error listener called diff --git a/tests/phpt/error_handler_captures_out_of_memory_fatal_error.phpt b/tests/phpt/error_handler_captures_out_of_memory_fatal_error.phpt index dda9b4ef4..fc96d0b63 100644 --- a/tests/phpt/error_handler_captures_out_of_memory_fatal_error.phpt +++ b/tests/phpt/error_handler_captures_out_of_memory_fatal_error.phpt @@ -34,9 +34,6 @@ $foo = str_repeat('x', 1024 * 1024 * 1024); ?> --EXPECTREGEX-- Before OOM memory limit: 67108864 -Fatal error: Allowed memory size of 67108864 bytes exhausted \(tried to allocate 1073741856 bytes\) in .* on line 28 -(Stack trace:)? -(#0 Standard input code\(28\): str_repeat\('x', 1073741824\))? -(#1 {main})? +Fatal error: Allowed memory size of 67108864 bytes exhausted \(tried to allocate 1073741856 bytes\) in .* on line 28(?:\RStack trace:\R(?:#\d+.*\R?)+)? Fatal error listener called After OOM memory limit: 67108864 diff --git a/tests/phpt/fatal_error_integration_captures_fatal_error.phpt b/tests/phpt/fatal_error_integration_captures_fatal_error.phpt index 39ef6c803..3e0aeb08a 100644 --- a/tests/phpt/fatal_error_integration_captures_fatal_error.phpt +++ b/tests/phpt/fatal_error_integration_captures_fatal_error.phpt @@ -58,7 +58,5 @@ final class TestClass implements \JsonSerializable } ?> --EXPECTREGEX-- -^Fatal error: Class Sentry\\Tests\\TestClass contains 1 abstract methods? and must therefore be declared abstract or implement the remaining methods? \(JsonSerializable::jsonSerialize\) in .* on line 53 -(Stack trace:)? -(#0 {main})? +^Fatal error: Class Sentry\\Tests\\TestClass contains 1 abstract methods? and must therefore be declared abstract or implement the remaining methods? \(JsonSerializable::jsonSerialize\) in .* on line 53(?:\RStack trace:\R(?:#\d+[^\r\n]*)+)? Transport called\R?$ From 0f96a98306bb35e93d72185de3d7b6034fd56715 Mon Sep 17 00:00:00 2001 From: Martin Linzmayer Date: Mon, 20 Oct 2025 17:30:07 +0200 Subject: [PATCH 5/9] wip --- tests/phpt/error_handler_captures_fatal_error.phpt | 2 +- tests/phpt/fatal_error_integration_captures_fatal_error.phpt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/phpt/error_handler_captures_fatal_error.phpt b/tests/phpt/error_handler_captures_fatal_error.phpt index 4cd3fa493..ac4acae7f 100644 --- a/tests/phpt/error_handler_captures_fatal_error.phpt +++ b/tests/phpt/error_handler_captures_fatal_error.phpt @@ -68,6 +68,6 @@ final class TestClass implements \JsonSerializable } ?> --EXPECTREGEX-- -Fatal error: Class Sentry\\Tests\\TestClass contains 1 abstract method and must therefore be declared abstract or implement the remaining methods? \(JsonSerializable::jsonSerialize\) in .* on line 63(?:\RStack trace:\R(?:#\d+[^\r\n]*)+)? +Fatal error: Class Sentry\\Tests\\TestClass contains 1 abstract method and must therefore be declared abstract or implement the remaining methods? \(JsonSerializable::jsonSerialize\) in .* on line 63(?:\RStack trace:\R(?:#\d+.*\R?)+)? Transport called Fatal error listener called diff --git a/tests/phpt/fatal_error_integration_captures_fatal_error.phpt b/tests/phpt/fatal_error_integration_captures_fatal_error.phpt index 3e0aeb08a..2582c4cd9 100644 --- a/tests/phpt/fatal_error_integration_captures_fatal_error.phpt +++ b/tests/phpt/fatal_error_integration_captures_fatal_error.phpt @@ -58,5 +58,5 @@ final class TestClass implements \JsonSerializable } ?> --EXPECTREGEX-- -^Fatal error: Class Sentry\\Tests\\TestClass contains 1 abstract methods? and must therefore be declared abstract or implement the remaining methods? \(JsonSerializable::jsonSerialize\) in .* on line 53(?:\RStack trace:\R(?:#\d+[^\r\n]*)+)? +^Fatal error: Class Sentry\\Tests\\TestClass contains 1 abstract methods? and must therefore be declared abstract or implement the remaining methods? \(JsonSerializable::jsonSerialize\) in .* on line 53(?:\RStack trace:\R(?:#\d+.*\R?)+)? Transport called\R?$ From fbb6affb08cf24260450499f47acc0987580a869 Mon Sep 17 00:00:00 2001 From: Martin Linzmayer Date: Thu, 6 Nov 2025 14:02:12 +0100 Subject: [PATCH 6/9] duplicate tests for php 8.5, bump phpunit 9 --- composer.json | 2 +- ...ry_fatal_error_increases_memory_limit.phpt | 13 ++- ...ry_fatal_error_increases_memory_limit.phpt | 84 +++++++++++++++++++ .../error_handler_captures_fatal_error.phpt | 9 +- ...er_captures_out_of_memory_fatal_error.phpt | 9 +- ...rror_integration_captures_fatal_error.phpt | 11 ++- ...tegration_respects_error_types_option.phpt | 9 +- .../error_handler_captures_fatal_error.phpt | 80 ++++++++++++++++++ ...er_captures_out_of_memory_fatal_error.phpt | 46 ++++++++++ ...rror_integration_captures_fatal_error.phpt | 69 +++++++++++++++ ...tegration_respects_error_types_option.phpt | 69 +++++++++++++++ 11 files changed, 387 insertions(+), 14 deletions(-) rename tests/phpt-oom/{ => php84}/out_of_memory_fatal_error_increases_memory_limit.phpt (86%) create mode 100644 tests/phpt-oom/php85/out_of_memory_fatal_error_increases_memory_limit.phpt rename tests/phpt/{ => php84}/error_handler_captures_fatal_error.phpt (84%) rename tests/phpt/{ => php84}/error_handler_captures_out_of_memory_fatal_error.phpt (80%) rename tests/phpt/{ => php84}/fatal_error_integration_captures_fatal_error.phpt (80%) rename tests/phpt/{ => php84}/fatal_error_integration_respects_error_types_option.phpt (81%) create mode 100644 tests/phpt/php85/error_handler_captures_fatal_error.phpt create mode 100644 tests/phpt/php85/error_handler_captures_out_of_memory_fatal_error.phpt create mode 100644 tests/phpt/php85/fatal_error_integration_captures_fatal_error.phpt create mode 100644 tests/phpt/php85/fatal_error_integration_respects_error_types_option.phpt diff --git a/composer.json b/composer.json index d8e863cc8..e6deb6a4c 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,7 @@ "monolog/monolog": "^1.6|^2.0|^3.0", "phpbench/phpbench": "^1.0", "phpstan/phpstan": "^1.3", - "phpunit/phpunit": "^8.5|^9.6", + "phpunit/phpunit": "^8.5|^9.6.25", "symfony/phpunit-bridge": "^5.2|6.4.25|7.3.3", "vimeo/psalm": "^4.17" }, diff --git a/tests/phpt-oom/out_of_memory_fatal_error_increases_memory_limit.phpt b/tests/phpt-oom/php84/out_of_memory_fatal_error_increases_memory_limit.phpt similarity index 86% rename from tests/phpt-oom/out_of_memory_fatal_error_increases_memory_limit.phpt rename to tests/phpt-oom/php84/out_of_memory_fatal_error_increases_memory_limit.phpt index 73e82ed61..19b7a6d08 100644 --- a/tests/phpt-oom/out_of_memory_fatal_error_increases_memory_limit.phpt +++ b/tests/phpt-oom/php84/out_of_memory_fatal_error_increases_memory_limit.phpt @@ -1,5 +1,10 @@ --TEST-- Test that when handling a out of memory error the memory limit is increased with 5 MiB and the event is serialized and ready to be sent +--SKIPIF-- + 80400) { + die('skip - only works for PHP 8.4 and below'); +} --INI-- memory_limit=67108864 --FILE-- @@ -70,8 +75,8 @@ $array = []; for ($i = 0; $i < 100000000; ++$i) { $array[] = 'sentry'; } ---EXPECTREGEX-- -^Before OOM memory limit: 67108864 -Fatal error: Allowed memory size of 67108864 bytes exhausted \(tried to allocate \d+ bytes\) in [^\r\n]+ on line \d+(?:\RStack trace:\R(?:#\d+[^\r\n]*)+)? +--EXPECTF-- +Before OOM memory limit: 67108864 +Fatal error: Allowed memory size of %d bytes exhausted (tried to allocate %d bytes) in %s on line %d Transport called -After OOM memory limit: 72351744$ +After OOM memory limit: 72351744 diff --git a/tests/phpt-oom/php85/out_of_memory_fatal_error_increases_memory_limit.phpt b/tests/phpt-oom/php85/out_of_memory_fatal_error_increases_memory_limit.phpt new file mode 100644 index 000000000..92e030588 --- /dev/null +++ b/tests/phpt-oom/php85/out_of_memory_fatal_error_increases_memory_limit.phpt @@ -0,0 +1,84 @@ +--TEST-- +Test that when handling a out of memory error the memory limit is increased with 5 MiB and the event is serialized and ready to be sent +--SKIPIF-- + 'http://public@example.com/sentry/1', +]); + +$transport = new class(new PayloadSerializer($options)) implements TransportInterface { + private $payloadSerializer; + + public function __construct(PayloadSerializerInterface $payloadSerializer) + { + $this->payloadSerializer = $payloadSerializer; + } + + public function send(Event $event): Result + { + $serialized = $this->payloadSerializer->serialize($event); + + echo 'Transport called' . \PHP_EOL; + + return new Result(ResultStatus::success()); + } + + public function close(?int $timeout = null): Result + { + return new Result(ResultStatus::success()); + } +}; + +$options->setTransport($transport); + +$client = (new ClientBuilder($options))->getClient(); + +SentrySdk::init()->bindClient($client); + +echo 'Before OOM memory limit: ' . \ini_get('memory_limit'); + +register_shutdown_function(function () { + echo 'After OOM memory limit: ' . \ini_get('memory_limit'); +}); + +$array = []; +for ($i = 0; $i < 100000000; ++$i) { + $array[] = 'sentry'; +} +--EXPECTF-- +Before OOM memory limit: 67108864 +Fatal error: Allowed memory size of %d bytes exhausted (tried to allocate %d bytes) in %s on line %d +Stack trace: +%A +Transport called +After OOM memory limit: 72351744 diff --git a/tests/phpt/error_handler_captures_fatal_error.phpt b/tests/phpt/php84/error_handler_captures_fatal_error.phpt similarity index 84% rename from tests/phpt/error_handler_captures_fatal_error.phpt rename to tests/phpt/php84/error_handler_captures_fatal_error.phpt index ac4acae7f..a00070e9b 100644 --- a/tests/phpt/error_handler_captures_fatal_error.phpt +++ b/tests/phpt/php84/error_handler_captures_fatal_error.phpt @@ -1,5 +1,10 @@ --TEST-- Test catching fatal errors +--SKIPIF-- + 80400) { + die('skip - only works for PHP 8.4 and below'); +} --FILE-- ---EXPECTREGEX-- -Fatal error: Class Sentry\\Tests\\TestClass contains 1 abstract method and must therefore be declared abstract or implement the remaining methods? \(JsonSerializable::jsonSerialize\) in .* on line 63(?:\RStack trace:\R(?:#\d+.*\R?)+)? +--EXPECTF-- +Fatal error: Class Sentry\Tests\TestClass contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (JsonSerializable::jsonSerialize) in %s on line %d Transport called Fatal error listener called diff --git a/tests/phpt/error_handler_captures_out_of_memory_fatal_error.phpt b/tests/phpt/php84/error_handler_captures_out_of_memory_fatal_error.phpt similarity index 80% rename from tests/phpt/error_handler_captures_out_of_memory_fatal_error.phpt rename to tests/phpt/php84/error_handler_captures_out_of_memory_fatal_error.phpt index fc96d0b63..f933ecbf1 100644 --- a/tests/phpt/error_handler_captures_out_of_memory_fatal_error.phpt +++ b/tests/phpt/php84/error_handler_captures_out_of_memory_fatal_error.phpt @@ -1,5 +1,10 @@ --TEST-- Test catching out of memory fatal error without increasing memory limit +--SKIPIF-- + 80400) { + die('skip - only works for PHP 8.4 and below'); +} --INI-- memory_limit=67108864 --FILE-- @@ -32,8 +37,8 @@ echo 'Before OOM memory limit: ' . ini_get('memory_limit'); $foo = str_repeat('x', 1024 * 1024 * 1024); ?> ---EXPECTREGEX-- +--EXPECTF-- Before OOM memory limit: 67108864 -Fatal error: Allowed memory size of 67108864 bytes exhausted \(tried to allocate 1073741856 bytes\) in .* on line 28(?:\RStack trace:\R(?:#\d+.*\R?)+)? +Fatal error: Allowed memory size of %d bytes exhausted (tried to allocate %d bytes) in %s on line %d Fatal error listener called After OOM memory limit: 67108864 diff --git a/tests/phpt/fatal_error_integration_captures_fatal_error.phpt b/tests/phpt/php84/fatal_error_integration_captures_fatal_error.phpt similarity index 80% rename from tests/phpt/fatal_error_integration_captures_fatal_error.phpt rename to tests/phpt/php84/fatal_error_integration_captures_fatal_error.phpt index 2582c4cd9..142698b96 100644 --- a/tests/phpt/fatal_error_integration_captures_fatal_error.phpt +++ b/tests/phpt/php84/fatal_error_integration_captures_fatal_error.phpt @@ -1,5 +1,10 @@ --TEST-- Test that the FatalErrorListenerIntegration integration captures only the errors allowed by the error_types option +--SKIPIF-- + 80400) { + die('skip - only works for PHP 8.4 and below'); +} --FILE-- ---EXPECTREGEX-- -^Fatal error: Class Sentry\\Tests\\TestClass contains 1 abstract methods? and must therefore be declared abstract or implement the remaining methods? \(JsonSerializable::jsonSerialize\) in .* on line 53(?:\RStack trace:\R(?:#\d+.*\R?)+)? -Transport called\R?$ +--EXPECTF-- +Fatal error: Class Sentry\Tests\TestClass contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (JsonSerializable::jsonSerialize) in %s on line %d +Transport called diff --git a/tests/phpt/fatal_error_integration_respects_error_types_option.phpt b/tests/phpt/php84/fatal_error_integration_respects_error_types_option.phpt similarity index 81% rename from tests/phpt/fatal_error_integration_respects_error_types_option.phpt rename to tests/phpt/php84/fatal_error_integration_respects_error_types_option.phpt index bb8cb6944..b210ed1e6 100644 --- a/tests/phpt/fatal_error_integration_respects_error_types_option.phpt +++ b/tests/phpt/php84/fatal_error_integration_respects_error_types_option.phpt @@ -1,5 +1,10 @@ --TEST-- Test that the FatalErrorListenerIntegration integration captures only the errors allowed by the error_types option +--SKIPIF-- + 80400) { + die('skip - only works for PHP 8.4 and below'); +} --FILE-- ---EXPECTREGEX-- -Fatal error: Class Sentry\\Tests\\TestClass contains 1 abstract method and must therefore be declared abstract or implement the remaining methods? \(JsonSerializable::jsonSerialize\) in .* on line 54 +--EXPECTF-- +Fatal error: Class Sentry\Tests\TestClass contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (JsonSerializable::jsonSerialize) in %s on line %d diff --git a/tests/phpt/php85/error_handler_captures_fatal_error.phpt b/tests/phpt/php85/error_handler_captures_fatal_error.phpt new file mode 100644 index 000000000..4a4fe0e98 --- /dev/null +++ b/tests/phpt/php85/error_handler_captures_fatal_error.phpt @@ -0,0 +1,80 @@ +--TEST-- +Test catching fatal errors +--SKIPIF-- + 'http://public@example.com/sentry/1', +]; + +$client = ClientBuilder::create($options) + ->setTransport($transport) + ->getClient(); + +SentrySdk::getCurrentHub()->bindClient($client); + +$errorHandler = ErrorHandler::registerOnceErrorHandler(); +$errorHandler->addErrorHandlerListener(static function (): void { + echo 'Error listener called (it should not have been)' . PHP_EOL; +}); + +$errorHandler = ErrorHandler::registerOnceFatalErrorHandler(); +$errorHandler->addFatalErrorHandlerListener(static function (): void { + echo 'Fatal error listener called' . PHP_EOL; +}); + +$errorHandler = ErrorHandler::registerOnceExceptionHandler(); +$errorHandler->addExceptionHandlerListener(static function (): void { + echo 'Exception listener called (it should not have been)' . PHP_EOL; +}); + +final class TestClass implements \JsonSerializable +{ +} +?> +--EXPECTF-- +Fatal error: Class Sentry\Tests\TestClass contains 1 abstract method and must therefore be declared abstract or implement the remaining method (JsonSerializable::jsonSerialize) in %s on line %d +Stack trace: +%A +Transport called +Fatal error listener called diff --git a/tests/phpt/php85/error_handler_captures_out_of_memory_fatal_error.phpt b/tests/phpt/php85/error_handler_captures_out_of_memory_fatal_error.phpt new file mode 100644 index 000000000..cd3986d9c --- /dev/null +++ b/tests/phpt/php85/error_handler_captures_out_of_memory_fatal_error.phpt @@ -0,0 +1,46 @@ +--TEST-- +Test catching out of memory fatal error without increasing memory limit +--SKIPIF-- +addFatalErrorHandlerListener(static function (): void { + echo 'Fatal error listener called' . PHP_EOL; + + echo 'After OOM memory limit: ' . ini_get('memory_limit'); +}); + +$errorHandler->setMemoryLimitIncreaseOnOutOfMemoryErrorInBytes(null); + +echo 'Before OOM memory limit: ' . ini_get('memory_limit'); + +$foo = str_repeat('x', 1024 * 1024 * 1024); +?> +--EXPECTF-- +Before OOM memory limit: 67108864 +Fatal error: Allowed memory size of %d bytes exhausted (tried to allocate %d bytes) in %s on line %d +Stack trace: +%A +Fatal error listener called +After OOM memory limit: 67108864 diff --git a/tests/phpt/php85/fatal_error_integration_captures_fatal_error.phpt b/tests/phpt/php85/fatal_error_integration_captures_fatal_error.phpt new file mode 100644 index 000000000..88fdd8f5c --- /dev/null +++ b/tests/phpt/php85/fatal_error_integration_captures_fatal_error.phpt @@ -0,0 +1,69 @@ +--TEST-- +Test that the FatalErrorListenerIntegration integration captures only the errors allowed by the error_types option +--SKIPIF-- + false, + 'integrations' => [ + new FatalErrorListenerIntegration(), + ], +]); + +$client = (new ClientBuilder($options)) + ->setTransport($transport) + ->getClient(); + +SentrySdk::getCurrentHub()->bindClient($client); + +final class TestClass implements \JsonSerializable +{ +} +?> +--EXPECTF-- +Fatal error: Class Sentry\Tests\TestClass contains 1 abstract method and must therefore be declared abstract or implement the remaining method (JsonSerializable::jsonSerialize) in %s on line %d +Stack trace: +%A +Transport called diff --git a/tests/phpt/php85/fatal_error_integration_respects_error_types_option.phpt b/tests/phpt/php85/fatal_error_integration_respects_error_types_option.phpt new file mode 100644 index 000000000..7d74233ce --- /dev/null +++ b/tests/phpt/php85/fatal_error_integration_respects_error_types_option.phpt @@ -0,0 +1,69 @@ +--TEST-- +Test that the FatalErrorListenerIntegration integration captures only the errors allowed by the error_types option +--SKIPIF-- + E_ALL & ~E_ERROR, + 'default_integrations' => false, + 'integrations' => [ + new FatalErrorListenerIntegration(), + ], +]); + +$client = (new ClientBuilder($options)) + ->setTransport($transport) + ->getClient(); + +SentrySdk::getCurrentHub()->bindClient($client); + +final class TestClass implements \JsonSerializable +{ +} +?> +--EXPECTF-- +Fatal error: Class Sentry\Tests\TestClass contains 1 abstract method and must therefore be declared abstract or implement the remaining method (JsonSerializable::jsonSerialize) in %s on line %d +Stack trace: +%A From 01026a274df1f7f12a3c9ff464e7ea5acc319d35 Mon Sep 17 00:00:00 2001 From: Martin Linzmayer Date: Thu, 6 Nov 2025 14:29:21 +0100 Subject: [PATCH 7/9] update phpunit runner in CI --- .github/workflows/ci.yml | 2 +- composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2d3e248bf..e4921fc52 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,7 +35,7 @@ jobs: - { version: '8.2', phpunit: '^9.6.21' } - { version: '8.3', phpunit: '^9.6.21' } - { version: '8.4', phpunit: '^9.6.21' } - - { version: '8.5', phpunit: '^9.6.21' } + - { version: '8.5', phpunit: '^9.6.25' } dependencies: - lowest - highest diff --git a/composer.json b/composer.json index b393385f7..bdeda9645 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,7 @@ "monolog/monolog": "^1.6|^2.0|^3.0", "phpbench/phpbench": "^1.0", "phpstan/phpstan": "^1.3", - "phpunit/phpunit": "^8.5|^9.6.25", + "phpunit/phpunit": "^8.5|^9.6", "symfony/phpunit-bridge": "^5.2|6.4.25|7.3.3", "vimeo/psalm": "^4.17" }, From bf04ba1f048cb95301f5458dff1ae39ab9bcf04c Mon Sep 17 00:00:00 2001 From: Martin Linzmayer Date: Thu, 6 Nov 2025 14:45:06 +0100 Subject: [PATCH 8/9] fix version guard --- .../php84/out_of_memory_fatal_error_increases_memory_limit.phpt | 2 +- tests/phpt/php84/error_handler_captures_fatal_error.phpt | 2 +- .../php84/error_handler_captures_out_of_memory_fatal_error.phpt | 2 +- .../php84/fatal_error_integration_captures_fatal_error.phpt | 2 +- .../fatal_error_integration_respects_error_types_option.phpt | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/phpt-oom/php84/out_of_memory_fatal_error_increases_memory_limit.phpt b/tests/phpt-oom/php84/out_of_memory_fatal_error_increases_memory_limit.phpt index 19b7a6d08..321ed418a 100644 --- a/tests/phpt-oom/php84/out_of_memory_fatal_error_increases_memory_limit.phpt +++ b/tests/phpt-oom/php84/out_of_memory_fatal_error_increases_memory_limit.phpt @@ -2,7 +2,7 @@ Test that when handling a out of memory error the memory limit is increased with 5 MiB and the event is serialized and ready to be sent --SKIPIF-- 80400) { +if (PHP_VERSION_ID >= 80400) { die('skip - only works for PHP 8.4 and below'); } --INI-- diff --git a/tests/phpt/php84/error_handler_captures_fatal_error.phpt b/tests/phpt/php84/error_handler_captures_fatal_error.phpt index a00070e9b..2c4b9143b 100644 --- a/tests/phpt/php84/error_handler_captures_fatal_error.phpt +++ b/tests/phpt/php84/error_handler_captures_fatal_error.phpt @@ -2,7 +2,7 @@ Test catching fatal errors --SKIPIF-- 80400) { +if (PHP_VERSION_ID >= 80500) { die('skip - only works for PHP 8.4 and below'); } --FILE-- diff --git a/tests/phpt/php84/error_handler_captures_out_of_memory_fatal_error.phpt b/tests/phpt/php84/error_handler_captures_out_of_memory_fatal_error.phpt index f933ecbf1..f25d224d7 100644 --- a/tests/phpt/php84/error_handler_captures_out_of_memory_fatal_error.phpt +++ b/tests/phpt/php84/error_handler_captures_out_of_memory_fatal_error.phpt @@ -2,7 +2,7 @@ Test catching out of memory fatal error without increasing memory limit --SKIPIF-- 80400) { +if (PHP_VERSION_ID >= 80500) { die('skip - only works for PHP 8.4 and below'); } --INI-- diff --git a/tests/phpt/php84/fatal_error_integration_captures_fatal_error.phpt b/tests/phpt/php84/fatal_error_integration_captures_fatal_error.phpt index 142698b96..2c8e40c4d 100644 --- a/tests/phpt/php84/fatal_error_integration_captures_fatal_error.phpt +++ b/tests/phpt/php84/fatal_error_integration_captures_fatal_error.phpt @@ -2,7 +2,7 @@ Test that the FatalErrorListenerIntegration integration captures only the errors allowed by the error_types option --SKIPIF-- 80400) { +if (PHP_VERSION_ID >= 80500) { die('skip - only works for PHP 8.4 and below'); } --FILE-- diff --git a/tests/phpt/php84/fatal_error_integration_respects_error_types_option.phpt b/tests/phpt/php84/fatal_error_integration_respects_error_types_option.phpt index b210ed1e6..6dc65c434 100644 --- a/tests/phpt/php84/fatal_error_integration_respects_error_types_option.phpt +++ b/tests/phpt/php84/fatal_error_integration_respects_error_types_option.phpt @@ -2,7 +2,7 @@ Test that the FatalErrorListenerIntegration integration captures only the errors allowed by the error_types option --SKIPIF-- 80400) { +if (PHP_VERSION_ID >= 80500) { die('skip - only works for PHP 8.4 and below'); } --FILE-- From ab72a04ce64611ce01677badbe1f0eeba39d8c65 Mon Sep 17 00:00:00 2001 From: Martin Linzmayer Date: Thu, 6 Nov 2025 15:08:48 +0100 Subject: [PATCH 9/9] remove accidentally added phpunit bridge --- composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/composer.json b/composer.json index bdeda9645..607891141 100644 --- a/composer.json +++ b/composer.json @@ -39,7 +39,6 @@ "phpbench/phpbench": "^1.0", "phpstan/phpstan": "^1.3", "phpunit/phpunit": "^8.5|^9.6", - "symfony/phpunit-bridge": "^5.2|6.4.25|7.3.3", "vimeo/psalm": "^4.17" }, "suggest": {