Skip to content

Commit de55c37

Browse files
committed
Upgrade Mago to 1.44.0
1 parent 280c500 commit de55c37

5 files changed

Lines changed: 82 additions & 51 deletions

File tree

Cargo.lock

Lines changed: 20 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ sqlparser = "0.62"
1818
tracing = "0.1"
1919
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
2020
tokio = { version = "1.39", features = ["full"] }
21-
mago-syntax = "=1.43.0"
22-
mago-allocator = "=1.43.0"
23-
mago-database = "=1.43.0"
21+
mago-syntax = "=1.44.0"
22+
mago-allocator = "=1.44.0"
23+
mago-database = "=1.44.0"
2424
mago-docblock = "=1.42.0"
25-
mago-names = "=1.43.0"
26-
mago-span = "=1.43.0"
25+
mago-names = "=1.44.0"
26+
mago-span = "=1.44.0"
2727
mago-type-syntax = "=1.42.0"
28-
mago-formatter = { version = "=1.43.0", features = ["serde"] }
29-
mago-php-version = "=1.43.0"
30-
mago-composer = "=1.43.0"
28+
mago-formatter = { version = "=1.44.0", features = ["serde"] }
29+
mago-php-version = "=1.44.0"
30+
mago-composer = "=1.44.0"
3131
ignore = "0.4"
3232
globset = "0.4"
3333
regex = "1"

docs/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5858

5959
### Fixed
6060

61+
- **Formatting a short method chain starting with `new X(...)` no longer breaks it across lines unnecessarily.** When the constructor call's own arguments were long enough to wrap, the formatter also forced a short trailing chain like `(new Foo(...))->bar()` onto separate lines even though it would have fit on one. Upstream fix from mago 1.44.0.
6162
- **`@method` and `@property` tags on an implemented interface are now always applied.** A class that declared no docblock of its own missed the magic methods and properties its interfaces declared, so they did not complete, hover, or resolve, and calls to them were reported as unknown members. Tags on an interface (and on the interfaces it extends) are now picked up regardless of what the implementing class documents.
6263
- **Find References, Rename, and Go to Implementation no longer look stalled during startup indexing.** A search started while the background index is still parsing the workspace waits for that index to finish, since acting on a partial index would silently miss results. That wait now shows in the request's own progress bar as "Waiting for workspace index" alongside the index's live file counts, instead of sitting at "Resolving…" with no indication of what it is waiting for.
6364
- **Type narrowing against `@phpstan-assert`/`@psalm-assert` no longer leaks memory.** Evaluating a narrowing call such as `Assert::isInstanceOf($x, Foo::class)` or a custom function/method with the same annotations allocated a small amount of memory that was never freed. This ran on every conditional touched during completion, hover, diagnostics, and go-to-definition, so memory held by a long-running editor session grew slowly but permanently the more the project was edited. Fixed by no longer leaking the allocation.

