You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 31cc5e2
Browse filesBrowse the repository at this point in the historyBrowse files
fix(diagnostics): resolve literal types for argument type checking
Fixes#180 — string/int/float literal expressions passed as arguments
are now narrowed to their precise literal type (e.g. `'desc'` becomes
`PhpType::Literal("'desc'")`) instead of the widened base type
(`string`). This allows literal values to correctly match PHPDoc
literal-union parameter types like `'asc'|'desc'`.
Also fixes `is_string_subtype()` and `is_int_subtype()` to handle
`PhpType::Union` — a union of string/int literals (e.g.
`'asc'|'desc'`) is now recognised as a string/int subtype, allowing
PHPDoc `@param` annotations with literal unions to properly override
native scalar type hints.
The narrowing is applied only in the diagnostic argument-collection
path (not in general variable resolution) to avoid changing inferred
types for array shapes and list element tracking.
Includes 8 new integration tests covering correct and incorrect
string, integer, and float literals against literal-union parameters,
plus precise numeric-string checking (`'42'` passes, `'hello'` is
flagged).
Closes#180
Signed-off-by: Anders Jenbo <[email protected]>
Copy file name to clipboardExpand all lines: docs/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
31
31
32
32
### Fixed
33
33
34
+
-**Literal type matching in argument diagnostics.** String, integer, and float literal arguments now match PHPDoc literal-union parameter types. For example, `orderBy('id', 'desc')` no longer produces a bogus error when the parameter is typed as `'asc'|'desc'`. Conversely, passing a provably wrong literal (e.g. `'invalid'` to `'asc'|'desc'`, or `'hello'` to `numeric-string`) is now correctly flagged. Fixes #180. Contributed by @calebdw in https://github.com/PHPantom-dev/phpantom_lsp/pull/191.
34
35
-**Type Hierarchy works in more clients.** The `textDocument/prepareTypeHierarchy` capability was registered without registration options, so some clients (notably Zed) did not reliably expose the Type Hierarchy action. The dynamic registration now carries proper `TypeHierarchyRegistrationOptions` with a PHP document selector, so those clients recognise that the feature applies to PHP files. Contributed by @sidux in https://github.com/PHPantom-dev/phpantom_lsp/pull/179.
35
36
-**Extract method generates correct code for more selections.** A variable that the selection reads before it first assigns (for example a parameter the extracted code both consults and updates) is now passed in as an argument as well as returned, instead of being left undefined inside the new method. And an early `return` whose value references a variable defined inside the selection is now kept inside the extracted method and propagated to the caller, instead of being copied to the call site where that variable does not exist.
36
37
- **The editor stays responsive during fast typing in large files.** Editors send a burst of requests on every keystroke (completion, a documentation lookup for each suggestion, diagnostics, code lens, semantic highlighting, and more). The server processed only a few at a time, so during continuous typing the burst backed up until the server stopped answering anything at all, including the completion the user was waiting on, and it only recovered after a restart. Now the burst is processed concurrently and every expensive request runs off the main loop: diagnostics (which re-analyze the whole file on each edit) compute in the background instead of on the request that asked for them, so a diagnostic pull returns immediately and never blocks the threads that deliver completion and hover, and repeated whole-file requests (semantic highlighting, code lens, the document outline, folding, document links) are collapsed so a fast typist's superseded requests no longer pile up and monopolize the CPU. Completion and other requests keep coming back while you type.
0 commit comments