From 50660411bee1aea5cfa64db8effabacdb96789d3 Mon Sep 17 00:00:00 2001 From: Martin Linzmayer Date: Tue, 17 Nov 2026 18:02:21 +0100 Subject: [PATCH 01/12] Prepare 4.37.1 (#2390) --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e98a8e84c..49f74dfd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # CHANGELOG +## 4.37.1 + +The Sentry SDK team is happy to announce the immediate availability of Sentry PHP SDK v4.37.1. + +### Bug Fixes + +- Write the HTTP status code into the `http.response.status_code` data of a span in `Span::setHttpStatus()`, so that the `trace_ignore_status_codes` option also applies to transactions whose status is set this way. [(#2384)](https://github.com/getsentry/sentry-php/pull/2384) +- Fix a `TypeError` when the response of the HTTP client contains a header with a numeric name. [(#2366)](https://github.com/getsentry/sentry-php/pull/2366) + ## 4.37.0 The Sentry SDK team is happy to announce the immediate availability of Sentry PHP SDK v4.37.0. From e91d17a16a2f007c01a68b0a6140a46bb3c1f90d Mon Sep 17 00:00:00 2001 From: stayallive <1090754+stayallive@users.noreply.github.com> Date: Tue, 17 Nov 2026 17:03:08 +0000 Subject: [PATCH 02/12] release: 4.37.1 --- src/Client.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Client.php b/src/Client.php index 9a59f2c87..f1ee38bf8 100644 --- a/src/Client.php +++ b/src/Client.php @@ -35,7 +35,7 @@ class Client implements ClientInterface /** * The version of the SDK. */ - public const SDK_VERSION = '4.37.0'; + public const SDK_VERSION = '4.37.1'; /** * Regex pattern to detect if a string is a regex pattern (starts and ends with / optionally followed by flags). From d60d4c5b6ec35c64e8015c0c63893eb4b75d828d Mon Sep 17 00:00:00 2001 From: "sentry-junior[bot]" <264270552+sentry-junior[bot]@users.noreply.github.com> Date: Wed, 18 Nov 2026 10:59:03 +0100 Subject: [PATCH 03/12] ref(spotlight): Pass int curl timeouts in SpotlightClient to drop PHPStan baseline entry (#2392) Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> --- phpstan-baseline.neon | 6 ------ src/Spotlight/SpotlightClient.php | 4 ++-- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index effeb2d11..0736344e8 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -480,12 +480,6 @@ parameters: count: 1 path: src/Serializer/AbstractSerializer.php - - - message: '#^Parameter \#3 \$value of function curl_setopt expects int, float given\.$#' - identifier: argument.type - count: 2 - path: src/Spotlight/SpotlightClient.php - - message: '#^Parameter \#3 \$value of function curl_setopt expects non\-empty\-string, string given\.$#' identifier: argument.type diff --git a/src/Spotlight/SpotlightClient.php b/src/Spotlight/SpotlightClient.php index 0b56517b3..f8c7e9b9c 100644 --- a/src/Spotlight/SpotlightClient.php +++ b/src/Spotlight/SpotlightClient.php @@ -29,8 +29,8 @@ public static function sendRequest(Request $request, string $url): Response curl_setopt($curlHandle, \CURLOPT_HTTPHEADER, [ 'Content-Type: application/x-sentry-envelope', ]); - curl_setopt($curlHandle, \CURLOPT_TIMEOUT, 2.0); - curl_setopt($curlHandle, \CURLOPT_CONNECTTIMEOUT, 1.0); + curl_setopt($curlHandle, \CURLOPT_TIMEOUT, 2); + curl_setopt($curlHandle, \CURLOPT_CONNECTTIMEOUT, 1); curl_setopt($curlHandle, \CURLOPT_ENCODING, ''); curl_setopt($curlHandle, \CURLOPT_POST, true); curl_setopt($curlHandle, \CURLOPT_POSTFIELDS, $requestData); From 3e3f04246b2800ea8bdf798658a681e28f3fa65e Mon Sep 17 00:00:00 2001 From: "sentry-junior[bot]" <264270552+sentry-junior[bot]@users.noreply.github.com> Date: Wed, 18 Nov 2026 12:02:02 +0100 Subject: [PATCH 04/12] chore: Backport the 5.0.0-beta1 changelog entry to master (#2395) Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: Martin Linzmayer --- CHANGELOG.md | 133 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 49f74dfd6..6c930ff8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,138 @@ # CHANGELOG +## 5.0.0-beta1 + +The Sentry SDK team is happy to announce the first beta release of Sentry PHP SDK v5.0.0. + +This is a pre-release of the next major version. The API can still change before the stable release, so we do not recommend it for production yet. To try it out, install the beta explicitly: + +```bash +composer require "sentry/sentry:^5.0@beta" +``` + +### Breaking Changes + +Please refer to the [UPGRADE-5.0.md](https://github.com/getsentry/sentry-php/blob/5.0.0-beta1/UPGRADE-5.0.md) guide for a complete list of breaking changes and how to migrate. + +
+Upgrading with an AI coding agent? Use this prompt. + +```text +Upgrade this project from version 4 to version 5 of the Sentry PHP SDK (sentry/sentry). + +Before you change anything, check composer.json. If the project requires sentry/sentry-laravel or +sentry/sentry-symfony, stop and tell me: those packages decide which version of sentry/sentry is +installed, so they have to be upgraded instead. + +Otherwise: + +1. Run `composer require "sentry/sentry:^5.0@beta"`. +2. Read vendor/sentry/sentry/UPGRADE-5.0.md completely. It is the source of truth for every breaking + change. Version 5 is newer than what you know about this SDK, so do not rely on your memory of its + API. When the guide does not cover something, read the code in vendor/sentry/sentry/src instead of + guessing. +3. Search the whole project for usages of the SDK, not only the place where \Sentry\init() is called: + everything from the Sentry\ namespace, the \Sentry\...() helper functions, the options passed to + init() (they may live in config files or environment-specific overrides), the Monolog handler + setup, custom integrations, event processors, and classes that implement or extend SDK types. +4. Apply the changes from the guide to every usage you found. +5. Run the static analysis and the tests of the project, if it has them, and fix what the upgrade + broke. + +Some changes do not cause an error, so nothing will point you to them. Check each of these explicitly: + +- Removed options are ignored silently. Compare every option passed to init() with the guide. +- The send_default_pii option is gone, and the defaults of the data_collection option collect more + data than before, whichever value send_default_pii had. What gets collected is a privacy decision + that is mine to make: apply the restrictive configuration from the guide, which is the closest to + the old behavior, and list what I could enable on top of it. This only applies if the project + does not set the data_collection option yet. If it already does, send_default_pii was already + ignored and the existing data_collection configuration keeps applying, so only remove + send_default_pii. +- The client is never null anymore. Remove the null checks, and tell me where one of them was used + to detect that the SDK is not initialized. +- Sentry\Metrics\Metrics and \Sentry\metrics() still exist, but they are a different API now. Code + that calls them still has to be migrated. +- Scope data that is set before startContext() or withContext() is no longer inherited by the + context. If this project runs long-lived workers (FrankenPHP, RoadRunner, Swoole, queue workers), + move the data that should apply to every request or job to the global scope. +- Event processors no longer run for check-ins, logs and metrics. If one of them filters or scrubs + that data, move the logic to before_send_check_in, before_send_log or before_send_metric. + +When you are done, give me a summary of what you changed and a separate list of what I have to +decide or check myself. Include the changes that affect what shows up in Sentry: transactions with +a 404 status are no longer sent, error events can get a different transaction name, and logs carry +a span_id instead of the sentry.trace.parent_span_id attribute. +``` + +
+ +- The Hub API has been removed, including `Hub`, `HubInterface`, `HubAdapter`, `SentrySdk::getCurrentHub()` and `SentrySdk::setCurrentHub()`. Use the global helper functions, `SentrySdk::getClient()` and the new scopes instead. [(#2157)](https://github.com/getsentry/sentry-php/pull/2157) + + ```php + // Before + \Sentry\SentrySdk::getCurrentHub()->configureScope(static function (\Sentry\State\Scope $scope): void { + $scope->setTag('feature', 'checkout'); + }); + + // After + \Sentry\configureScope(static function (\Sentry\State\IsolationScope $scope): void { + $scope->setTag('feature', 'checkout'); + }); + ``` + +- `Sentry\State\Scope` is now abstract and split into a `GlobalScope` and an `IsolationScope`. `withScope()` has been replaced by `withIsolationScope()`, and `Scope::addGlobalEventProcessor()` by `SentrySdk::getGlobalScope()->addEventProcessor()`. Event processors only run for error events and transactions. [(#2157)](https://github.com/getsentry/sentry-php/pull/2157), [(#2245)](https://github.com/getsentry/sentry-php/pull/2245) + +- A runtime context started with `startContext()` or `withContext()` starts with an empty isolation scope and no longer inherits the data set before it was started. Set data that applies to every context on the global scope. [(#2157)](https://github.com/getsentry/sentry-php/pull/2157) + +- The `send_default_pii` option has been removed. The `data_collection` option now always decides which data the SDK collects, and its defaults collect more data than `send_default_pii` did. The `context_lines` option moved to `data_collection.frame_context_lines`. [(#2356)](https://github.com/getsentry/sentry-php/pull/2356) + +- The `trace_ignore_status_codes` option now defaults to `[404]`, so transactions of requests that end in a `404` response are no longer sent. [(#2338)](https://github.com/getsentry/sentry-php/pull/2338) + +- The old Metrics API has been removed. `Sentry\Metrics\TraceMetrics` has been renamed to `Sentry\Metrics\Metrics`, and `\Sentry\traceMetrics()` has been removed in favor of `\Sentry\metrics()`. [(#1877)](https://github.com/getsentry/sentry-php/pull/1877), [(#2357)](https://github.com/getsentry/sentry-php/pull/2357) + +- The `enable_logs` and `enable_metrics` options have been removed. Logs and metrics are always captured when their APIs or integrations are used. [(#2355)](https://github.com/getsentry/sentry-php/pull/2355) + +- All deprecated options and methods have been removed, such as `enable_tracing`, `spotlight_url`, `strict_trace_propagation`, the user `segment`, `getW3CTraceparent()` and `SpanStatus::resourceExchausted()`. [(#1877)](https://github.com/getsentry/sentry-php/pull/1877), [(#2355)](https://github.com/getsentry/sentry-php/pull/2355) + +- The deprecated `Sentry\Monolog\Handler` has been removed, and the remaining Monolog handlers no longer take a `HubInterface` as their first constructor argument. [(#2136)](https://github.com/getsentry/sentry-php/pull/2136), [(#2157)](https://github.com/getsentry/sentry-php/pull/2157) + +- The SDK no longer truncates string values, the `max_value_length` option has been removed. [(#1903)](https://github.com/getsentry/sentry-php/pull/1903) + +- The `max_request_body_size` option no longer accepts `'none'`, use `'never'` instead. [(#1942)](https://github.com/getsentry/sentry-php/pull/1942) + +- The `symfony/options-resolver` and `jean85/pretty-package-versions` dependencies have been removed, along with the packages that were only installed through them. The `ModulesIntegration` requires Composer 2. [(#1900)](https://github.com/getsentry/sentry-php/pull/1900), [(#1914)](https://github.com/getsentry/sentry-php/pull/1914), [(#1922)](https://github.com/getsentry/sentry-php/pull/1922) + +### Features + +- Add a global scope and an isolation scope. Data on the global scope is applied to every event of the process and survives across requests in long-running workers, while the isolation scope holds the data of the current runtime context, for example a single request. [(#2157)](https://github.com/getsentry/sentry-php/pull/2157) + + ```php + // Applied to every event of this worker process + \Sentry\getGlobalScope()->setTag('worker', 'queue-1'); + + // Applied to the events of the current request or job only + \Sentry\getIsolationScope()->setUser(['id' => '123']); + ``` + +- Add `withIsolationScope()`, which forks the current isolation scope for the duration of a callback, and `SentrySdk::pushIsolationScope()` and `SentrySdk::popIsolationScope()` for code that cannot be wrapped in a callback. [(#2157)](https://github.com/getsentry/sentry-php/pull/2157), [(#2315)](https://github.com/getsentry/sentry-php/pull/2315) + +- Add `\Sentry\getClient()` and `SentrySdk::getClient()`, which always return a client. Before the SDK is initialized they return a `NoOpClient`, so the client no longer has to be checked for `null`. [(#1957)](https://github.com/getsentry/sentry-php/pull/1957) + +### Bug Fixes + +- Use the name of the active transaction as the `transaction` of error events, and fall back to the path of `REQUEST_URI` when `PATH_INFO` is not set. [(#2339)](https://github.com/getsentry/sentry-php/pull/2339) +- Set the status of a span to `internal_error` when the callback passed to `\Sentry\trace()` throws. [(#2371)](https://github.com/getsentry/sentry-php/pull/2371) +- Report the duration of a failed run in `\Sentry\withMonitor()` instead of `0`. [(#2372)](https://github.com/getsentry/sentry-php/pull/2372) +- Replace PSR-3 placeholders with the values of the context in the `Sentry\Monolog\LogsHandler`, and send the template and its parameters as attributes. [(#2377)](https://github.com/getsentry/sentry-php/pull/2377) +- Send the active span of a log as its `span_id` instead of the `sentry.trace.parent_span_id` attribute. [(#2375)](https://github.com/getsentry/sentry-php/pull/2375) +- Use a Spotlight URL that has a path as it is, instead of always appending `/stream`. [(#2376)](https://github.com/getsentry/sentry-php/pull/2376) +- Draw the random numbers for sampling decisions from the operating system, so that forked processes no longer continue the same sequence. [(#2369)](https://github.com/getsentry/sentry-php/pull/2369) +- Send the pending client reports on `\Sentry\flush()` and when a runtime context ends, with the client of that context. [(#2368)](https://github.com/getsentry/sentry-php/pull/2368) +- Record a client report for transactions that are dropped by `trace_ignore_status_codes`. [(#2367)](https://github.com/getsentry/sentry-php/pull/2367) +- Fix the argument names of closures in stack frames. [(#2370)](https://github.com/getsentry/sentry-php/pull/2370) +- Omit the `unit` of a metric and of a crontab monitor schedule when it is not set. [(#2373)](https://github.com/getsentry/sentry-php/pull/2373), [(#2374)](https://github.com/getsentry/sentry-php/pull/2374) + ## 4.37.1 The Sentry SDK team is happy to announce the immediate availability of Sentry PHP SDK v4.37.1. From e8f6c66b8efa30fef6f2324f4c6faf967e358ee4 Mon Sep 17 00:00:00 2001 From: "sentry-junior[bot]" <264270552+sentry-junior[bot]@users.noreply.github.com> Date: Wed, 18 Nov 2026 12:02:29 +0100 Subject: [PATCH 05/12] chore(deps): Bump mago to 1.60.2 (#2394) Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: Martin Linzmayer --- analysis-baseline.toml | 610 +++++---------------- composer.json | 2 +- mago.toml | 3 +- src/Attachment/Attachment.php | 8 +- src/DataCollection/HttpCookieCollector.php | 4 - src/Dsn.php | 2 +- 6 files changed, 136 insertions(+), 493 deletions(-) diff --git a/analysis-baseline.toml b/analysis-baseline.toml index 1b9b4c023..2c8f8507a 100644 --- a/analysis-baseline.toml +++ b/analysis-baseline.toml @@ -6,12 +6,24 @@ code = "impossible-condition" message = "This condition (type `false`) will always evaluate to false." count = 1 +[[issues]] +file = "src/Attachment/FileAttachment.php" +code = "avoid-catching-error" +message = "Avoid catching 'Error' class instances." +count = 1 + [[issues]] file = "src/Client.php" code = "implicit-to-string-cast" message = 'Implicit conversion to `string` for left operand via `Sentry\Severity::__toString()`.' count = 1 +[[issues]] +file = "src/Client.php" +code = "mixed-assignment" +message = "Assigning `mixed` type to a variable may lead to unexpected behavior." +count = 2 + [[issues]] file = "src/Client.php" code = "possibly-invalid-argument" @@ -48,10 +60,22 @@ code = "redundant-comparison" message = "Redundant `===` comparison: left-hand side is never identical to right-hand side." count = 1 +[[issues]] +file = "src/DataCollection/DataCollectionOptions.php" +code = "less-specific-nested-argument-type" +message = "Argument type mismatch for argument #1 of `array_diff`: expected `array`, but provided type `array` is less specific." +count = 1 + +[[issues]] +file = "src/DataCollection/DataCollectionOptions.php" +code = "template-constraint-violation" +message = "Argument type mismatch for template `V`." +count = 1 + [[issues]] file = "src/Dsn.php" code = "possibly-false-operand" -message = "Left operand in `==` comparison might be `false` (type `false|int`)." +message = "Left operand in `==` comparison might be `false` (type `false|int(0)|int(1)`)." count = 1 [[issues]] @@ -99,25 +123,25 @@ count = 1 [[issues]] file = "src/Dsn.php" code = "possibly-undefined-string-array-index" -message = "Possibly undefined array key 'host' accessed on `array{'fragment'?: non-empty-string, 'host'?: non-empty-string, 'pass'?: non-empty-string, 'path'?: non-empty-string, 'port'?: int<0, 65535>, 'query'?: non-empty-string, 'scheme'?: non-empty-string, 'user'?: non-empty-string}`." +message = "Possibly undefined array key 'host' accessed on `array{'fragment'?: string, 'host'?: non-empty-string, 'pass'?: string, 'path'?: non-empty-string, 'port'?: int<0, 65535>, 'query'?: string, 'scheme'?: string('http')|string('https'), 'user'?: string}`." count = 2 [[issues]] file = "src/Dsn.php" code = "possibly-undefined-string-array-index" -message = "Possibly undefined array key 'path' accessed on `array{'fragment'?: non-empty-string, 'host'?: non-empty-string, 'pass'?: non-empty-string, 'path'?: non-empty-string, 'port'?: int<0, 65535>, 'query'?: non-empty-string, 'scheme'?: non-empty-string, 'user'?: non-empty-string}`." +message = "Possibly undefined array key 'path' accessed on `array{'fragment'?: string, 'host'?: non-empty-string, 'pass'?: string, 'path'?: non-empty-string, 'port'?: int<0, 65535>, 'query'?: string, 'scheme'?: string('http')|string('https'), 'user'?: string}`." count = 4 [[issues]] file = "src/Dsn.php" code = "possibly-undefined-string-array-index" -message = "Possibly undefined array key 'scheme' accessed on `array{'fragment'?: non-empty-string, 'host'?: non-empty-string, 'pass'?: non-empty-string, 'path'?: non-empty-string, 'port'?: int<0, 65535>, 'query'?: non-empty-string, 'scheme'?: non-empty-string, 'user'?: non-empty-string}`." +message = "Possibly undefined array key 'scheme' accessed on `array{'fragment'?: string, 'host'?: non-empty-string, 'pass'?: string, 'path'?: non-empty-string, 'port'?: int<0, 65535>, 'query'?: string, 'scheme'?: non-empty-string, 'user'?: string}`." count = 1 [[issues]] file = "src/Dsn.php" code = "possibly-undefined-string-array-index" -message = "Possibly undefined array key 'user' accessed on `array{'fragment'?: non-empty-string, 'host'?: non-empty-string, 'pass'?: non-empty-string, 'path'?: non-empty-string, 'port'?: int<0, 65535>, 'query'?: non-empty-string, 'scheme'?: non-empty-string, 'user'?: non-empty-string}`." +message = "Possibly undefined array key 'user' accessed on `array{'fragment'?: string, 'host'?: non-empty-string, 'pass'?: string, 'path'?: non-empty-string, 'port'?: int<0, 65535>, 'query'?: string, 'scheme'?: string('http')|string('https'), 'user'?: string}`." count = 1 [[issues]] @@ -168,6 +192,12 @@ code = "possibly-invalid-argument" message = '''Possible argument type mismatch for argument #1 of `Sentry\ErrorHandler::cleanBacktraceFromErrorHandlerFrames`: expected `list, 'class'?: class-string, 'file'?: string, 'function'?: string, 'line'?: int, 'type'?: string}>`, but possibly received `array`.''' count = 1 +[[issues]] +file = "src/ErrorHandler.php" +code = "possibly-invalid-argument" +message = "Possible argument type mismatch for argument #2 of `str_repeat`: expected `non-negative-int`, but possibly received `int`." +count = 1 + [[issues]] file = "src/ErrorHandler.php" code = "redundant-comparison" @@ -228,6 +258,12 @@ code = "redundant-type-comparison" message = "Redundant type assertion: `$extra` is already `array`." count = 1 +[[issues]] +file = "src/FrameBuilder.php" +code = "impossible-condition" +message = "This condition (type `false`) will always evaluate to false." +count = 1 + [[issues]] file = "src/FrameBuilder.php" code = "invalid-operand" @@ -309,7 +345,7 @@ count = 1 [[issues]] file = "src/HttpClient/Response.php" code = "property-type-coercion" -message = "A value of a less specific type `array{'': array-key, ...}` is being assigned to property `$$headerNames` (array)." +message = "A value of a less specific type `non-empty-array` is being assigned to property `$headerNames` (array)." count = 1 [[issues]] @@ -326,87 +362,51 @@ count = 1 [[issues]] file = "src/Integration/IntegrationRegistry.php" -code = "invalid-property-assignment-value" -message = 'Invalid type for property `$integrations`: expected `array, bool>`, but got `array|string, bool>`.' +code = "impossible-condition" +message = "This condition (type `false`) will always evaluate to false." count = 1 [[issues]] file = "src/Integration/IntegrationRegistry.php" -code = "invalid-return-statement" -message = 'Invalid return type for function `Sentry\Integration\IntegrationRegistry::getIntegrationsToSetup`: expected `array`, but found `list<(callable(array): Sentry\Integration\IntegrationInterface)|Sentry\Integration\IntegrationInterface>`.' +code = "less-specific-return-statement" +message = 'Returned type `array|list` is less specific than the declared return type `array` for function `Sentry\Integration\IntegrationRegistry::getIntegrationsToSetup`.' count = 1 [[issues]] file = "src/Integration/IntegrationRegistry.php" -code = "invalid-return-statement" -message = 'Invalid return type for function `Sentry\Integration\IntegrationRegistry::setupIntegrations`: expected `array, Sentry\Integration\IntegrationInterface>`, but found `array`.' +code = "no-value" +message = "Argument #1 passed to function `get_debug_type` has type `never`, meaning it cannot produce a value." count = 1 [[issues]] file = "src/Integration/IntegrationRegistry.php" code = "possibly-invalid-argument" -message = '''Possible argument type mismatch for argument #1 of `array_map`: expected `(callable((callable(array): Sentry\Integration\IntegrationInterface)|object): string)|(callable((callable(array): Sentry\Integration\IntegrationInterface)|object, ('S.array_map() extends mixed)): string)|null`, but possibly received `string('get_class')`.''' +message = "Possible argument type mismatch for argument #1 of `array_map`: expected `(callable(class-string|non-empty-string|object): class-string<'T.get_class() extends object>)|(callable(class-string|non-empty-string|object, ('S.array_map() extends mixed)): class-string<'T.get_class() extends object>)|null`, but possibly received `string('get_class')`." count = 1 [[issues]] file = "src/Integration/IntegrationRegistry.php" code = "possibly-invalid-argument" -message = 'Possible argument type mismatch for argument #1 of `get_class`: expected `object`, but possibly received `(callable(array): Sentry\Integration\IntegrationInterface)|Sentry\Integration\IntegrationInterface`.' -count = 1 - -[[issues]] -file = "src/Integration/IntegrationRegistry.php" -code = "redundant-condition" -message = "This condition (type `true`) will always evaluate to true." +message = "Possible argument type mismatch for argument #1 of `get_class`: expected `('T.get_class() extends object)`, but possibly received `class-string|non-empty-string|object`." count = 1 [[issues]] file = "src/Integration/IntegrationRegistry.php" code = "redundant-type-comparison" -message = 'Redundant type assertion: `$userIntegrations` is already `array): Sentry\Integration\IntegrationInterface)|Sentry\Integration\IntegrationInterface>`.' +message = 'Redundant type assertion: `$integrations` is already `array`.' count = 1 [[issues]] file = "src/Integration/IntegrationRegistry.php" -code = "unreachable-else-clause" -message = "Unreachable else clause" -count = 1 - -[[issues]] -file = "src/Integration/RequestIntegration.php" -code = "invalid-property-assignment-value" -message = "Invalid type for property `$options`: expected `array{'pii_sanitize_headers': array}`, but got `array`." -count = 1 - -[[issues]] -file = "src/Integration/RequestIntegration.php" -code = "less-specific-argument" -message = 'Argument type mismatch for argument #1 of `Sentry\Integration\RequestIntegration::parseUploadedFiles`: expected `array`, but provided type `array` is less specific.' -count = 2 - -[[issues]] -file = "src/Integration/RequestIntegration.php" -code = "less-specific-return-statement" -message = 'Returned type `array>` is less specific than the declared return type `array>` for function `Sentry\Integration\RequestIntegration::sanitizeHeaders`.' -count = 1 - -[[issues]] -file = "src/Integration/RequestIntegration.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `Sentry\UserDataBag::createFromUserIpAddress`: expected `string`, but found `truthy-mixed`.' -count = 1 - -[[issues]] -file = "src/Integration/RequestIntegration.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `Sentry\UserDataBag::setIpAddress`: expected `null|string`, but found `truthy-mixed`.' +code = "template-constraint-violation" +message = "Argument type mismatch for template `T`." count = 1 [[issues]] file = "src/Integration/RequestIntegration.php" code = "mixed-assignment" message = "Assigning `mixed` type to a variable may lead to unexpected behavior." -count = 2 +count = 1 [[issues]] file = "src/Logger/DebugLogger.php" @@ -438,12 +438,6 @@ code = "redundant-type-comparison" message = "Redundant type assertion: `$key` is already `string`." count = 1 -[[issues]] -file = "src/Metrics/Metrics.php" -code = "deprecated-class" -message = 'Class `Sentry\Metrics\Metrics` is deprecated and should no longer be used.' -count = 1 - [[issues]] file = "src/Metrics/MetricsAggregator.php" code = "ambiguous-instantiation-target" @@ -458,32 +452,32 @@ count = 1 [[issues]] file = "src/Metrics/MetricsAggregator.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `Sentry\Util\TelemetryStorage::push`: expected `Sentry\Metrics\Types\Metric`, but found `nonnull`.' +code = "less-specific-argument" +message = 'Argument type mismatch for argument #5 of `Sentry\Metrics\Types\CounterMetric::__construct`: expected `array`, but provided type `array` is less specific.' count = 1 [[issues]] file = "src/Metrics/MetricsAggregator.php" -code = "mixed-assignment" -message = "Assigning `mixed` type to a variable may lead to unexpected behavior." +code = "less-specific-argument" +message = 'Argument type mismatch for argument #5 of `Sentry\Metrics\Types\DistributionMetric::__construct`: expected `array`, but provided type `array` is less specific.' count = 1 [[issues]] file = "src/Metrics/MetricsAggregator.php" -code = "possibly-invalid-argument" -message = 'Possible argument type mismatch for argument #5 of `Sentry\Metrics\Types\CounterMetric::__construct`: expected `array`, but possibly received `array`.' +code = "less-specific-argument" +message = 'Argument type mismatch for argument #5 of `Sentry\Metrics\Types\GaugeMetric::__construct`: expected `array`, but provided type `array` is less specific.' count = 1 [[issues]] file = "src/Metrics/MetricsAggregator.php" -code = "possibly-invalid-argument" -message = 'Possible argument type mismatch for argument #5 of `Sentry\Metrics\Types\DistributionMetric::__construct`: expected `array`, but possibly received `array`.' +code = "mixed-argument" +message = 'Invalid argument type for argument #1 of `Sentry\Util\TelemetryStorage::push`: expected `Sentry\Metrics\Types\Metric`, but found `nonnull`.' count = 1 [[issues]] file = "src/Metrics/MetricsAggregator.php" -code = "possibly-invalid-argument" -message = 'Possible argument type mismatch for argument #5 of `Sentry\Metrics\Types\GaugeMetric::__construct`: expected `array`, but possibly received `array`.' +code = "mixed-assignment" +message = "Assigning `mixed` type to a variable may lead to unexpected behavior." count = 1 [[issues]] @@ -498,6 +492,36 @@ code = "redundant-type-comparison" message = "Redundant type assertion: `$value` is already `float`." count = 1 +[[issues]] +file = "src/Monolog/BreadcrumbHandler.php" +code = "deprecated-class-constant" +message = 'Use of deprecated class constant `Monolog\Logger::DEBUG`.' +count = 2 + +[[issues]] +file = "src/Monolog/BreadcrumbHandler.php" +code = "deprecated-class-constant" +message = 'Use of deprecated class constant `Monolog\Logger::ERROR`.' +count = 2 + +[[issues]] +file = "src/Monolog/BreadcrumbHandler.php" +code = "deprecated-class-constant" +message = 'Use of deprecated class constant `Monolog\Logger::INFO`.' +count = 1 + +[[issues]] +file = "src/Monolog/BreadcrumbHandler.php" +code = "deprecated-class-constant" +message = 'Use of deprecated class constant `Monolog\Logger::NOTICE`.' +count = 1 + +[[issues]] +file = "src/Monolog/BreadcrumbHandler.php" +code = "deprecated-class-constant" +message = 'Use of deprecated class constant `Monolog\Logger::WARNING`.' +count = 1 + [[issues]] file = "src/Monolog/BreadcrumbHandler.php" code = "impossible-nonnull-entry-check" @@ -552,12 +576,6 @@ code = "possibly-invalid-operand" message = "Possibly invalid type for right operand." count = 1 -[[issues]] -file = "src/Monolog/CompatibilityLogLevelTrait.php" -code = "duplicate-definition" -message = 'Trait `Sentry\Monolog\CompatibilityLogLevelTrait` is already defined elsewhere.' -count = 1 - [[issues]] file = "src/Monolog/CompatibilityLogLevelTrait.php" code = "redundant-comparison" @@ -571,9 +589,9 @@ message = "This condition (type `true`) will always evaluate to true." count = 1 [[issues]] -file = "src/Monolog/CompatibilityProcessingHandlerTrait.php" -code = "duplicate-definition" -message = 'Trait `Sentry\Monolog\CompatibilityProcessingHandlerTrait` is already defined elsewhere.' +file = "src/Monolog/CompatibilityLogLevelTrait.php" +code = "unreachable-else-clause" +message = "Unreachable else clause" count = 1 [[issues]] @@ -588,6 +606,18 @@ code = "redundant-condition" message = "This condition (type `true`) will always evaluate to true." count = 1 +[[issues]] +file = "src/Monolog/CompatibilityProcessingHandlerTrait.php" +code = "unreachable-else-clause" +message = "Unreachable else clause" +count = 1 + +[[issues]] +file = "src/Monolog/ExceptionToSentryIssueHandler.php" +code = "deprecated-class-constant" +message = 'Use of deprecated class constant `Monolog\Logger::DEBUG`.' +count = 1 + [[issues]] file = "src/Monolog/ExceptionToSentryIssueHandler.php" code = "less-specific-return-statement" @@ -654,6 +684,12 @@ code = "mixed-assignment" message = "Assigning `mixed` type to a variable may lead to unexpected behavior." count = 2 +[[issues]] +file = "src/Monolog/LogToSentryIssueHandler.php" +code = "deprecated-class-constant" +message = 'Use of deprecated class constant `Monolog\Logger::DEBUG`.' +count = 1 + [[issues]] file = "src/Monolog/LogToSentryIssueHandler.php" code = "less-specific-return-statement" @@ -688,7 +724,7 @@ count = 1 file = "src/Monolog/LogToSentryIssueHandler.php" code = "possibly-invalid-argument" message = 'Possible argument type mismatch for argument #1 of `Monolog\Handler\AbstractHandler::isHandling`: expected `Monolog\LogRecord`, but possibly received `Monolog\LogRecord|array`.' -count = 2 +count = 1 [[issues]] file = "src/Monolog/LogToSentryIssueHandler.php" @@ -736,7 +772,7 @@ count = 2 file = "src/Options.php" code = "deprecated-method" message = 'Call to deprecated method: `Sentry\Options::getEnableTracing`.' -count = 3 +count = 2 [[issues]] file = "src/Options.php" @@ -1039,279 +1075,21 @@ message = 'Could not infer a precise return type for function `Sentry\Options::s count = 1 [[issues]] -file = "src/Options.php" -code = "property-type-coercion" -message = "A value of a less specific type `array` is being assigned to property `$$options` (array)." -count = 55 - -[[issues]] -file = "src/Profiling/ContinuousProfiler.php" -code = "impossible-assignment" -message = "Invalid assignment: the right-hand side has type `never` and cannot produce a value." -count = 1 - -[[issues]] -file = "src/Profiling/ContinuousProfiler.php" -code = "invalid-method-access" -message = "Attempting to access a method on a non-object type (`unknown-ref(ExcimerLogEntry)`)." -count = 1 - -[[issues]] -file = "src/Profiling/ContinuousProfiler.php" -code = "invalid-method-access" -message = "Attempting to access a method on a non-object type (`unknown-ref(ExcimerProfiler)`)." -count = 8 - -[[issues]] -file = "src/Profiling/ContinuousProfiler.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `Sentry\Profiling\ContinuousProfiler::completeChunks`: expected `iterable`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Profiling/ContinuousProfiler.php" +file = "src/OptionsResolver.php" code = "mixed-assignment" message = "Assigning `mixed` type to a variable may lead to unexpected behavior." count = 2 [[issues]] file = "src/Profiling/ContinuousProfiler.php" -code = "mixed-operand" -message = "Left operand in `>=` comparison has `mixed` type." -count = 1 - -[[issues]] -file = "src/Profiling/ContinuousProfiler.php" -code = "mixed-operand" -message = "Left operand in binary operation has type `mixed`." -count = 1 - -[[issues]] -file = "src/Profiling/ContinuousProfiler.php" -code = "mixed-operand" -message = "Right operand in `<` comparison has `mixed` type." -count = 1 - -[[issues]] -file = "src/Profiling/ContinuousProfiler.php" -code = "mixed-operand" -message = "Right operand in binary operation has type `mixed`." -count = 1 - -[[issues]] -file = "src/Profiling/ContinuousProfiler.php" -code = "non-existent-class" -message = "Class `ExcimerProfiler` not found." -count = 1 - -[[issues]] -file = "src/Profiling/ContinuousProfiler.php" -code = "non-existent-class-like" -message = "Cannot find class, interface, enum, or type alias `ExcimerLogEntry`." -count = 4 - -[[issues]] -file = "src/Profiling/ContinuousProfiler.php" -code = "non-existent-class-like" -message = "Cannot find class, interface, enum, or type alias `ExcimerProfiler`." -count = 1 - -[[issues]] -file = "src/Profiling/ContinuousProfiler.php" -code = "non-existent-class-like" -message = "Class, Interface, or Trait `ExcimerLogEntry` does not exist." -count = 2 - -[[issues]] -file = "src/Profiling/ContinuousProfiler.php" -code = "non-existent-constant" -message = "Undefined constant: `EXCIMER_REAL`." -count = 1 - -[[issues]] -file = "src/Profiling/ContinuousProfiler.php" -code = "possibly-invalid-array-access" -message = "Cannot perform array access on value of type `unknown-ref(ExcimerLogEntry)`." -count = 1 - -[[issues]] -file = "src/Profiling/ExcimerLogConverter.php" -code = "invalid-iterator" -message = "The expression provided to `foreach` is not iterable. It resolved to type `mixed`, which is not iterable." -count = 1 - -[[issues]] -file = "src/Profiling/ExcimerLogConverter.php" code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `Sentry\Profiling\ProfileFrame::__construct`: expected `string`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Profiling/ExcimerLogConverter.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #2 of `Sentry\Profiling\ProfileSample::__construct`: expected `float`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Profiling/ExcimerLogConverter.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #2 of `Sentry\Util\PrefixStripper::stripPrefixFromFilePath`: expected `string`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Profiling/ExcimerLogConverter.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #3 of `Sentry\Profiling\ProfileFrame::__construct`: expected `string`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Profiling/ExcimerLogConverter.php" -code = "mixed-argument" -message = "Invalid argument type for argument #3 of `preg_replace_callback`: expected `array|string`, but found `mixed`." -count = 1 - -[[issues]] -file = "src/Profiling/ExcimerLogConverter.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #4 of `Sentry\Profiling\ProfileFrame::__construct`: expected `null|string`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Profiling/ExcimerLogConverter.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #5 of `Sentry\Profiling\ProfileFrame::__construct`: expected `int|null`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Profiling/ExcimerLogConverter.php" -code = "mixed-array-access" -message = "Unsafe array access on type `mixed`." -count = 4 - -[[issues]] -file = "src/Profiling/ExcimerLogConverter.php" -code = "mixed-assignment" -message = "Assigning `mixed` type to a variable may lead to unexpected behavior." -count = 10 - -[[issues]] -file = "src/Profiling/ExcimerLogConverter.php" -code = "mixed-assignment" -message = "Assigning `nonnull` type to a variable may lead to unexpected behavior." -count = 3 - -[[issues]] -file = "src/Profiling/ExcimerLogConverter.php" -code = "mixed-operand" -message = "Invalid left operand: type `nonnull` cannot be reliably used in string concatenation." -count = 1 - -[[issues]] -file = "src/Profiling/ExcimerLogConverter.php" -code = "mixed-operand" -message = "Invalid right operand: type `nonnull` cannot be reliably used in string concatenation." -count = 1 - -[[issues]] -file = "src/Profiling/ExcimerLogConverter.php" -code = "mixed-operand" -message = "Left operand in `>` comparison has `mixed` type." -count = 2 - -[[issues]] -file = "src/Profiling/ExcimerLogConverter.php" -code = "mixed-operand" -message = "Left operand in binary operation has type `mixed`." -count = 3 - -[[issues]] -file = "src/Profiling/ExcimerLogConverter.php" -code = "mixed-operand" -message = "Right operand in binary operation has type `mixed`." -count = 3 - -[[issues]] -file = "src/Profiling/ExcimerLogConverter.php" -code = "non-existent-class-like" -message = "Cannot find class, interface, enum, or type alias `ExcimerLogEntry`." -count = 1 - -[[issues]] -file = "src/Profiling/ExcimerLogConverter.php" -code = "non-existent-class-like" -message = "Class, Interface, or Trait `ExcimerLogEntry` does not exist." -count = 1 - -[[issues]] -file = "src/Profiling/ExcimerLogConverter.php" -code = "possibly-invalid-array-access" -message = "Cannot perform array access on value of type `unknown-ref(ExcimerLogEntry)`." -count = 2 - -[[issues]] -file = "src/Profiling/Profile.php" -code = "invalid-method-access" -message = "Attempting to access a method on a non-object type (`unknown-ref(ExcimerLog)`)." +message = 'Invalid argument type for argument #1 of `Sentry\Profiling\ContinuousProfiler::completeChunks`: expected `iterable`, but found `mixed`.' count = 1 [[issues]] file = "src/Profiling/Profile.php" code = "invalid-return-statement" -message = '''Invalid return type for function `Sentry\Profiling\Profile::getFormattedData`: expected `array{'device': array{'architecture': string}, 'environment': string, 'event_id': string, 'os': array{'build_number': string, 'name': string, 'version': string}, 'platform': string('php'), 'profile': array{'frames': array, 'samples': array, 'stacks': array>}, 'release': string, 'runtime': array{'name': string, 'version': string}, 'timestamp': string, 'transaction': array{'active_thread_id': string, 'id': string, 'name': string, 'trace_id': string}, 'version': string}|null`, but found `array{'device': array{'architecture': null|string}, 'environment': string, 'event_id': string, 'os': array{'build_number': string, 'name': string, 'version': null|string}, 'platform': string('php'), 'profile': array{'frames': array{}|non-empty-list, 'samples': array{}|non-empty-list, 'stacks': array>}, 'release': string, 'runtime': array{'name': string, 'sapi': null|string, 'version': null|string}, 'timestamp': non-empty-string, 'transaction': array{'active_thread_id': string, 'id': string, 'name': null|string, 'trace_id': null|string}, 'version': string}`.''' -count = 1 - -[[issues]] -file = "src/Profiling/Profile.php" -code = "mixed-assignment" -message = "Assigning `mixed` type to a variable may lead to unexpected behavior." -count = 1 - -[[issues]] -file = "src/Profiling/Profile.php" -code = "mixed-operand" -message = "Left operand in `>=` comparison has `mixed` type." -count = 1 - -[[issues]] -file = "src/Profiling/Profile.php" -code = "non-existent-class-like" -message = "Cannot find class, interface, enum, or type alias `ExcimerLog`." -count = 2 - -[[issues]] -file = "src/Profiling/Profile.php" -code = "possibly-invalid-argument" -message = '''Possible argument type mismatch for argument #1 of `Sentry\Profiling\ExcimerLogConverter::convert`: expected `iterable}|unknown-ref(ExcimerLogEntry)>`, but possibly received `array}>|unknown-ref(ExcimerLog)`.''' -count = 1 - -[[issues]] -file = "src/Profiling/Profiler.php" -code = "invalid-method-access" -message = "Attempting to access a method on a non-object type (`unknown-ref(ExcimerProfiler)`)." -count = 3 - -[[issues]] -file = "src/Profiling/Profiler.php" -code = "mixed-argument" -message = '''Invalid argument type for argument #1 of `Sentry\Profiling\Profile::setExcimerLog`: expected `array}>|unknown-ref(ExcimerLog)`, but found `mixed`.''' -count = 1 - -[[issues]] -file = "src/Profiling/Profiler.php" -code = "non-existent-class" -message = "Class `ExcimerProfiler` not found." -count = 1 - -[[issues]] -file = "src/Profiling/Profiler.php" -code = "non-existent-class-like" -message = "Cannot find class, interface, enum, or type alias `ExcimerProfiler`." -count = 1 - -[[issues]] -file = "src/Profiling/Profiler.php" -code = "non-existent-constant" -message = "Undefined constant: `EXCIMER_REAL`." +message = '''Invalid return type for function `Sentry\Profiling\Profile::getFormattedData`: expected `array{'device': array{'architecture': string}, 'environment': string, 'event_id': string, 'os': array{'build_number': string, 'name': string, 'version': string}, 'platform': string('php'), 'profile': array{'frames': array, 'samples': array, 'stacks': array>}, 'release': string, 'runtime': array{'name': string, 'version': string}, 'timestamp': string, 'transaction': array{'active_thread_id': string, 'id': string, 'name': string, 'trace_id': string}, 'version': string}|null`, but found `array{'device': array{'architecture': null|string}, 'environment': string, 'event_id': string, 'os': array{'build_number': string, 'name': string, 'version': null|string}, 'platform': string('php'), 'profile': array{'frames': list, 'samples': list, 'stacks': array>}, 'release': string, 'runtime': array{'name': string, 'sapi': null|string, 'version': null|string}, 'timestamp': non-empty-string, 'transaction': array{'active_thread_id': string, 'id': string, 'name': null|string, 'trace_id': null|string}, 'version': string}`.''' count = 1 [[issues]] @@ -1320,18 +1098,6 @@ code = "generic-object-iteration" message = "Iterating over a generic `object`. This will iterate its public properties." count = 1 -[[issues]] -file = "src/Serializer/AbstractSerializer.php" -code = "impossible-condition" -message = "This condition (type `false`) will always evaluate to false." -count = 1 - -[[issues]] -file = "src/Serializer/AbstractSerializer.php" -code = "impossible-type-comparison" -message = "Impossible type assertion: `$callable` of type `(callable(...mixed): mixed)` can never be `object`." -count = 2 - [[issues]] file = "src/Serializer/AbstractSerializer.php" code = "invalid-operand" @@ -1344,16 +1110,10 @@ code = "invalid-operand" message = "Left operand in `&&` operation is an `object`." count = 1 -[[issues]] -file = "src/Serializer/AbstractSerializer.php" -code = "invalid-return-statement" -message = 'Invalid return type for function `Sentry\Serializer\AbstractSerializer::serializeValue`: expected `bool|float|int|null|string`, but found `bool|null|numeric`.' -count = 1 - [[issues]] file = "src/Serializer/AbstractSerializer.php" code = "mixed-argument" -message = "Invalid argument type for argument #1 of `method_exists`: expected `class-string|object`, but found `nonnull`." +message = "Invalid argument type for argument #1 of `method_exists`: expected `object|string`, but found `nonnull`." count = 1 [[issues]] @@ -1362,18 +1122,6 @@ code = "mixed-assignment" message = "Assigning `mixed` type to a variable may lead to unexpected behavior." count = 5 -[[issues]] -file = "src/Serializer/AbstractSerializer.php" -code = "no-value" -message = "Argument #1 passed to function `method_exists` has type `never`, meaning it cannot produce a value." -count = 1 - -[[issues]] -file = "src/Serializer/AbstractSerializer.php" -code = "no-value" -message = "Argument #1 passed to method `ReflectionMethod::__construct` has type `never`, meaning it cannot produce a value." -count = 1 - [[issues]] file = "src/Serializer/AbstractSerializer.php" code = "null-operand" @@ -1392,12 +1140,6 @@ code = "redundant-cast" message = "Redundant cast to `(string)`: the expression already has this type." count = 1 -[[issues]] -file = "src/Serializer/AbstractSerializer.php" -code = "redundant-logical-operation" -message = "Redundant `&&` operation: left operand is always falsy and right operand is not evaluated." -count = 1 - [[issues]] file = "src/Serializer/AbstractSerializer.php" code = "redundant-logical-operation" @@ -1452,12 +1194,6 @@ code = "mixed-assignment" message = "Assigning `mixed` type to a variable may lead to unexpected behavior." count = 1 -[[issues]] -file = "src/Serializer/RepresentationSerializer.php" -code = "invalid-operand" -message = "Invalid type `never` for left operand in string concatenation." -count = 1 - [[issues]] file = "src/Serializer/Traits/BreadcrumbSeralizerTrait.php" code = "invalid-return-statement" @@ -1512,12 +1248,6 @@ code = "no-value" message = "Argument #1 passed to function `get_debug_type` has type `never`, meaning it cannot produce a value." count = 1 -[[issues]] -file = "src/StacktraceBuilder.php" -code = "less-specific-nested-argument-type" -message = 'Argument type mismatch for argument #1 of `Sentry\Stacktrace::__construct`: expected `array`, but provided type `non-empty-list` is less specific.' -count = 1 - [[issues]] file = "src/StacktraceBuilder.php" code = "possibly-invalid-argument" @@ -1545,7 +1275,13 @@ count = 3 [[issues]] file = "src/State/Scope.php" code = "mixed-property-type-coercion" -message = 'A value with a less specific type `non-empty-array|non-empty-list<(callable(...mixed): mixed)>` is being assigned to property `$$eventProcessors` (array).' +message = 'A value with a less specific type `non-empty-array|non-empty-list<(callable(...mixed): mixed)>` is being assigned to property `$eventProcessors` (array).' +count = 1 + +[[issues]] +file = "src/State/Scope.php" +code = "mixed-property-type-coercion" +message = "Mixed property type coercion" count = 1 [[issues]] @@ -1572,12 +1308,6 @@ code = "redundant-logical-operation" message = "Redundant `&&` operation: left operand is evaluated and right operand is always falsy." count = 1 -[[issues]] -file = "src/Tracing/DynamicSamplingContext.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #2 of `Sentry\Tracing\DynamicSamplingContext::set`: expected `string`, but found `mixed`.' -count = 1 - [[issues]] file = "src/Tracing/DynamicSamplingContext.php" code = "possibly-null-argument" @@ -1590,54 +1320,12 @@ code = "implicit-to-string-cast" message = 'Implicit conversion to `string` for right operand via `Psr\Http\Message\UriInterface::__toString()`.' count = 1 -[[issues]] -file = "src/Tracing/GuzzleTracingMiddleware.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `Sentry\Tracing\SpanStatus::createFromHttpStatusCode`: expected `int`, but found `mixed`.' -count = 1 - [[issues]] file = "src/Tracing/GuzzleTracingMiddleware.php" code = "mixed-assignment" message = "Assigning `mixed` type to a variable may lead to unexpected behavior." count = 1 -[[issues]] -file = "src/Tracing/GuzzleTracingMiddleware.php" -code = "mixed-method-access" -message = "Attempting to access a method on a non-object type (`mixed`)." -count = 2 - -[[issues]] -file = "src/Tracing/GuzzleTracingMiddleware.php" -code = "mixed-method-access" -message = "Attempting to access a method on a non-object type (`nonnull`)." -count = 7 - -[[issues]] -file = "src/Tracing/GuzzleTracingMiddleware.php" -code = "mixed-operand" -message = "Left operand in `<` comparison has `mixed` type." -count = 1 - -[[issues]] -file = "src/Tracing/GuzzleTracingMiddleware.php" -code = "mixed-operand" -message = "Left operand in `>=` comparison has `mixed` type." -count = 3 - -[[issues]] -file = "src/Tracing/GuzzleTracingMiddleware.php" -code = "non-existent-class-like" -message = 'Class, Interface, or Trait `GuzzleHttp\Exception\RequestException` does not exist.' -count = 3 - -[[issues]] -file = "src/Tracing/GuzzleTracingMiddleware.php" -code = "non-existent-method" -message = 'Method `getresponse` does not exist on type `GuzzleHttp\Exception\RequestException`.' -count = 1 - [[issues]] file = "src/Tracing/GuzzleTracingMiddleware.php" code = "possibly-null-argument" @@ -1656,18 +1344,6 @@ code = "invalid-type-cast" message = "Non numeric string of type `string` implicitly cast to `float`." count = 4 -[[issues]] -file = "src/Tracing/Traits/TraceHeaderParserTrait.php" -code = "mixed-argument" -message = "Invalid argument type for argument #3 of `sprintf`: expected `Stringable|null|scalar`, but found `nonnull`." -count = 1 - -[[issues]] -file = "src/Tracing/Traits/TraceHeaderParserTrait.php" -code = "mixed-assignment" -message = "Assigning `mixed` type to a variable may lead to unexpected behavior." -count = 1 - [[issues]] file = "src/Tracing/Traits/TraceHeaderParserTrait.php" code = "possible-method-access-on-null" @@ -1710,18 +1386,6 @@ code = "implicit-to-string-cast" message = 'Implicit conversion to `string` for left operand via `Sentry\Severity::__toString()`.' count = 2 -[[issues]] -file = "src/Transport/HttpTransport.php" -code = "mixed-argument" -message = "Invalid argument type for argument #2 of `sprintf`: expected `Stringable|null|scalar`, but found `mixed`." -count = 1 - -[[issues]] -file = "src/Transport/HttpTransport.php" -code = "mixed-argument" -message = "Invalid argument type for argument #3 of `sprintf`: expected `Stringable|null|scalar`, but found `mixed`." -count = 1 - [[issues]] file = "src/Transport/HttpTransport.php" code = "possible-method-access-on-null" @@ -1806,12 +1470,6 @@ code = "invalid-iterator" message = "The expression provided to `foreach` is not iterable. It resolved to type `mixed`, which is not iterable." count = 1 -[[issues]] -file = "src/Util/Arr.php" -code = "less-specific-argument" -message = 'Argument type mismatch for argument #1 of `Sentry\Util\Arr::isList`: expected `array`, but provided type `non-empty-array` is less specific.' -count = 1 - [[issues]] file = "src/Util/Arr.php" code = "mixed-assignment" @@ -1830,18 +1488,6 @@ code = "mixed-operand" message = "Invalid right operand: type `mixed` cannot be reliably used in string concatenation." count = 1 -[[issues]] -file = "src/Util/Arr.php" -code = "redundant-comparison" -message = "Redundant `!==` comparison: left-hand side is always not identical to right-hand side." -count = 1 - -[[issues]] -file = "src/Util/Arr.php" -code = "redundant-condition" -message = "This condition (type `true`) will always evaluate to true." -count = 1 - [[issues]] file = "src/Util/JSON.php" code = "mixed-assignment" diff --git a/composer.json b/composer.json index cc8df365d..9ff00e387 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ "symfony/options-resolver": "^4.4.30|^5.0.11|^6.0|^7.0|^8.0" }, "require-dev": { - "carthage-software/mago": "1.30.0", + "carthage-software/mago": "1.60.2", "friendsofphp/php-cs-fixer": "^3.4", "guzzlehttp/guzzle": "^7.0|^8.0", "guzzlehttp/promises": "^2.0.3|^3.0.0", diff --git a/mago.toml b/mago.toml index f8b021c00..70cfabb83 100644 --- a/mago.toml +++ b/mago.toml @@ -1,12 +1,13 @@ [source] paths = ["src"] -includes = ["vendor"] +includes = ["vendor", "stubs"] excludes = [ "tests/resources/**", "tests/Fixtures/**", "src/Util/ClockMock.php", "vendor/open-telemetry/gen-otlp-protobuf/GPBMetadata/**", ] +extensions = ["php", "stub"] [analyzer] baseline = "analysis-baseline.toml" diff --git a/src/Attachment/Attachment.php b/src/Attachment/Attachment.php index 9fdeea438..9aa0611f5 100644 --- a/src/Attachment/Attachment.php +++ b/src/Attachment/Attachment.php @@ -42,8 +42,8 @@ public function getContentType(): string * If no low overhead way exists, then the result should be cached so that calling it multiple times * does not decrease performance. * - * @return int the size in bytes or null if the length could not be determined, for example if the file - * does not exist + * @return int|null the size in bytes or null if the length could not be determined, for example if the file + * does not exist */ abstract public function getSize(): ?int; @@ -51,8 +51,8 @@ abstract public function getSize(): ?int; * Fetches and returns the data. Calling this can have a non-trivial impact on memory usage, depending * on the type and size of attachment. * - * @return string the content as bytes or null if the content could not be retrieved, for example if the file - * does not exist + * @return string|null the content as bytes or null if the content could not be retrieved, for example if the + * file does not exist */ abstract public function getData(): ?string; diff --git a/src/DataCollection/HttpCookieCollector.php b/src/DataCollection/HttpCookieCollector.php index d4bf80b18..397f63359 100644 --- a/src/DataCollection/HttpCookieCollector.php +++ b/src/DataCollection/HttpCookieCollector.php @@ -44,10 +44,8 @@ public static function collectPsr7Request(DataCollectionPolicy $policy, HttpMess return null; } - /** @mago-ignore analysis:deprecated-method */ $cookies = HttpCookieParser::parseCookieHeaders($request->getHeader('Cookie')); - /** @mago-ignore analysis:deprecated-method */ return self::collectGroupedPairs($policy, $type, $cookies); } @@ -63,10 +61,8 @@ public static function collectPsr7Response(DataCollectionPolicy $policy, HttpMes return null; } - /** @mago-ignore analysis:deprecated-method */ $cookies = HttpCookieParser::parseSetCookieHeaders($response->getHeader('Set-Cookie')); - /** @mago-ignore analysis:deprecated-method */ return self::collectGroupedPairs($policy, $type, $cookies); } diff --git a/src/Dsn.php b/src/Dsn.php index d89d6804b..5f0bb5767 100644 --- a/src/Dsn.php +++ b/src/Dsn.php @@ -89,7 +89,7 @@ public static function createFromString(string $value): self } foreach (['scheme', 'host', 'path', 'user'] as $component) { - if (!isset($parsedDsn[$component]) || (isset($parsedDsn[$component]) && empty($parsedDsn[$component]))) { + if (empty($parsedDsn[$component])) { throw new \InvalidArgumentException(\sprintf('The "%s" DSN must contain a scheme, a host, a user and a path component.', $value)); } } From 7bb8ff42e564e190059c04a38f5f0c5dab8161b7 Mon Sep 17 00:00:00 2001 From: Martin Linzmayer Date: Thu, 19 Nov 2026 10:56:12 +0100 Subject: [PATCH 06/12] feat: add user resolver (#2396) --- analysis-baseline.toml | 12 ++++ src/State/Scope.php | 64 ++++++++++++++++++-- tests/State/ScopeTest.php | 122 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 194 insertions(+), 4 deletions(-) diff --git a/analysis-baseline.toml b/analysis-baseline.toml index 2c8f8507a..0c1a8d183 100644 --- a/analysis-baseline.toml +++ b/analysis-baseline.toml @@ -1260,6 +1260,18 @@ code = "possibly-null-operand" message = "Left operand in `<` comparison might be `null` (type `float|null`)." count = 1 +[[issues]] +file = "src/State/Scope.php" +code = "deprecated-method" +message = 'Call to deprecated method: `Sentry\UserDataBag::getSegment`.' +count = 2 + +[[issues]] +file = "src/State/Scope.php" +code = "deprecated-method" +message = 'Call to deprecated method: `Sentry\UserDataBag::setSegment`.' +count = 1 + [[issues]] file = "src/State/Scope.php" code = "impossible-condition" diff --git a/src/State/Scope.php b/src/State/Scope.php index e771953dc..911c918a6 100644 --- a/src/State/Scope.php +++ b/src/State/Scope.php @@ -45,6 +45,11 @@ class Scope */ private $user; + /** + * @var (callable(): (UserDataBag|null))|null The callable that resolves the user each time it is read + */ + private $userResolver; + /** * @var array> The list of contexts associated to this scope */ @@ -248,7 +253,54 @@ public function setExtras(array $extras): self */ public function getUser(): ?UserDataBag { - return $this->user; + if ($this->userResolver === null) { + return $this->user; + } + + $userResolver = $this->userResolver; + // unset the callback to prevent recursion in case getUser is called in the callback + $this->userResolver = null; + + try { + $resolvedUser = $userResolver(); + } catch (\Throwable $exception) { + $resolvedUser = null; + } finally { + $this->userResolver = $userResolver; + } + + if ($resolvedUser === null) { + return $this->user; + } + + if ($this->user === null) { + return clone $resolvedUser; + } + + $user = clone $this->user; + $user->setId($user->getId() ?? $resolvedUser->getId()); + $user->setEmail($user->getEmail() ?? $resolvedUser->getEmail()); + $user->setUsername($user->getUsername() ?? $resolvedUser->getUsername()); + $user->setIpAddress($user->getIpAddress() ?? $resolvedUser->getIpAddress()); + $user->setSegment($user->getSegment() ?? $resolvedUser->getSegment()); + + return (clone $resolvedUser)->merge($user); + } + + /** + * Sets a callable that resolves the user each time it is read, which + * happens for every event, log and metric, so it should be cheap. The + * data set on the scope takes precedence over the data it returns. + * + * @param callable(): (UserDataBag|null) $userResolver + * + * @return $this + */ + public function setUserResolver(callable $userResolver): self + { + $this->userResolver = $userResolver; + + return $this; } /** @@ -285,6 +337,7 @@ public function setUser($user): self public function removeUser(): self { $this->user = null; + $this->userResolver = null; return $this; } @@ -439,6 +492,7 @@ public static function getExternalPropagationContext(): ?array public function clear(): self { $this->user = null; + $this->userResolver = null; $this->level = null; $this->span = null; $this->fingerprint = []; @@ -489,13 +543,15 @@ public function applyToEvent(Event $event, ?EventHint $hint = null, ?Options $op $event->setExtra(array_merge($this->extra, $event->getExtra())); } - if ($this->user !== null) { + $scopeUser = $this->getUser(); + + if ($scopeUser !== null) { $user = $event->getUser(); if ($user === null) { - $user = $this->user; + $user = $scopeUser; } else { - $user = $this->user->merge($user); + $user = $scopeUser->merge($user); } $event->setUser($user); diff --git a/tests/State/ScopeTest.php b/tests/State/ScopeTest.php index de9b1a621..2a01c409e 100644 --- a/tests/State/ScopeTest.php +++ b/tests/State/ScopeTest.php @@ -305,6 +305,125 @@ public function testSetUserThrowsOnInvalidArgument(): void $scope->setUser('foo'); } + public function testSetUserResolver(): void + { + $scope = new Scope(); + $scope->setUser(UserDataBag::createFromUserIpAddress('127.0.0.1')); + + $resolvable = false; + $calls = 0; + + $scope->setUserResolver(static function () use (&$resolvable, &$calls): ?UserDataBag { + ++$calls; + + return $resolvable ? UserDataBag::createFromUserIdentifier('unique_id') : null; + }); + + $this->assertEquals(UserDataBag::createFromUserIpAddress('127.0.0.1'), $scope->getUser()); + $this->assertSame(1, $calls); + + $resolvable = true; + + $event = $scope->applyToEvent(Event::createEvent()); + + $this->assertNotNull($event); + $this->assertEquals(UserDataBag::createFromArray(['id' => 'unique_id', 'ip_address' => '127.0.0.1']), $event->getUser()); + $this->assertSame(2, $calls); + + $resolvable = false; + + $this->assertEquals(UserDataBag::createFromUserIpAddress('127.0.0.1'), $scope->getUser()); + } + + public function testSetUserResolverDoesNotOverrideTheUser(): void + { + $scope = new Scope(); + $scope->setUser(['id' => 'unique_id', 'subscription' => 'basic']); + + $scope->setUserResolver(static function (): UserDataBag { + return UserDataBag::createFromArray([ + 'id' => 'resolved_id', + 'email' => 'foo@example.com', + 'segment' => 'my_segment', + 'subscription' => 'pro', + 'plan' => 'yearly', + ]); + }); + + $this->assertEquals( + UserDataBag::createFromArray([ + 'id' => 'unique_id', + 'email' => 'foo@example.com', + 'segment' => 'my_segment', + 'subscription' => 'basic', + 'plan' => 'yearly', + ]), + $scope->getUser() + ); + } + + public function testSetUserResolverDoesNotChangeTheResolvedUser(): void + { + $resolvedUser = UserDataBag::createFromUserIdentifier('unique_id'); + + $scope = new Scope(); + $scope->setUserResolver(static function () use ($resolvedUser): UserDataBag { + return $resolvedUser; + }); + + $event = Event::createEvent(); + $event->setUser(UserDataBag::createFromUserIpAddress('127.0.0.1')); + + $scope->applyToEvent($event); + + $this->assertEquals(UserDataBag::createFromUserIdentifier('unique_id'), $resolvedUser); + } + + public function testSetUserResolverKeepsTheUserIfTheResolverThrows(): void + { + $scope = new Scope(); + $scope->setUser(UserDataBag::createFromUserIpAddress('127.0.0.1')); + + $scope->setUserResolver(static function (): UserDataBag { + throw new \RuntimeException('foo'); + }); + + $this->assertEquals(UserDataBag::createFromUserIpAddress('127.0.0.1'), $scope->getUser()); + } + + public function testSetUserResolverIsNotCalledAgainWhileItRuns(): void + { + $scope = new Scope(); + $calls = 0; + + $scope->setUserResolver(static function () use ($scope, &$calls): ?UserDataBag { + ++$calls; + + return $scope->getUser(); + }); + + $this->assertNull($scope->getUser()); + $this->assertSame(1, $calls); + + $scope->getUser(); + + $this->assertSame(2, $calls); + } + + public function testRemoveUserRemovesTheUserResolver(): void + { + $scope = new Scope(); + $scope->setUserResolver(static function (): UserDataBag { + return UserDataBag::createFromUserIdentifier('unique_id'); + }); + + $this->assertEquals(UserDataBag::createFromUserIdentifier('unique_id'), $scope->getUser()); + + $scope->removeUser(); + + $this->assertNull($scope->getUser()); + } + public function testRemoveUser(): void { $scope = new Scope(); @@ -523,6 +642,9 @@ public function testClear(): void $scope->setTags(['bar' => 'foo']); $scope->addFeatureFlag('feature', true); $scope->setUser(UserDataBag::createFromUserIdentifier('unique_id')); + $scope->setUserResolver(static function (): UserDataBag { + return UserDataBag::createFromUserIdentifier('resolved_id'); + }); $scope->clear(); $event = $scope->applyToEvent(Event::createEvent()); From 642bf38898e70b2ecb3cae076c601ecda0a85fe8 Mon Sep 17 00:00:00 2001 From: "sentry-junior[bot]" <264270552+sentry-junior[bot]@users.noreply.github.com> Date: Thu, 19 Nov 2026 11:10:58 +0100 Subject: [PATCH 07/12] ref(tracing): Drop Transaction::$transaction redeclaration to remove Mago baseline entry (#2398) Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> --- analysis-baseline.toml | 6 ------ src/Tracing/Transaction.php | 7 +------ 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/analysis-baseline.toml b/analysis-baseline.toml index 0c1a8d183..59975be06 100644 --- a/analysis-baseline.toml +++ b/analysis-baseline.toml @@ -1368,12 +1368,6 @@ code = "reference-to-undefined-variable" message = "Reference created from a previously undefined variable `$matches`." count = 1 -[[issues]] -file = "src/Tracing/Transaction.php" -code = "incompatible-property-type" -message = 'Property `Sentry\Tracing\Transaction::$transaction` has an incompatible type declaration from docblock.' -count = 1 - [[issues]] file = "src/Tracing/Transaction.php" code = "invalid-return-statement" diff --git a/src/Tracing/Transaction.php b/src/Tracing/Transaction.php index 4eb943d7e..3bd4c8689 100644 --- a/src/Tracing/Transaction.php +++ b/src/Tracing/Transaction.php @@ -31,11 +31,6 @@ final class Transaction extends Span */ private $name; - /** - * @var Transaction The transaction - */ - protected $transaction; - /** * @var TransactionMetadata */ @@ -103,7 +98,7 @@ public function getDynamicSamplingContext(): DynamicSamplingContext return $this->metadata->getDynamicSamplingContext(); } - $samplingContext = DynamicSamplingContext::fromTransaction($this->transaction, $this->hub); + $samplingContext = DynamicSamplingContext::fromTransaction($this, $this->hub); $this->getMetadata()->setDynamicSamplingContext($samplingContext); return $samplingContext; From 9cbcd089f98e8115a694df65509deac9499cb8f5 Mon Sep 17 00:00:00 2001 From: "sentry-junior[bot]" <264270552+sentry-junior[bot]@users.noreply.github.com> Date: Thu, 19 Nov 2026 11:11:02 +0100 Subject: [PATCH 08/12] ref(util): Match debug_backtrace native type in CodeLocationResolver @var to drop PHPStan baseline entry (#2393) Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> --- phpstan-baseline.neon | 6 ------ src/Util/CodeLocationResolver.php | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 0736344e8..5fe7166ce 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -522,12 +522,6 @@ parameters: count: 1 path: src/UserDataBag.php - - - message: '#^PHPDoc tag @var with type list\\}\> is not subtype of native type list\''\|''\:\:'', args\?\: list\, object\?\: object\}\>\.$#' - identifier: varTag.nativeType - count: 1 - path: src/Util/CodeLocationResolver.php - - message: '#^Method Sentry\\Util\\TelemetryStorage\:\:bounded\(\) should return Sentry\\Util\\TelemetryStorage\ but returns Sentry\\Util\\TelemetryStorage\\.$#' identifier: return.type diff --git a/src/Util/CodeLocationResolver.php b/src/Util/CodeLocationResolver.php index cc968e70c..e89063ba2 100644 --- a/src/Util/CodeLocationResolver.php +++ b/src/Util/CodeLocationResolver.php @@ -42,7 +42,7 @@ public function __construct(Options $options, RepresentationSerializerInterface */ public function resolve(int $limit = 20): ?array { - /** @var list $backtrace */ + /** @var list'|'::'}> $backtrace */ $backtrace = debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, $limit); return $this->resolveFromBacktrace($backtrace); From b44566cde15710e898ba8e9ef32d79c820f7bd4a Mon Sep 17 00:00:00 2001 From: "sentry-junior[bot]" <264270552+sentry-junior[bot]@users.noreply.github.com> Date: Thu, 19 Nov 2026 11:13:42 +0100 Subject: [PATCH 09/12] ref(client-report): Narrow ClientReportAggregator reports key type to drop Mago baseline entry (#2397) Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> --- analysis-baseline.toml | 6 ------ src/ClientReport/ClientReportAggregator.php | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/analysis-baseline.toml b/analysis-baseline.toml index 59975be06..155d7e3ca 100644 --- a/analysis-baseline.toml +++ b/analysis-baseline.toml @@ -48,12 +48,6 @@ code = "impossible-condition" message = "This condition (type `false`) will always evaluate to false." count = 1 -[[issues]] -file = "src/ClientReport/ClientReportAggregator.php" -code = "less-specific-argument" -message = 'Argument type mismatch for argument #1 of `Sentry\ClientReport\DiscardedEvent::__construct`: expected `string`, but provided type `array-key` is less specific.' -count = 1 - [[issues]] file = "src/ClientReport/ClientReportAggregator.php" code = "redundant-comparison" diff --git a/src/ClientReport/ClientReportAggregator.php b/src/ClientReport/ClientReportAggregator.php index 32a9aa613..04fe29f28 100644 --- a/src/ClientReport/ClientReportAggregator.php +++ b/src/ClientReport/ClientReportAggregator.php @@ -27,7 +27,7 @@ class ClientReportAggregator * ] *``` * - * @var array> + * @var array> */ private $reports = []; From 3633c26abb62da1ad95bcfa2779b9c119995c422 Mon Sep 17 00:00:00 2001 From: Martin Linzmayer Date: Thu, 19 Nov 2026 11:49:17 +0100 Subject: [PATCH 10/12] Prepare 4.38.0 (#2399) --- CHANGELOG.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c930ff8e..f24cfd7f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,22 @@ # CHANGELOG +## 4.38.0 + +The Sentry SDK team is happy to announce the immediate availability of Sentry PHP SDK v4.38.0. + +### Features + +- Add `Scope::setUserResolver()` to resolve the user lazily each time it is read, instead of setting it upfront. User data set with `Scope::setUser()` takes precedence over the data the resolver returns. [(#2396)](https://github.com/getsentry/sentry-php/pull/2396) + + ```php + \Sentry\configureScope(static function (\Sentry\State\Scope $scope): void { + $scope->setUserResolver(static function (): ?\Sentry\UserDataBag { + // Return null as long as the user is not known yet + return \Sentry\UserDataBag::createFromUserIdentifier('1234'); + }); + }); + ``` + ## 5.0.0-beta1 The Sentry SDK team is happy to announce the first beta release of Sentry PHP SDK v5.0.0. From 9e5f09ccb8f741dde2717f48b1c6df820f95b7c5 Mon Sep 17 00:00:00 2001 From: stayallive <1090754+stayallive@users.noreply.github.com> Date: Thu, 19 Nov 2026 10:49:48 +0000 Subject: [PATCH 11/12] release: 4.38.0 --- src/Client.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Client.php b/src/Client.php index f1ee38bf8..9517f6248 100644 --- a/src/Client.php +++ b/src/Client.php @@ -35,7 +35,7 @@ class Client implements ClientInterface /** * The version of the SDK. */ - public const SDK_VERSION = '4.37.1'; + public const SDK_VERSION = '4.38.0'; /** * Regex pattern to detect if a string is a regex pattern (starts and ends with / optionally followed by flags). From 67114a7b169415fe583b9e49811cba4be9083bfa Mon Sep 17 00:00:00 2001 From: Martin Linzmayer Date: Thu, 19 Nov 2026 16:10:41 +0100 Subject: [PATCH 12/12] fix(client-reports): record events dropped by client exception (#2401) --- src/Transport/HttpTransport.php | 3 +++ tests/Transport/HttpTransportTest.php | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/src/Transport/HttpTransport.php b/src/Transport/HttpTransport.php index ed264e5fc..2e4f9d2ac 100644 --- a/src/Transport/HttpTransport.php +++ b/src/Transport/HttpTransport.php @@ -155,6 +155,9 @@ public function send(Event $event): Result ['exception' => $exception, 'event' => $event] ); + // No response was received, so this is recorded like a failed connection + ClientReportAggregator::getInstance()->addEvent($event, Reason::networkError()); + return new Result(ResultStatus::failed()); } diff --git a/tests/Transport/HttpTransportTest.php b/tests/Transport/HttpTransportTest.php index ad7604e39..538e0d04d 100644 --- a/tests/Transport/HttpTransportTest.php +++ b/tests/Transport/HttpTransportTest.php @@ -165,6 +165,10 @@ public static function sendDataProvider(): iterable public function testSendFailsDueToHttpClientException(): void { + SentrySdk::init()->bindClient(new Client(new Options([ + 'send_client_reports' => true, + ]), StubTransport::getInstance())); + $exception = new \Exception('foo'); $event = Event::createEvent(); @@ -198,6 +202,7 @@ public function testSendFailsDueToHttpClientException(): void $result = $transport->send($event); $this->assertSame(ResultStatus::failed(), $result->getStatus()); + $this->assertClientReports(['error' => ['network_error' => 1]]); } public function testRecordsClientReportWhenSerializationFails(): void