docs/todo.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ unlikely to move the needle for most users.
195195
| E6 | Stub install prompt for non-Composer projects | Low | Low |
196196
| E7 | [Stub-based framework patches](todo/external-stubs.md#e7-stub-based-framework-patches) | Medium | Medium |
197197
| | **[Performance](todo/performance.md)** | | |
198-
| P29 | [Migrate to `mago-phpdoc-syntax`](todo/performance.md#p29-migrate-to-mago-phpdoc-syntax) (drop deprecated `mago-docblock` / `mago-type-syntax`) | Medium | Medium |
198+
| P29 | [Migrate to `mago-phpdoc-syntax`](todo/performance.md#p29-migrate-to-mago-phpdoc-syntax) (drop deprecated `mago-docblock` / `mago-type-syntax`; sequenced behind P30) | Medium | High |
199199
| P30 | [Evaluate migrating parse/resolve/docblock pipeline to `mago-hir`](todo/performance.md#p30-evaluate-migrating-parseresolvedocblock-pipeline-to-mago-hir) (blocked on upstream API stabilizing — see triggers) | Medium-High | High |
200200
| P43 | [`init_single_project` is the longest single-threaded stretch of a run](todo/performance.md#p43-init_single_project-is-the-longest-single-threaded-stretch-of-a-run) | Medium-High | Medium |
201201
| P16 | [Pre-parsed stub format (eliminate raw PHP embedding)](todo/performance.md#p16-pre-parsed-stub-format-eliminate-raw-php-embedding) | High | Medium-High |

docs/todo/performance.md

Lines changed: 52 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -680,33 +680,63 @@ body-return inference, since fixed by memoization).
680680

681681
## P29. Migrate to `mago-phpdoc-syntax`
682682

683-
**Impact: Medium · Effort: Medium**
683+
**Impact: Medium · Effort: High**
684684

685685
As of the 1.42/1.43 mago releases, `mago-docblock` and
686686
`mago-type-syntax` are both deprecated and frozen at 1.42.0. Upstream
687687
folded them into a single unified crate, `mago-phpdoc-syntax`, which
688688
parses docblock comments and their embedded type and constant
689-
expressions in one pass and is meant to replace both. The deprecation
690-
notices point at `mago_phpdoc_syntax::PHPDocParser` (for
691-
`parse_phpdoc_with_span`) and `mago_phpdoc_syntax::parse_type` (for
692-
`parse_str`).
693-
694-
We currently call the deprecated functions at four sites, each wrapped
695-
in `#[allow(deprecated)]`:
696-
697-
- `src/docblock/parser.rs``mago_docblock::parse_phpdoc_with_span`
698-
- `src/php_type.rs``mago_type_syntax::parse_str` (type-string parse
699-
and the round-trip test helper)
700-
- `src/symbol_map/docblock.rs``mago_type_syntax::parse_str`
701-
702-
`mago-phpdoc-syntax` first shipped at 1.44.0, so this migration is
703-
coupled to bumping the rest of the mago toolchain from 1.43.0 to
704-
1.44.0 (mixing 1.43 and 1.44 would pull two incompatible copies of the
705-
shared `mago-span` types). Do the version bump and the API migration
706-
together, drop `mago-docblock` and `mago-type-syntax` from
707-
`Cargo.toml`, and remove the `#[allow(deprecated)]` wrappers. The
708-
unified single-pass parser should also be a small win on the docblock
709-
parse hot path.
689+
expressions in one pass and is meant to replace both.
690+
691+
This is **not** a same-shaped API rename. The deprecation notices
692+
point at `mago_phpdoc_syntax::PHPDocParser` (replacing
693+
`parse_phpdoc_with_span`) and `mago_phpdoc_syntax::parse_type`
694+
(replacing `parse_str`), but the new crate produces a fundamentally
695+
different CST: the old flat `mago_docblock::document::{Document, Tag,
696+
TagKind}` (one enum with `tags_by_kind(TagKind::X)` lookups) is
697+
replaced by a `TagValue` enum with ~60 per-tag-kind structs
698+
(`ThrowsTagValue`, `TemplateTagValue`, `ParamTagValue`, ...), and
699+
`mago_type_syntax::cst::Type` (69 variants) is replaced by an equally
700+
restructured type CST. Confirmed by reading both crate sources
701+
directly rather than relying on docs.rs.
702+
703+
Grepping for `mago_docblock`/`mago_type_syntax` usage turns up far
704+
more than the three call sites in the old writeup — at last count 14
705+
files, including the core of the shared type engine
706+
(`src/php_type/mod.rs`, `src/php_type/parse.rs` build `PhpType` off
707+
`mago_type_syntax::cst::Type` directly) and every consumer that
708+
filters tags by `TagKind` (`src/docblock/tags.rs`, `templates.rs`,
709+
`conditional.rs`, `virtual_members.rs`, `completion/phpdoc/mod.rs`,
710+
`code_actions/update_docblock.rs`, `code_actions/phpstan/add_throws.rs`,
711+
`completion/source/throws_analysis/scanning.rs`, `hover/formatting.rs`).
712+
This is a full rewrite of the docblock/type parsing foundation, sized
713+
for several sprint items, not one.
714+
715+
**Sequencing with P30:** [P30](#p30-evaluate-migrating-parseresolvedocblock-pipeline-to-mago-hir)
716+
evaluates `mago-hir`, which — if it pans out — replaces this entire
717+
hand-rolled layer (docblock tag parsing and type-string parsing both)
718+
with a single upstream pass. Hand-migrating to `mago-phpdoc-syntax`
719+
now risks being thrown away if `mago-hir` is adopted later. Do not
720+
start the CST rewrite until P30's triggers have been evaluated one way
721+
or the other — either `mago-hir` is adopted (making this migration
722+
moot) or its triggers are judged unmet for the foreseeable future
723+
(making this migration the fallback worth doing).
724+
725+
The rest of the mago toolchain (`mago-syntax`, `mago-allocator`,
726+
`mago-database`, `mago-names`, `mago-span`, `mago-formatter`,
727+
`mago-php-version`, `mago-composer`) is already on 1.44.0 — that bump
728+
was independent of this CST rewrite and safe to do ahead of it (see
729+
the `[Unreleased]` changelog entry for the one user-visible effect, a
730+
`mago-formatter` chain-breaking fix). `mago-docblock` and
731+
`mago-type-syntax` are still pinned at 1.42.0 pending this migration.
732+
Do not go past 1.44.0 for the rest of the toolchain until this
733+
migration (or P30) is underway: `mago-allocator` 1.45.0 rewrites
734+
`LocalArena`/`SharedArena` into a unified `Arena` trait (new
735+
`boxed.rs`, `iter.rs`, `collections.rs`, `vec.rs` modules) — a real
736+
breaking change to the arena API this codebase uses throughout the
737+
parse hot path (`src/parser/ast_update.rs`'s `with_reusable_arena`,
738+
the parse-worker threads, etc.) — and taking it piecemeal ahead of a
739+
real reason to touch that code would be its own unreviewed migration.
710740

711741
---
712742

0 commit comments

Comments
 (0)