From dbbccef0e17f3c26339538ea72b75489ba5a49e4 Mon Sep 17 00:00:00 2001 From: Martin Linzmayer Date: Wed, 4 Mar 2026 16:26:25 +0100 Subject: [PATCH 1/2] feat(ci): add mago to CI pipeline --- .github/workflows/ci.yml | 2 +- .github/workflows/static-analysis.yaml | 18 + analysis-baseline.toml | 1693 +++++++++++++++++ composer.json | 6 +- mago.toml | 11 + .../EnvelopItems/TransactionItem.php | 2 +- src/Util/PHPVersion.php | 1 + src/functions.php | 7 +- 8 files changed, 1734 insertions(+), 6 deletions(-) create mode 100644 analysis-baseline.toml create mode 100644 mago.toml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2939342fb5..6534b210d8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -73,7 +73,7 @@ jobs: # These dependencies are not used running the tests but can cause deprecation warnings so we remove them before running the tests - name: Remove unused dependencies - run: composer remove vimeo/psalm phpstan/phpstan friendsofphp/php-cs-fixer --dev --no-interaction --no-update + run: composer remove vimeo/psalm carthage-software/mago phpstan/phpstan friendsofphp/php-cs-fixer --dev --no-interaction --no-update - name: Remove RoadRunner dependencies on unsupported PHP versions if: ${{ matrix.os == 'windows-latest' || matrix.php.version == '7.2' || matrix.php.version == '7.3' || matrix.php.version == '7.4' || matrix.php.version == '8.0' }} diff --git a/.github/workflows/static-analysis.yaml b/.github/workflows/static-analysis.yaml index ba6ffe12cf..2a0961f1ad 100644 --- a/.github/workflows/static-analysis.yaml +++ b/.github/workflows/static-analysis.yaml @@ -64,3 +64,21 @@ jobs: - name: Run script run: vendor/bin/psalm + + mago: + name: Mago + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v6 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.4' + + - name: Install dependencies + run: composer update --no-progress --no-interaction --prefer-dist + + - name: Run script + run: composer mago diff --git a/analysis-baseline.toml b/analysis-baseline.toml new file mode 100644 index 0000000000..b8a147a156 --- /dev/null +++ b/analysis-baseline.toml @@ -0,0 +1,1693 @@ +variant = "loose" + +[[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 = "possible-method-access-on-null" +message = "Attempting to call a method on `null`." +count = 2 + +[[issues]] +file = "src/Client.php" +code = "possibly-invalid-argument" +message = '''Possible argument type mismatch for argument #1 of `Sentry\StacktraceBuilder::buildfrombacktrace`: expected `list, 'class'?: class-string, 'file'?: string, 'function'?: string, 'line'?: int, 'type'?: string}>`, but possibly received `array`.''' +count = 1 + +[[issues]] +file = "src/Client.php" +code = "possibly-null-argument" +message = 'Argument #1 of method `Sentry\StacktraceBuilder::buildfromexception` is possibly `null`, but parameter type `Throwable` does not accept it.' +count = 1 + +[[issues]] +file = "src/Client.php" +code = "possibly-null-argument" +message = 'Argument #1 of method `sentry\exceptiondatabag::__construct` is possibly `null`, but parameter type `Throwable` does not accept it.' +count = 1 + +[[issues]] +file = "src/Client.php" +code = "possibly-null-operand" +message = 'Possibly null left operand used in string concatenation (type `Sentry\Severity|null`).' +count = 1 + +[[issues]] +file = "src/Client.php" +code = "redundant-docblock-type" +message = "Redundant docblock type for variable `$result`." +count = 1 + +[[issues]] +file = "src/Client.php" +code = "unused-template-parameter" +message = 'Template parameter `T` is never used in method `Sentry\Client::getIntegration`.' +count = 1 + +[[issues]] +file = "src/Dsn.php" +code = "possibly-false-operand" +message = "Left operand in `==` comparison might be `false` (type `false|int`)." +count = 1 + +[[issues]] +file = "src/Dsn.php" +code = "possibly-null-argument" +message = "Argument #2 of function `preg_match` is possibly `null`, but parameter type `string` does not accept it." +count = 1 + +[[issues]] +file = "src/Dsn.php" +code = "possibly-null-argument" +message = 'Argument #2 of method `sentry\dsn::__construct` is possibly `null`, but parameter type `string` does not accept it.' +count = 1 + +[[issues]] +file = "src/Dsn.php" +code = "possibly-null-argument" +message = 'Argument #6 of method `sentry\dsn::__construct` is possibly `null`, but parameter type `string` does not accept it.' +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': string, 'port'?: int<0, 65535>, 'query'?: non-empty-string, 'scheme': string('http')|string('https'), 'user'?: non-empty-string}`." +count = 2 + +[[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': string, 'port'?: int<0, 65535>, 'query'?: non-empty-string, 'scheme'?: non-empty-string, 'user'?: non-empty-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': string, 'port'?: int<0, 65535>, 'query'?: non-empty-string, 'scheme': string('http')|string('https'), 'user'?: non-empty-string}`." +count = 1 + +[[issues]] +file = "src/Dsn.php" +code = "redundant-comparison" +message = "Redundant `!==` comparison: left-hand side is always not identical to right-hand side." +count = 2 + +[[issues]] +file = "src/Dsn.php" +code = "redundant-condition" +message = "This condition (type `true`) will always evaluate to true." +count = 2 + +[[issues]] +file = "src/Dsn.php" +code = "reference-to-undefined-variable" +message = "Reference created from a previously undefined variable `$matches`." +count = 1 + +[[issues]] +file = "src/ErrorHandler.php" +code = "less-specific-nested-argument-type" +message = '''Argument type mismatch for argument #1 of `closure::fromcallable`: expected `(callable(...mixed=): mixed)`, but provided type `list{Sentry\ErrorHandler&static|sentry\errorhandler, string('handleError')}` is less specific.''' +count = 1 + +[[issues]] +file = "src/ErrorHandler.php" +code = "less-specific-nested-argument-type" +message = '''Argument type mismatch for argument #1 of `closure::fromcallable`: expected `(callable(...mixed=): mixed)`, but provided type `list{Sentry\ErrorHandler&static|sentry\errorhandler, string('handleException')}` is less specific.''' +count = 1 + +[[issues]] +file = "src/ErrorHandler.php" +code = "less-specific-nested-argument-type" +message = '''Argument type mismatch for argument #1 of `closure::fromcallable`: expected `(callable(...mixed=): mixed)`, but provided type `list{Sentry\ErrorHandler&static|sentry\errorhandler, string('handleFatalError')}` is less specific.''' +count = 1 + +[[issues]] +file = "src/ErrorHandler.php" +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 = "redundant-comparison" +message = "Redundant `>=` comparison: left-hand side is always greater than or equal to right-hand side." +count = 1 + +[[issues]] +file = "src/ErrorHandler.php" +code = "redundant-condition" +message = "This condition (type `true`) will always evaluate to true." +count = 1 + +[[issues]] +file = "src/ErrorHandler.php" +code = "reference-to-undefined-variable" +message = "Reference created from a previously undefined variable `$matches`." +count = 1 + +[[issues]] +file = "src/ErrorHandler.php" +code = "write-only-property" +message = "Property `$reservedMemory` is written to but never read." +count = 1 + +[[issues]] +file = "src/Event.php" +code = "impossible-condition" +message = "This condition (type `false`) will always evaluate to false." +count = 1 + +[[issues]] +file = "src/Event.php" +code = "mixed-assignment" +message = "Assigning `mixed` type to a variable may lead to unexpected behavior." +count = 1 + +[[issues]] +file = "src/Event.php" +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/EventHint.php" +code = "impossible-condition" +message = "This condition (type `false`) will always evaluate to false." +count = 4 + +[[issues]] +file = "src/EventHint.php" +code = "no-value" +message = "Argument #1 passed to function `get_debug_type` has type `never`, meaning it cannot produce a value." +count = 4 + +[[issues]] +file = "src/EventHint.php" +code = "redundant-logical-operation" +message = "Redundant `&&` operation: left operand is evaluated and right operand is always falsy." +count = 3 + +[[issues]] +file = "src/EventHint.php" +code = "redundant-type-comparison" +message = "Redundant type assertion: `$extra` of type `array` is always not `array`." +count = 1 + +[[issues]] +file = "src/FrameBuilder.php" +code = "invalid-operand" +message = "Right operand in `&&` operation is an `array`." +count = 1 + +[[issues]] +file = "src/FrameBuilder.php" +code = "mixed-assignment" +message = "Assigning `mixed` type to a variable may lead to unexpected behavior." +count = 2 + +[[issues]] +file = "src/FrameBuilder.php" +code = "reference-to-undefined-variable" +message = "Reference created from a previously undefined variable `$matches`." +count = 1 + +[[issues]] +file = "src/HttpClient/HttpClient.php" +code = "impossible-condition" +message = "This condition (type `false`) will always evaluate to false." +count = 2 + +[[issues]] +file = "src/HttpClient/HttpClient.php" +code = "less-specific-argument" +message = "Argument type mismatch for argument #1 of `curl_share_setopt`: expected `CurlShareHandle`, but provided type `null|object|resource` is less specific." +count = 2 + +[[issues]] +file = "src/HttpClient/HttpClient.php" +code = "mixed-argument" +message = 'Invalid argument type for argument #1 of `sentry\httpclient\response::__construct`: expected `int`, but found `mixed`.' +count = 1 + +[[issues]] +file = "src/HttpClient/HttpClient.php" +code = "mixed-argument" +message = 'Invalid argument type for argument #1 of `sentry\util\http::parseresponseheaders`: expected `string`, but found `mixed`.' +count = 1 + +[[issues]] +file = "src/HttpClient/HttpClient.php" +code = "mixed-argument" +message = "Invalid argument type for argument #1 of `version_compare`: expected `string`, but found `mixed`." +count = 1 + +[[issues]] +file = "src/HttpClient/HttpClient.php" +code = "mixed-assignment" +message = "Assigning `mixed` type to a variable may lead to unexpected behavior." +count = 1 + +[[issues]] +file = "src/HttpClient/HttpClient.php" +code = "mixed-operand" +message = "Left operand in `>=` comparison has `mixed` type." +count = 1 + +[[issues]] +file = "src/HttpClient/HttpClient.php" +code = "mixed-property-type-coercion" +message = "A value with a less specific type `mixed` is being assigned to property `$$shareHandle` (null|object|resource)." +count = 1 + +[[issues]] +file = "src/HttpClient/HttpClient.php" +code = "non-existent-function" +message = 'Could not find definition for function `Sentry\HttpClient\curl_share_init_persistent` (also tried as `curl_share_init_persistent` in a broader scope).' +count = 1 + +[[issues]] +file = "src/HttpClient/HttpClient.php" +code = "possibly-null-argument" +message = "Argument #1 of function `curl_share_setopt` is possibly `null`, but parameter type `CurlShareHandle` does not accept it." +count = 2 + +[[issues]] +file = "src/HttpClient/HttpClient.php" +code = "redundant-comparison" +message = "Redundant `<` comparison: left-hand side is never less than right-hand side." +count = 2 + +[[issues]] +file = "src/HttpClient/Request.php" +code = "redundant-comparison" +message = "Redundant `!==` comparison: left-hand side is always not identical to right-hand side." +count = 1 + +[[issues]] +file = "src/HttpClient/Response.php" +code = "less-specific-argument" +message = "Argument type mismatch for argument #1 of `strtolower`: expected `string`, but provided type `array-key` is less specific." +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)." +count = 1 + +[[issues]] +file = "src/Integration/FrameContextifierIntegration.php" +code = "possibly-null-argument" +message = 'Argument #2 of method `Sentry\Integration\FrameContextifierIntegration::addcontexttostacktraceframes` is possibly `null`, but parameter type `Sentry\Stacktrace` does not accept it.' +count = 1 + +[[issues]] +file = "src/Integration/FrameContextifierIntegration.php" +code = "possibly-null-argument" +message = 'Argument #2 of method `Sentry\Integration\FrameContextifierIntegration::getsourcecodeexcerpt` is possibly `null`, but parameter type `string` does not accept it.' +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>`.' +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 `array{}|non-empty-list<(callable(array): Sentry\Integration\IntegrationInterface)|Sentry\Integration\IntegrationInterface>`.' +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`.' +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')`.''' +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." +count = 1 + +[[issues]] +file = "src/Integration/IntegrationRegistry.php" +code = "redundant-type-comparison" +message = 'Redundant type assertion: `$userIntegrations` of type `array): Sentry\Integration\IntegrationInterface)|Sentry\Integration\IntegrationInterface>` is always not `array`.' +count = 1 + +[[issues]] +file = "src/Integration/IntegrationRegistry.php" +code = "unreachable-else-clause" +message = "Unreachable else clause" +count = 1 + +[[issues]] +file = "src/Integration/ModulesIntegration.php" +code = "invalid-argument" +message = "Invalid argument type for argument #1 of `array_keys`: expected `array`, but found `list{}`." +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::setipaddress`: expected `null|string`, but found `truthy-mixed`.' +count = 1 + +[[issues]] +file = "src/Integration/RequestIntegration.php" +code = "mixed-argument" +message = "Invalid argument type for argument #1 of `min`: expected `array|int(10000)`, but found `mixed`." +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 `strlen`: expected `string`, but found `mixed`." +count = 1 + +[[issues]] +file = "src/Integration/RequestIntegration.php" +code = "mixed-assignment" +message = "Assigning `mixed` type to a variable may lead to unexpected behavior." +count = 4 + +[[issues]] +file = "src/Integration/RequestIntegration.php" +code = "mixed-operand" +message = "Invalid right operand: type `mixed` cannot be reliably used in string concatenation." +count = 1 + +[[issues]] +file = "src/Integration/RequestIntegration.php" +code = "mixed-operand" +message = "Left operand in `>` comparison has `mixed` type." +count = 2 + +[[issues]] +file = "src/Integration/RequestIntegration.php" +code = "mixed-operand" +message = "Left operand in binary operation has type `mixed`." +count = 1 + +[[issues]] +file = "src/Logger/DebugLogger.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/Logs/LogsAggregator.php" +code = "impossible-condition" +message = "This condition (type `false`) will always evaluate to false." +count = 1 + +[[issues]] +file = "src/Logs/LogsAggregator.php" +code = "mixed-assignment" +message = "Assigning `mixed` type to a variable may lead to unexpected behavior." +count = 1 + +[[issues]] +file = "src/Logs/LogsAggregator.php" +code = "no-value" +message = "Argument #2 passed to function `sprintf` has type `never`, meaning it cannot produce a value." +count = 1 + +[[issues]] +file = "src/Logs/LogsAggregator.php" +code = "possible-method-access-on-null" +message = "Attempting to call a method on `null`." +count = 1 + +[[issues]] +file = "src/Logs/LogsAggregator.php" +code = "redundant-type-comparison" +message = "Redundant type assertion: `$key` of type `string` is always not `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" +message = "Ambiguous instantiation: the expression used with `new` can resolve to multiple different classes." +count = 1 + +[[issues]] +file = "src/Metrics/MetricsAggregator.php" +code = "impossible-condition" +message = "This condition (type `false`) will always evaluate to false." +count = 1 + +[[issues]] +file = "src/Metrics/MetricsAggregator.php" +code = "mixed-argument" +message = 'Invalid argument type for argument #1 of `Sentry\Util\RingBuffer::push`: expected `Sentry\Metrics\Types\Metric`, but found `nonnull`.' +count = 1 + +[[issues]] +file = "src/Metrics/MetricsAggregator.php" +code = "mixed-assignment" +message = "Assigning `mixed` type to a variable may lead to unexpected behavior." +count = 1 + +[[issues]] +file = "src/Metrics/MetricsAggregator.php" +code = "mixed-property-type-coercion" +message = 'A value with a less specific type `Sentry\Util\RingBuffer` is being assigned to property `$$metrics` (Sentry\Util\RingBuffer).' +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|array{'sentry.environment': string, 'sentry.release'?: string, 'sentry.sdk.name': string, 'sentry.sdk.version': string, 'server.address': string, 'user.email'?: null|string, 'user.id'?: int|null|string, 'user.name'?: null|string}`.''' +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|array{'sentry.environment': string, 'sentry.release'?: string, 'sentry.sdk.name': string, 'sentry.sdk.version': string, 'server.address': string, 'user.email'?: null|string, 'user.id'?: int|null|string, 'user.name'?: null|string}`.''' +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|array{'sentry.environment': string, 'sentry.release'?: string, 'sentry.sdk.name': string, 'sentry.sdk.version': string, 'server.address': string, 'user.email'?: null|string, 'user.id'?: int|null|string, 'user.name'?: null|string}`.''' +count = 1 + +[[issues]] +file = "src/Metrics/MetricsAggregator.php" +code = "possibly-null-argument" +message = 'Argument #3 of method `sentry\metrics\types\countermetric::__construct` is possibly `null`, but parameter type `Sentry\Tracing\TraceId` does not accept it.' +count = 1 + +[[issues]] +file = "src/Metrics/MetricsAggregator.php" +code = "possibly-null-argument" +message = 'Argument #3 of method `sentry\metrics\types\distributionmetric::__construct` is possibly `null`, but parameter type `Sentry\Tracing\TraceId` does not accept it.' +count = 1 + +[[issues]] +file = "src/Metrics/MetricsAggregator.php" +code = "possibly-null-argument" +message = 'Argument #3 of method `sentry\metrics\types\gaugemetric::__construct` is possibly `null`, but parameter type `Sentry\Tracing\TraceId` does not accept it.' +count = 1 + +[[issues]] +file = "src/Metrics/MetricsAggregator.php" +code = "possibly-null-argument" +message = 'Argument #4 of method `sentry\metrics\types\countermetric::__construct` is possibly `null`, but parameter type `Sentry\Tracing\SpanId` does not accept it.' +count = 1 + +[[issues]] +file = "src/Metrics/MetricsAggregator.php" +code = "possibly-null-argument" +message = 'Argument #4 of method `sentry\metrics\types\distributionmetric::__construct` is possibly `null`, but parameter type `Sentry\Tracing\SpanId` does not accept it.' +count = 1 + +[[issues]] +file = "src/Metrics/MetricsAggregator.php" +code = "possibly-null-argument" +message = 'Argument #4 of method `sentry\metrics\types\gaugemetric::__construct` is possibly `null`, but parameter type `Sentry\Tracing\SpanId` does not accept it.' +count = 1 + +[[issues]] +file = "src/Metrics/MetricsAggregator.php" +code = "redundant-logical-operation" +message = "Redundant `&&` operation: left operand is evaluated and right operand is always falsy." +count = 1 + +[[issues]] +file = "src/Metrics/MetricsAggregator.php" +code = "redundant-type-comparison" +message = "Redundant type assertion: `$value` of type `float` is always not `float`." +count = 1 + +[[issues]] +file = "src/Monolog/BreadcrumbHandler.php" +code = "impossible-nonnull-entry-check" +message = "Impossible `isset` check on key `'context'` accessed on `array{'channel': string, 'datetime': DateTimeImmutable, 'extra'?: array, 'level': int, 'message': string}`." +count = 1 + +[[issues]] +file = "src/Monolog/BreadcrumbHandler.php" +code = "invalid-method-access" +message = "Attempting to access a method on a non-object type (`array`)." +count = 1 + +[[issues]] +file = "src/Monolog/BreadcrumbHandler.php" +code = "invalid-method-access" +message = "Attempting to access a method on a non-object type (`int`)." +count = 1 + +[[issues]] +file = "src/Monolog/BreadcrumbHandler.php" +code = "invalid-method-access" +message = "Attempting to access a method on a non-object type (`string`)." +count = 1 + +[[issues]] +file = "src/Monolog/BreadcrumbHandler.php" +code = "less-specific-argument" +message = 'Argument type mismatch for argument #5 of `sentry\breadcrumb::__construct`: expected `array`, but provided type `array|int` is less specific.' +count = 1 + +[[issues]] +file = "src/Monolog/BreadcrumbHandler.php" +code = "mixed-argument" +message = 'Invalid argument type for argument #6 of `sentry\breadcrumb::__construct`: expected `float|null`, but found `mixed`.' +count = 1 + +[[issues]] +file = "src/Monolog/BreadcrumbHandler.php" +code = "possibly-invalid-argument" +message = 'Possible argument type mismatch for argument #1 of `Sentry\Monolog\BreadcrumbHandler::getbreadcrumblevel`: expected `enum(Monolog\Level)|int`, but possibly received `DateTimeImmutable|array|int|string`.' +count = 1 + +[[issues]] +file = "src/Monolog/BreadcrumbHandler.php" +code = "possibly-invalid-argument" +message = 'Possible argument type mismatch for argument #1 of `Sentry\Monolog\BreadcrumbHandler::getbreadcrumbtype`: expected `int`, but possibly received `DateTimeImmutable|array|int|string`.' +count = 1 + +[[issues]] +file = "src/Monolog/BreadcrumbHandler.php" +code = "possibly-invalid-argument" +message = '''Possible argument type mismatch for argument #1 of `monolog\handler\abstracthandler::__construct`: expected `enum(Monolog\Level)|int(100)|int(200)|int(250)|int(300)|int(400)|int(500)|int(550)|int(600)|string('ALERT')|string('CRITICAL')|string('DEBUG')|string('EMERGENCY')|string('ERROR')|string('INFO')|string('NOTICE')|string('WARNING')|string('alert')|string('critical')|string('debug')|string('emergency')|string('error')|string('info')|string('notice')|string('warning')`, but possibly received `enum(Monolog\Level)|int|string`.''' +count = 1 + +[[issues]] +file = "src/Monolog/BreadcrumbHandler.php" +code = "possibly-invalid-argument" +message = 'Possible argument type mismatch for argument #3 of `sentry\breadcrumb::__construct`: expected `string`, but possibly received `DateTimeImmutable|array|int|string`.' +count = 1 + +[[issues]] +file = "src/Monolog/BreadcrumbHandler.php" +code = "possibly-invalid-argument" +message = 'Possible argument type mismatch for argument #4 of `sentry\breadcrumb::__construct`: expected `null|string`, but possibly received `DateTimeImmutable|array|int|string`.' +count = 1 + +[[issues]] +file = "src/Monolog/BreadcrumbHandler.php" +code = "possibly-invalid-operand" +message = "Possibly invalid type for left operand." +count = 1 + +[[issues]] +file = "src/Monolog/BreadcrumbHandler.php" +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" +message = "Redundant `>=` comparison: left-hand side is always greater than or equal to right-hand side." +count = 1 + +[[issues]] +file = "src/Monolog/CompatibilityLogLevelTrait.php" +code = "redundant-condition" +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.' +count = 1 + +[[issues]] +file = "src/Monolog/CompatibilityProcessingHandlerTrait.php" +code = "redundant-comparison" +message = "Redundant `>=` comparison: left-hand side is always greater than or equal to right-hand side." +count = 1 + +[[issues]] +file = "src/Monolog/CompatibilityProcessingHandlerTrait.php" +code = "redundant-condition" +message = "This condition (type `true`) will always evaluate to true." +count = 1 + +[[issues]] +file = "src/Monolog/Handler.php" +code = "mixed-argument" +message = 'Invalid argument type for argument #1 of `Sentry\Event::setmessage`: expected `string`, but found `mixed`.' +count = 1 + +[[issues]] +file = "src/Monolog/Handler.php" +code = "mixed-argument" +message = 'Invalid argument type for argument #1 of `Sentry\Monolog\Handler::getmonologcontextdata`: expected `array`, but found `mixed`.' +count = 1 + +[[issues]] +file = "src/Monolog/Handler.php" +code = "mixed-argument" +message = 'Invalid argument type for argument #1 of `Sentry\Monolog\Handler::getmonologextradata`: expected `array`, but found `mixed`.' +count = 1 + +[[issues]] +file = "src/Monolog/Handler.php" +code = "mixed-argument" +message = '''Invalid argument type for argument #1 of `monolog\handler\abstracthandler::__construct`: expected `enum(Monolog\Level)|int(100)|int(200)|int(250)|int(300)|int(400)|int(500)|int(550)|int(600)|string('ALERT')|string('CRITICAL')|string('DEBUG')|string('EMERGENCY')|string('ERROR')|string('INFO')|string('NOTICE')|string('WARNING')|string('alert')|string('critical')|string('debug')|string('emergency')|string('error')|string('info')|string('notice')|string('warning')`, but found `mixed`.''' +count = 1 + +[[issues]] +file = "src/Monolog/Handler.php" +code = "mixed-argument" +message = 'Invalid argument type for argument #1 of `sentry\monolog\compatibilityprocessinghandlertrait::getseverityfromlevel`: expected `int`, but found `mixed`.' +count = 1 + +[[issues]] +file = "src/Monolog/Handler.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/Monolog/Handler.php" +code = "mixed-assignment" +message = "Assigning `mixed` type to a variable may lead to unexpected behavior." +count = 2 + +[[issues]] +file = "src/Monolog/LogsHandler.php" +code = "mixed-argument" +message = "Invalid argument type for argument #1 of `array_merge`: expected `array`, but found `mixed`." +count = 1 + +[[issues]] +file = "src/Monolog/LogsHandler.php" +code = "mixed-argument" +message = 'Invalid argument type for argument #1 of `sentry\monolog\compatibilitylogleveltrait::getsentryloglevelfrommonologlevel`: expected `int`, but found `mixed`.' +count = 2 + +[[issues]] +file = "src/Monolog/LogsHandler.php" +code = "mixed-argument" +message = 'Invalid argument type for argument #2 of `Sentry\Logs\LogsAggregator::add`: expected `string`, but found `mixed`.' +count = 1 + +[[issues]] +file = "src/Monolog/LogsHandler.php" +code = "mixed-argument" +message = "Invalid argument type for argument #2 of `array_merge`: expected `array`, but found `mixed`." +count = 1 + +[[issues]] +file = "src/Monolog/LogsHandler.php" +code = "mixed-operand" +message = "Left operand in `>=` comparison has `mixed` type." +count = 2 + +[[issues]] +file = "src/Options.php" +code = "deprecated-method" +message = 'Call to deprecated method: `Sentry\Options::getenabletracing`.' +count = 3 + +[[issues]] +file = "src/Options.php" +code = "mixed-assignment" +message = "Assigning `mixed` type to a variable may lead to unexpected behavior." +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-operand" +message = "Right operand in `||` operation has `mixed` type." +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::getbeforebreadcrumbcallback`. Saw type `mixed`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::getbeforesendcallback`. Saw type `mixed`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::getbeforesendcheckincallback`. Saw type `mixed`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::getbeforesendlogcallback`. Saw type `mixed`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::getbeforesendmetricscallback`. Saw type `mixed`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::getbeforesendtransactioncallback`. Saw type `mixed`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::getclassserializers`. Saw type `mixed`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::getcontextlines`. Saw type `mixed`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::getdsn`. Saw type `mixed`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::getenablelogs`. Saw type `nonnull`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::getenabletracing`. Saw type `mixed`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::getenvironment`. Saw type `mixed`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::geterrortypes`. Saw type `nonnull`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::gethttpclient`. Saw type `mixed`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::gethttpconnecttimeout`. Saw type `mixed`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::gethttpproxy`. Saw type `mixed`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::gethttpproxyauthentication`. Saw type `mixed`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::gethttpsslnativeca`. Saw type `mixed`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::gethttpsslverifypeer`. Saw type `mixed`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::gethttptimeout`. Saw type `mixed`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::getignoreexceptions`. Saw type `mixed`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::getignoretransactions`. Saw type `mixed`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::getinappexcludedpaths`. Saw type `mixed`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::getinappincludedpaths`. Saw type `mixed`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::getintegrations`. Saw type `mixed`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::getlogger`. Saw type `mixed`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::getmaxbreadcrumbs`. Saw type `mixed`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::getmaxrequestbodysize`. Saw type `mixed`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::getmaxvaluelength`. Saw type `mixed`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::getorgid`. Saw type `mixed`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::getprefixes`. Saw type `mixed`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::getrelease`. Saw type `mixed`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::getsamplerate`. Saw type `mixed`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::getservername`. Saw type `mixed`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::getspotlighturl`. Saw type `mixed`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::gettags`. Saw type `mixed`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::gettracepropagationtargets`. Saw type `mixed`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::gettracessampler`. Saw type `mixed`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::gettracessamplerate`. Saw type `mixed`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::gettransport`. Saw type `mixed`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::hasdefaultintegrations`. Saw type `mixed`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::ishttpcompressionenabled`. Saw type `mixed`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::isstricttracepropagationenabled`. Saw type `mixed`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::shouldattachmetriccodelocations`. Saw type `mixed`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::shouldattachstacktrace`. Saw type `mixed`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::shouldcapturesilencederrors`. Saw type `mixed`.' +count = 1 + +[[issues]] +file = "src/Options.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `sentry\options::shouldsenddefaultpii`. Saw type `mixed`.' +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 = 52 + +[[issues]] +file = "src/Profiling/Profile.php" +code = "invalid-method-access" +message = "Attempting to access a method on a non-object type (`unknown-ref(ExcimerLog)`)." +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, '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{}|non-empty-list>}, 'release': string, 'runtime': array{'name': string, 'sapi': null|string, 'version': null|string}, 'timestamp': 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 = "less-specific-nested-return-statement" +message = '''Returned type `array{}|non-empty-list` is less specific than the declared return type `array}>` for function `sentry\profiling\profile::preparestacks` due to nested 'mixed'.''' +count = 1 + +[[issues]] +file = "src/Profiling/Profile.php" +code = "mixed-assignment" +message = "Assigning `mixed` type to a variable may lead to unexpected behavior." +count = 2 + +[[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 = "non-existent-class-like" +message = "Class, Interface, or Trait `ExcimerLogEntry` does not exist." +count = 5 + +[[issues]] +file = "src/Profiling/Profile.php" +code = "non-existent-method" +message = "Method `gettimestamp` does not exist on type `ExcimerLogEntry`." +count = 1 + +[[issues]] +file = "src/Profiling/Profile.php" +code = "non-existent-method" +message = "Method `gettrace` does not exist on type `ExcimerLogEntry`." +count = 1 + +[[issues]] +file = "src/Profiling/Profile.php" +code = "possibly-invalid-iterator" +message = "The expression provided to `foreach` (type `array}>|unknown-ref(ExcimerLog)`) might not be iterable at runtime." +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`." +count = 1 + +[[issues]] +file = "src/Serializer/AbstractSerializer.php" +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" +message = "Invalid type `scalar` for middle operand in string concatenation." +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`." +count = 1 + +[[issues]] +file = "src/Serializer/AbstractSerializer.php" +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" +message = "Right operand in `!=` comparison is `null`." +count = 1 + +[[issues]] +file = "src/Serializer/AbstractSerializer.php" +code = "possibly-null-operand" +message = "Left operand in `!=` comparison might be `null` (type `null|string`)." +count = 1 + +[[issues]] +file = "src/Serializer/AbstractSerializer.php" +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/EnvelopItems/CheckInItem.php" +code = "possible-method-access-on-null" +message = "Attempting to call a method on `null`." +count = 1 + +[[issues]] +file = "src/Serializer/EnvelopItems/EventItem.php" +code = "deprecated-method" +message = 'Call to deprecated method: `Sentry\UserDataBag::getsegment`.' +count = 1 + +[[issues]] +file = "src/Serializer/EnvelopItems/EventItem.php" +code = "mixed-array-assignment" +message = "Unsafe array assignment on type `mixed`." +count = 1 + +[[issues]] +file = "src/Serializer/EnvelopItems/EventItem.php" +code = "possibly-null-argument" +message = 'Argument #1 of method `sentry\util\str::vsprintfornull` is possibly `null`, but parameter type `string` does not accept it.' +count = 1 + +[[issues]] +file = "src/Serializer/EnvelopItems/ProfileItem.php" +code = "mixed-assignment" +message = "Assigning `mixed` type to a variable may lead to unexpected behavior." +count = 1 + +[[issues]] +file = "src/Serializer/EnvelopItems/TransactionItem.php" +code = "deprecated-method" +message = 'Call to deprecated method: `Sentry\UserDataBag::getsegment`.' +count = 1 + +[[issues]] +file = "src/Serializer/EnvelopItems/TransactionItem.php" +code = "invalid-return-statement" +message = '''Invalid return type for function `sentry\serializer\envelopitems\transactionitem::serializespan`: expected `array{'_metrics_summary'?: array, 'data'?: array, 'description'?: string, 'op'?: string, 'parent_span_id'?: string, 'span_id': string, 'start_timestamp': float, 'status'?: string, 'tags'?: array, 'timestamp'?: float, 'trace_id': string}`, but found `array{'data'?: array, 'description'?: null|string, 'op'?: null|string, 'origin': string, 'parent_span_id'?: string, 'span_id': string, 'start_timestamp': float, 'status'?: string, 'tags'?: array, 'timestamp'?: float|null, 'trace_id': string}`.''' +count = 1 + +[[issues]] +file = "src/Serializer/EnvelopItems/TransactionItem.php" +code = "mixed-assignment" +message = "Assigning `mixed` type to a variable may lead to unexpected behavior." +count = 1 + +[[issues]] +file = "src/Serializer/PayloadSerializer.php" +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" +message = '''Invalid return type for function `sentry\serializer\traits\breadcrumbseralizertrait::serializebreadcrumb`: expected `array{'category': string, 'data'?: object, 'level': string, 'message'?: string, 'timestamp': float, 'type': string}`, but found `array{'category': string, 'data'?: stdClass, 'level': string, 'message'?: null|string, 'timestamp': float, 'type': string}`.''' +count = 1 + +[[issues]] +file = "src/Serializer/Traits/StacktraceFrameSeralizerTrait.php" +code = "invalid-return-statement" +message = '''Invalid return type for function `sentry\serializer\traits\stacktraceframeseralizertrait::serializestacktraceframe`: expected `array{'abs_path'?: string, 'context_line'?: string, 'filename': string, 'function'?: string, 'in_app': bool, 'lineno': int, 'post_context'?: array, 'pre_context'?: array, 'raw_function'?: string, 'vars'?: array}`, but found `array{'abs_path'?: null|string, 'context_line'?: null|string, 'filename': string, 'function'?: null|string, 'in_app': bool, 'lineno': int, 'post_context'?: array, 'pre_context'?: array, 'raw_function'?: null|string, 'vars'?: array}`.''' +count = 1 + +[[issues]] +file = "src/Spotlight/SpotlightClient.php" +code = "impossible-condition" +message = "This condition (type `false`) will always evaluate to false." +count = 2 + +[[issues]] +file = "src/Spotlight/SpotlightClient.php" +code = "mixed-argument" +message = 'Invalid argument type for argument #1 of `sentry\httpclient\response::__construct`: expected `int`, but found `mixed`.' +count = 1 + +[[issues]] +file = "src/Spotlight/SpotlightClient.php" +code = "mixed-assignment" +message = "Assigning `mixed` type to a variable may lead to unexpected behavior." +count = 1 + +[[issues]] +file = "src/Spotlight/SpotlightClient.php" +code = "redundant-comparison" +message = "Redundant `<` comparison: left-hand side is never less than right-hand side." +count = 2 + +[[issues]] +file = "src/Stacktrace.php" +code = "impossible-condition" +message = "This condition (type `false`) will always evaluate to false." +count = 1 + +[[issues]] +file = "src/Stacktrace.php" +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" +message = '''Possible argument type mismatch for argument #1 of `Sentry\StacktraceBuilder::buildfrombacktrace`: expected `list, 'class'?: class-string, 'file'?: string, 'function'?: string, 'line'?: int, 'type'?: string}>`, but possibly received `array`.''' +count = 1 + +[[issues]] +file = "src/State/Hub.php" +code = "mixed-operand" +message = "Right operand in `<` comparison has `mixed` type." +count = 1 + +[[issues]] +file = "src/State/Hub.php" +code = "possibly-null-operand" +message = "Left operand in `<` comparison might be `null` (type `float|null`)." +count = 1 + +[[issues]] +file = "src/State/Scope.php" +code = "impossible-condition" +message = "This condition (type `false`) will always evaluate to false." +count = 2 + +[[issues]] +file = "src/State/Scope.php" +code = "mixed-property-type-coercion" +message = 'A value with a less specific type `array|non-empty-list<(callable(...mixed): mixed)>` is being assigned to property `$$eventProcessors` (array).' +count = 1 + +[[issues]] +file = "src/State/Scope.php" +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/State/Scope.php" +code = "redundant-comparison" +message = "Redundant `!==` comparison: left-hand side is always not identical to right-hand side." +count = 1 + +[[issues]] +file = "src/State/Scope.php" +code = "redundant-condition" +message = "This condition (type `true`) will always evaluate to true." +count = 1 + +[[issues]] +file = "src/State/Scope.php" +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 = 2 + +[[issues]] +file = "src/Tracing/DynamicSamplingContext.php" +code = "possible-method-access-on-null" +message = "Attempting to call a method on `null`." +count = 8 + +[[issues]] +file = "src/Tracing/DynamicSamplingContext.php" +code = "possibly-null-argument" +message = 'Argument #2 of method `Sentry\Tracing\DynamicSamplingContext::set` is possibly `null`, but parameter type `string` does not accept it.' +count = 4 + +[[issues]] +file = "src/Tracing/GuzzleTracingMiddleware.php" +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" +message = "Argument #2 of function `in_array` is possibly `null`, but parameter type `array` does not accept it." +count = 1 + +[[issues]] +file = "src/Tracing/PropagationContext.php" +code = "redundant-comparison" +message = "Redundant `!==` comparison: left-hand side is always not identical to right-hand side." +count = 1 + +[[issues]] +file = "src/Tracing/PropagationContext.php" +code = "redundant-condition" +message = "This condition (type `true`) will always evaluate to true." +count = 1 + +[[issues]] +file = "src/Tracing/PropagationContext.php" +code = "write-only-property" +message = "Property `$parentSampled` is written to but never read." +count = 1 + +[[issues]] +file = "src/Tracing/Traits/TraceHeaderParserTrait.php" +code = "invalid-type-cast" +message = "Non numeric string of type `string` implicitly cast to `float`." +count = 5 + +[[issues]] +file = "src/Tracing/Traits/TraceHeaderParserTrait.php" +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" +message = 'Invalid return type for function `sentry\tracing\transaction::getdynamicsamplingcontext`: expected `Sentry\Tracing\DynamicSamplingContext`, but found `Sentry\Tracing\DynamicSamplingContext|null`.' +count = 1 + +[[issues]] +file = "src/Tracing/Transaction.php" +code = "nullable-return-statement" +message = 'Function `sentry\tracing\transaction::getdynamicsamplingcontext` is declared to return `Sentry\Tracing\DynamicSamplingContext` but possibly returns a nullable value (inferred as `Sentry\Tracing\DynamicSamplingContext|null`).' +count = 1 + +[[issues]] +file = "src/Transport/HttpTransport.php" +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" +message = "Attempting to call a method on `null`." +count = 2 + +[[issues]] +file = "src/Transport/HttpTransport.php" +code = "possibly-null-operand" +message = 'Possibly null left operand used in string concatenation (type `Sentry\Severity|null`).' +count = 2 + +[[issues]] +file = "src/UserDataBag.php" +code = "deprecated-method" +message = 'Call to deprecated method: `Sentry\UserDataBag::setsegment`.' +count = 2 + +[[issues]] +file = "src/UserDataBag.php" +code = "impossible-condition" +message = "This condition (type `false`) will always evaluate to false." +count = 1 + +[[issues]] +file = "src/UserDataBag.php" +code = "mixed-argument" +message = 'Invalid argument type for argument #1 of `Sentry\UserDataBag::setemail`: expected `null|string`, but found `mixed`.' +count = 1 + +[[issues]] +file = "src/UserDataBag.php" +code = "mixed-argument" +message = 'Invalid argument type for argument #1 of `Sentry\UserDataBag::setid`: expected `int|null|string`, but found `mixed`.' +count = 1 + +[[issues]] +file = "src/UserDataBag.php" +code = "mixed-argument" +message = 'Invalid argument type for argument #1 of `Sentry\UserDataBag::setipaddress`: expected `null|string`, but found `mixed`.' +count = 1 + +[[issues]] +file = "src/UserDataBag.php" +code = "mixed-argument" +message = 'Invalid argument type for argument #1 of `Sentry\UserDataBag::setsegment`: expected `null|string`, but found `mixed`.' +count = 1 + +[[issues]] +file = "src/UserDataBag.php" +code = "mixed-argument" +message = 'Invalid argument type for argument #1 of `Sentry\UserDataBag::setusername`: expected `null|string`, but found `mixed`.' +count = 1 + +[[issues]] +file = "src/UserDataBag.php" +code = "mixed-assignment" +message = "Assigning `mixed` type to a variable may lead to unexpected behavior." +count = 1 + +[[issues]] +file = "src/UserDataBag.php" +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/UserDataBag.php" +code = "redundant-logical-operation" +message = "Redundant `&&` operation: left operand is evaluated and right operand is always falsy." +count = 1 + +[[issues]] +file = "src/UserDataBag.php" +code = "redundant-type-comparison" +message = "Redundant type assertion: `$id` of type `int` is always not `int`." +count = 1 + +[[issues]] +file = "src/Util/Arr.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/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" +message = "Assigning `mixed` type to a variable may lead to unexpected behavior." +count = 3 + +[[issues]] +file = "src/Util/Arr.php" +code = "mixed-operand" +message = "Invalid left operand: type `mixed` cannot be reliably used in string concatenation." +count = 1 + +[[issues]] +file = "src/Util/Arr.php" +code = "mixed-operand" +message = "Invalid right operand: type `mixed` cannot be reliably used in string concatenation." +count = 1 + +[[issues]] +file = "src/Util/JSON.php" +code = "falsable-return-statement" +message = '''Function `sentry\util\json::encode` is declared to return `string` but possibly returns 'false' (inferred as `false|non-empty-string`).''' +count = 1 + +[[issues]] +file = "src/Util/JSON.php" +code = "invalid-return-statement" +message = 'Invalid return type for function `sentry\util\json::encode`: expected `string`, but found `false|non-empty-string`.' +count = 1 + +[[issues]] +file = "src/Util/JSON.php" +code = "mixed-assignment" +message = "Assigning `mixed` type to a variable may lead to unexpected behavior." +count = 1 + +[[issues]] +file = "src/Util/Str.php" +code = "avoid-catching-error" +message = "Avoid catching 'Error' class instances." +count = 1 + +[[issues]] +file = "src/Util/Str.php" +code = "impossible-condition" +message = "Redundant ternary operator: condition is always falsy." +count = 1 + +[[issues]] +file = "src/Util/Str.php" +code = "redundant-comparison" +message = "Redundant `===` comparison: left-hand side is never identical to right-hand side." +count = 1 + +[[issues]] +file = "src/functions.php" +code = "mixed-assignment" +message = "Assigning `mixed` type to a variable may lead to unexpected behavior." +count = 1 diff --git a/composer.json b/composer.json index b3878c9acb..2ef87fc904 100644 --- a/composer.json +++ b/composer.json @@ -32,6 +32,7 @@ "symfony/options-resolver": "^4.4.30|^5.0.11|^6.0|^7.0|^8.0" }, "require-dev": { + "carthage-software/mago": "^1.13.3", "friendsofphp/php-cs-fixer": "^3.4", "guzzlehttp/promises": "^2.0.3", "guzzlehttp/psr7": "^1.8.4|^2.1.1", @@ -68,13 +69,16 @@ "@cs-check", "@phpstan", "@psalm", + "@mago", "@tests" ], "tests": "vendor/bin/phpunit --verbose", "cs-check": "vendor/bin/php-cs-fixer fix --verbose --diff --dry-run", "cs-fix": "vendor/bin/php-cs-fixer fix --verbose --diff", "phpstan": "vendor/bin/phpstan analyse", - "psalm": "vendor/bin/psalm" + "psalm": "vendor/bin/psalm", + "mago": "vendor/bin/mago --config=mago.toml analyze", + "mago-php72": "vendor/bin/mago --config=mago.toml --php-version=7.2 --allow-unsupported-php-version analyze" }, "config": { "sort-packages": true diff --git a/mago.toml b/mago.toml new file mode 100644 index 0000000000..d1b63f09d7 --- /dev/null +++ b/mago.toml @@ -0,0 +1,11 @@ +[source] +paths = ["src"] +includes = ["vendor"] +excludes = [ + "tests/resources/**", + "tests/Fixtures/**", + "src/Util/ClockMock.php", +] + +[analyzer] +baseline = "analysis-baseline.toml" diff --git a/src/Serializer/EnvelopItems/TransactionItem.php b/src/Serializer/EnvelopItems/TransactionItem.php index 9eb8eab226..cfabaa114a 100644 --- a/src/Serializer/EnvelopItems/TransactionItem.php +++ b/src/Serializer/EnvelopItems/TransactionItem.php @@ -144,7 +144,7 @@ public static function toEnvelopeItem(Event $event): string * description?: string, * op?: string, * data?: array, - * tags?: array + * tags?: array, * _metrics_summary?: array * } */ diff --git a/src/Util/PHPVersion.php b/src/Util/PHPVersion.php index 3f0394b6a4..c388070346 100644 --- a/src/Util/PHPVersion.php +++ b/src/Util/PHPVersion.php @@ -22,6 +22,7 @@ final class PHPVersion */ public static function parseVersion(string $version = \PHP_VERSION): string { + $matches = []; if (!preg_match(self::VERSION_PARSING_REGEX, $version, $matches)) { return $version; } diff --git a/src/functions.php b/src/functions.php index 02b32c430b..e37572a5ad 100644 --- a/src/functions.php +++ b/src/functions.php @@ -286,6 +286,7 @@ function trace(callable $trace, SpanContext $context) { return SentrySdk::getCurrentHub()->withScope(static function (Scope $scope) use ($context, $trace) { $parentSpan = $scope->getSpan(); + $span = null; // If there is a span set on the scope and it's sampled there is an active transaction. // If that is the case we create the child span and set it on the scope. @@ -299,7 +300,7 @@ function trace(callable $trace, SpanContext $context) try { return $trace($scope); } finally { - if (isset($span)) { + if ($span !== null) { $span->finish(); $scope->setSpan($parentSpan); @@ -322,7 +323,7 @@ function getTraceparent(): string if ($client !== null) { $options = $client->getOptions(); - if ($options !== null && $options->isTracingEnabled()) { + if ($options->isTracingEnabled()) { $span = SentrySdk::getCurrentHub()->getSpan(); if ($span !== null) { return $span->toTraceparent(); @@ -365,7 +366,7 @@ function getBaggage(): string if ($client !== null) { $options = $client->getOptions(); - if ($options !== null && $options->isTracingEnabled()) { + if ($options->isTracingEnabled()) { $span = SentrySdk::getCurrentHub()->getSpan(); if ($span !== null) { return $span->toBaggage(); From aa834b08fde99fb9b7f51faf5910d99849979e74 Mon Sep 17 00:00:00 2001 From: Martin Linzmayer Date: Wed, 4 Mar 2026 16:27:24 +0100 Subject: [PATCH 2/2] fix --- composer.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 2ef87fc904..9141de4ace 100644 --- a/composer.json +++ b/composer.json @@ -77,8 +77,7 @@ "cs-fix": "vendor/bin/php-cs-fixer fix --verbose --diff", "phpstan": "vendor/bin/phpstan analyse", "psalm": "vendor/bin/psalm", - "mago": "vendor/bin/mago --config=mago.toml analyze", - "mago-php72": "vendor/bin/mago --config=mago.toml --php-version=7.2 --allow-unsupported-php-version analyze" + "mago": "vendor/bin/mago --config=mago.toml analyze" }, "config": { "sort-packages": true