-
-
Notifications
You must be signed in to change notification settings - Fork 173
Mago 2.0 - Tracking Issue #1931
Copy link
Copy link
Labels
bc-breakBreaking changeBreaking changec-analyzerPHP static analyzer and type error detectionPHP static analyzer and type error detectionc-codexType system representation and codebase metadataType system representation and codebase metadatac-databaseIn-memory database for source code analysisIn-memory database for source code analysisc-docblockPHPDoc annotation and tag extractionPHPDoc annotation and tag extractionc-formatterPHP code reformatting and style rulesPHP code reformatting and style rulesc-guardPHP dependencies guard for clean architecturePHP dependencies guard for clean architecturec-linterPHP linting for errors, style, and bugsPHP linting for errors, style, and bugsc-orchestratorCoordination of Mago componentsCoordination of Mago componentsc-semanticsPHP semantics checkerPHP semantics checkerc-syntaxPHP lexer, parser, and ASTPHP lexer, parser, and ASTc-type-syntaxPHPDoc type syntax parsingPHPDoc type syntax parsingcliCommand-line interfaceCommand-line interfaceconfigurationConfiguration loading and validationConfiguration loading and validationlanguage-serverExperimental Mago Language ServerExperimental Mago Language ServerrustWritten in RustWritten in Rustt-enhancementNew feature or requestNew feature or request
Milestone
Description
Metadata
Metadata
Assignees
Labels
bc-breakBreaking changeBreaking changec-analyzerPHP static analyzer and type error detectionPHP static analyzer and type error detectionc-codexType system representation and codebase metadataType system representation and codebase metadatac-databaseIn-memory database for source code analysisIn-memory database for source code analysisc-docblockPHPDoc annotation and tag extractionPHPDoc annotation and tag extractionc-formatterPHP code reformatting and style rulesPHP code reformatting and style rulesc-guardPHP dependencies guard for clean architecturePHP dependencies guard for clean architecturec-linterPHP linting for errors, style, and bugsPHP linting for errors, style, and bugsc-orchestratorCoordination of Mago componentsCoordination of Mago componentsc-semanticsPHP semantics checkerPHP semantics checkerc-syntaxPHP lexer, parser, and ASTPHP lexer, parser, and ASTc-type-syntaxPHPDoc type syntax parsingPHPDoc type syntax parsingcliCommand-line interfaceCommand-line interfaceconfigurationConfiguration loading and validationConfiguration loading and validationlanguage-serverExperimental Mago Language ServerExperimental Mago Language ServerrustWritten in RustWritten in Rustt-enhancementNew feature or requestNew feature or request
Mago 2.0 - Tracking Issue
Meta issue for the 2.0 release. 2.0 is a ground-up rework of the analysis pipeline plus the tooling and stability commitments that ride on top of it. This issue tracks the whole effort; each box links to (or will spawn) a dedicated issue/PR.
Why 2.0
PHP is effectively two languages: the surface syntax, and the type language embedded in docblocks (
@var,@param,@template,@method,@psalm-type, ...). They have different grammars and, in 1.x, are parsed by different code at different times, the syntax tree as one artifact, docblocks re-parsed on demand across a multiple scattered call sites.2.0 fuses them. A single lowering pass turns the syntax tree into one typed IR that already has docblocks parsed, names resolved, and sugar normalized — and analysis is split into honest phases (scan → inference → check) that hand a typed program forward instead of re-deriving it. As a side effect we stop lying about the tree: what 1.x calls the "AST" is really a lossless CST (it keeps trivia and spans, which is why the formatter round-trips), so 2.0 names it a CST and reserves "the real, lowered tree" for the IR.
The new pipeline
Key decisions already settled in design:
C(context) andT(type), with annotationion** (no interior mutability), the generics encode the analysis phase in the type system.bumpalo-herd) or as owned-per-file values, not borrowed from a transient per-thread bump.Workstreams
1. Compiler core (critical path — roughly in order)
mago_syntax::ast→mago_syntax::cst). Mechanical, unblocks the naming for everything below. refactor: rename ast to cst everywhere #1933mago_ir/mago_hir— TBD): node defs generic overS/D/Emago_names) and docblock parsing/merge + desugaring. feat(hir): native CST lowering with name resolution #1936 chore(hir): some clean up #1937 feat(hir): lower phpdoc to IR #1943CodebaseMetadatafrom the IR (instead of the CST) feat: IR-based codebase scanner #1952mago-oracle, amago-codexreplacement:oracle::ty- done in fix(oracle): close lattice soundness gaps #1979CodebaseMetadata-> IR withTfilled. feat(inference): introduce mago-inference crate #2036mago-analyzer, superseded by inference + checker; it does not get a 2.0.2. Type-system features
recursive-array<K, V>andrecursive-list<T>(Support recursive types #1139).3. New commands
mago check— runs linter → inference → checker as one pass (faster thanmago analyze+mago lintseparately).mago security-analy-taint-analysis, TBD) (Support SQL static analysis and type inference for the database access layer #454).mago bc-check, detect backward-incompatible changes between the working tree and a given tag (BC Checking #675).4. Linter & formatter
T[]) #1016).5. Editor & LSP
6. Extensibility & stability
Open questions
CtxvsEnv?mago security-analysissubcommand vs--with-taint-analysismago analyze/mago lintget deprecated in favor ofmago check, or kept as aliasbumpalo-herdvs owned-per-file (self_cell)?