Skip to content

Commit 45f85ab

Browse files
committed
Duplicate forward-delimiter scanners
1 parent e04cf74 commit 45f85ab

8 files changed

Lines changed: 89 additions & 815 deletions

File tree

docs/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6464
- **Go-to-implementation and type hierarchy return the same results every time.** After the workspace finished indexing, these features listed only your project's implementing classes, but a class from a dependency could slip in if you happened to have viewed it earlier in the session, so the same query gave different results depending on what you'd looked at. Results are now consistently limited to your own code, matching what the workspace index actually covers.
6565
- **Blade files with raw `<?php ... ?>` tags no longer report false syntax errors.** PHP code embedded directly in a Blade template (outside `@php`/`@endphp`) is now recognized and passed through unmodified, so string literals that happen to start with `@` (e.g. a JSON-LD `'@context'` array key) are no longer misread as Blade directives.
6666
- **`@switch`/`@case` with a class-constant case value no longer reports a syntax error.** `@case (Some\Namespaced\Enum::VALUE)` now translates to a valid `case` arm instead of silently corrupting the rest of the file.
67-
- **Generated `@return` types infer the same rich type from multi-line array literals.** A function returning an array literal written across several lines now infers the precise type (for example `list<string>`) in its generated docblock, matching the single-line form. Previously breaking the literal onto multiple lines degraded the inferred type to `array<mixed>`.
67+
- **Generated return types and `@return` tags understand every kind of return expression, not just literals and variables.** Inferring a missing return type now resolves method/function calls, ternaries, matches, property access, and array literals split across multiple lines through the same type engine as hover, instead of degrading to `mixed` (or, for multi-line array literals, to a coarser `array<mixed>`) for anything beyond a simple literal, `new`, or a plain variable.
6868
- **Calls to functions declared in another `namespace` block of the same file resolve their return type.** In a file that declares more than one `namespace`, a call to a function from a later block used to leave the returned value untyped unless the function carried an `@return` docblock. The call and its return type now resolve regardless, so completion, hover, and diagnostics see the value's type.
6969

7070
## [0.9.0] - 2026-07-20

docs/todo/refactor.md

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -425,44 +425,4 @@ a neighbour, adding another divergent copy per action.
425425

426426
---
427427

428-
## `fix_return_type` re-implements expression type inference
429-
430-
**What to do.** `src/code_actions/phpstan/fix_return_type.rs` contains
431-
a parallel, text-based type inferencer: `infer_return_type` scans body
432-
lines as strings, and `infer_type_from_literal` /
433-
`infer_array_literal_type` / `split_array_elements` /
434-
`find_top_level_arrow` re-derive array-literal and `new ClassName`
435-
types from source text. Only the `$variable` case defers to the shared
436-
pipeline. This is the "lightweight parallel resolver" the conventions
437-
forbid. Route the array/`new`/expression cases through
438-
`resolve_rhs_expression` (the AST is already parsed and cached in both
439-
`handle_code_action` and `resolve_code_action`, so there is no
440-
performance excuse). Audit `phpstan/add_iterable_type.rs::
441-
infer_iterable_element_type` for the same pattern while there.
442-
443-
**Why it matters.** Direct violation of the single-pipeline rule:
444-
every inference improvement (shapes, generics, literals) silently
445-
misses this code action, and its answers can contradict hover.
446-
447-
---
448-
449-
## Duplicate forward-delimiter scanners in `text_scan.rs`
450-
451-
**What to do.** `src/text_scan.rs` now hosts two near-identical
452-
forward delimiter-matching scanners side by side:
453-
`find_matching_delimiter_forward` (skips string literals only; single
454-
consumer, `completion/source/throws_analysis/scanning.rs`) and
455-
`find_matching_forward` (skips string literals *and* both PHP comment
456-
styles; many consumers). Determine whether the
457-
`throws_analysis/scanning.rs` call site can safely move to the
458-
comment-aware `find_matching_forward` (check whether it is a
459-
performance-sensitive hot path first, since the comment-unaware
460-
version is cheaper), and delete whichever scanner becomes redundant.
461-
462-
**Why it matters.** Two scanners answering "find the matching closing
463-
delimiter" invite a fix (e.g. a heredoc-awareness bug) to land in one
464-
copy and not the other.
465-
466-
---
467-
468428

0 commit comments

Comments
 (0)