Skip to content

refactor(trace): report source as a single trimmed line - #6

Merged
shadowhand merged 1 commit into
mainfrom
refactor/trace-source-line
Oct 1, 2026
Merged

shadowhand merged 1 commit into
mainfrom
refactor/trace-source-line

Conversation

@shadowhand

Copy link
Copy Markdown
Owner

Summary

Reduce the trace's source context to a single source string: the source line at the reported line, trimmed of surrounding whitespace. The {start, end, code} object, the ±3 window, and the SourceBlock DTO are removed.

The surrounding lines proved unhelpful and the nested object read poorly in JSON.

Changes

  • source is now a plain string on the origin and every frame; unavailable source is still omitted.
  • Deleted Snafu\Document\SourceBlock; SourceContext::window() became SourceContext::line(): ?string.
  • Frame::$source and Problem::$source are ?string.
  • Updated the spec, README, changelog, and tests.
  • Moved the invalid UTF-8 bytes in the utf8_failure fixture onto the throw line, since that line is now the only source captured.

Verification

composer run verify passes: format, lint, analyze, and 96 tests at 100% coverage.

Replace the `{start, end, code}` source block with a single `source` string: the source line at the reported line, trimmed of surrounding whitespace. The ±3 window and the `SourceBlock` DTO are removed.

Update the spec, README, changelog, and tests to match.
@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

🏹 Robin

✅ Review done. I flagged 1 thing worth a look.

Push fixes whenever you like, then comment /robin for another pass.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🏹 Robin

Heads up: this is a point-in-time review. Push fixes freely, then comment /robin whenever you want another pass.

🚨 1 High

Summary

The changes represent a refactor from a block-based source context to a single trimmed line source. The implementation appears consistent, with updated documentation, specs, and code across the project. However, a critical validation issue was introduced in the SourceContext::line method, removing essential line number checks and potentially causing incorrect line retrieval. This oversight must be addressed to maintain correctness.


Robin — the Robin Hood of code review. Free for every PR.

Comment thread src/Trace/SourceContext.php Resolved
@shadowhand
shadowhand merged commit e2f5ad4 into main Oct 1, 2026
3 checks passed
@shadowhand
shadowhand deleted the refactor/trace-source-line branch October 1, 2026 16:56
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