Skip to content

ref(tracing): Drop Transaction::$transaction redeclaration to remove Mago baseline entry - #2398

Merged
Litarnus merged 1 commit into
masterfrom
ref/transaction-drop-transaction-property-override
Nov 19, 2026
Merged

Litarnus merged 1 commit into
masterfrom
ref/transaction-drop-transaction-property-override

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Removes this Mago baseline entry from analysis-baseline.toml:

  • src/Tracing/Transaction.php · incompatible-property-type · Property Sentry\Tracing\Transaction::$transaction has an incompatible type declaration from docblock.

Transaction redeclared the protected $transaction property from Span only to narrow its docblock from Transaction|null to Transaction. A mutable property's docblock type cannot be narrowed in a child class, so Mago flags it. The narrowing was only needed for one call, DynamicSamplingContext::fromTransaction($this->transaction, ...) in getDynamicSamplingContext().

Transaction is final and its constructor sets $this->transaction = $this, which nothing else reassigns, so that call now passes $this directly and the redeclaration is dropped. The inherited Span::$transaction property is still set in the constructor, so getTransaction() and startChild() behave the same.

via automation sched_a59acc45df166a80a839d0b32321e740 · Run ID sched_a59acc45df166a80a839d0b32321e740:1795078800000.

--

View Session [Sentry]

@Litarnus
Litarnus marked this pull request as ready for review November 19, 2026 09:56
@Litarnus
Litarnus requested review from a team and stayallive as code owners November 19, 2026 09:56

@Litarnus Litarnus left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cannot just drop the property and still keep it assigned. This will make the property dynamic which is bad

@sentry-junior

sentry-junior Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for looking at this. I don't think the property becomes dynamic, though. Span still declares protected $transaction; at src/Tracing/Span.php:102, and Transaction extends Span. So $this->transaction = $this; in the Transaction constructor writes to the inherited declared property. It doesn't create a new one. The only thing this PR removes is the second declaration in the subclass, which existed only to narrow the docblock.

I checked this on this branch with PHP 8.4 and error_reporting=-1:

  • There's no Creation of dynamic property deprecation when constructing a Transaction.
  • ReflectionObject($transaction)->getProperty('transaction') is declared in Sentry\Tracing\Span with isDefault() === true. Dynamic properties report false there.
  • $transaction->getTransaction() === $transaction and $transaction->startChild(...)->getTransaction() === $transaction both still hold.

If you'd still rather keep the explicit redeclaration in Transaction, I'm happy to close this one and leave the baseline entry in place.

@Litarnus

Copy link
Copy Markdown
Collaborator

ok fair, I didn't read the description properly

@Litarnus
Litarnus merged commit 642bf38 into master Nov 19, 2026
60 checks passed
@Litarnus
Litarnus deleted the ref/transaction-drop-transaction-property-override branch November 19, 2026 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant