0.2.4#11
Merged
Merged
Conversation
An EOF-anchored syntax error (unterminated comment, "unexpected EOF")
made the server emit a diagnostic whose range end was one character past
end-of-document: nikic reports a 1-based BYTE `endColumn` of
`lineLength + 1` at EOF, which `buildParseErrorDiagnostic` used verbatim.
A strict LSP annotator (PhpStorm) throws `Range must be inside element
being annotated` when asked to render that range mid-edit, poisoning the
diagnostics provider for the rest of the session.
Clamp every emitted range into the analyzed buffer:
- PositionMap gains `clampPosition` / `clampRange` primitives (UTF-16
aware, reusing the extracted `lineUtf16Length`).
- `Analyzer::buildParseErrorDiagnostic` clamps at the source so the
internal Diagnostic is never out of bounds.
- `XphpDiagnosticsProvider` clamps at the wire boundary via a cached
PositionMap (`toLspClamped`) as defense-in-depth across parse,
undefined-name, and workspace diagnostics. `DiagnosticTranslator`
stays pure.
Why it escaped: nothing asserted that emitted ranges stay within
document bounds, and the Behat "underlines" step routed through
`positionToOffset`, which silently clamps past-EOL. Adds the
`AssertsRangeWithinDocument` invariant (proven to fail pre-fix on the
EOF cases), PositionMap clamp + characterization tests, a provider-level
wire test, and a Behat bounds step + unterminated-comment scenario.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Release 0.2.4. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Hovering a property accessed through a generic receiver showed the raw
declared type parameter (`public A $first`) instead of the concrete type,
even though the variable-inference path already computed the substituted
type (the assigned `$x = $pair->first` hover showed `Pair<Plastic, User>`).
Wire the existing substitution into the member-hover path:
- GenericResolver gains `resolvePropertyTypeAt`, which finds the
PropertyFetch at the cursor and renders its substituted type via the
existing `resolvePropertyFetch` (same machinery the assignment-tracking
path uses -- no new substitution logic).
- PhpHoverResolver passes that type into `renderProperty`, which prefers
it over `prettify(inferredType)` and falls back cleanly when the
receiver isn't a tracked generic instantiation.
Now `$nested->swap()->first` hovers as
`public App\...\Pair<App\...\Plastic, App\...\User> $first`, matching the
LHS-variable hover. Covers the direct-receiver and chained-method-call
cases with tests.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
End-to-end scenarios through the real hover handler: a property accessed through a direct generic receiver (`$pair->first` on `Pair<Plastic, User>`) and through a chained generic method call (`$nested->swap()->first`) both hover with the substituted concrete type instead of the raw type-param `A`. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.