Repository navigation
refactor(trace): report source as a single trimmed line - #6
Conversation
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.
🏹 Robin✅ Review done. I flagged 1 thing worth a look. Push fixes whenever you like, then comment |
There was a problem hiding this comment.
🏹 Robin
Heads up: this is a point-in-time review. Push fixes freely, then comment
/robinwhenever 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.
Summary
Reduce the trace's source context to a single
sourcestring: the source line at the reportedline, trimmed of surrounding whitespace. The{start, end, code}object, the ±3 window, and theSourceBlockDTO are removed.The surrounding lines proved unhelpful and the nested object read poorly in JSON.
Changes
sourceis now a plain string on the origin and every frame; unavailable source is still omitted.Snafu\Document\SourceBlock;SourceContext::window()becameSourceContext::line(): ?string.Frame::$sourceandProblem::$sourceare?string.utf8_failurefixture onto the throw line, since that line is now the only source captured.Verification
composer run verifypasses: format, lint, analyze, and 96 tests at 100% coverage.