Skip to content

Add SimpleScope PHPStan-free type resolution proof of concept - #8463

Open
TomasVotruba wants to merge 3 commits into
mainfrom
simple-scope-tier3-poc
Open

Add SimpleScope PHPStan-free type resolution proof of concept#8463
TomasVotruba wants to merge 3 commits into
mainfrom
simple-scope-tier3-poc

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Why

First concrete step toward reducing PHPStan coupling in the codebase. PHPStan is currently a runtime dependency used across ~545 source files (type system, scope, reflection, phpdoc parser). This PR does not remove any of that - it proves a model for a dependency-free type layer on an isolated island, so we can evaluate the approach before touching real rules.

What

A standalone, PHPStan-free type-resolution layer:

  • Rector\SimpleType\Contract\SimpleTypeInterface + concrete StringType, IntegerType, BooleanType, NullType, ArrayType, ObjectType, MixedType
  • Rector\SimpleScope\SimpleScope - resolves an expression to a SimpleType (literals, new X, local variables)
  • Rector\SimpleScope\SimpleScopeResolver - builds a scope from parameters and local assignments, in source order
  • DemoObjectMethodCallRenameRector - a Tier-3 name-matcher rule that does its own type resolution with zero PHPStan usage in its logic

Scope and limits

  • Nothing existing is changed; this is a self-contained island.
  • Handles the local, syntactic cases (literals, new, typed params, local vars). Cross-file inference (method return types, property types, flow-sensitive unions) still needs real reflection and is intentionally out of scope - those return MixedType (safe no-op).
  • Covered by a unit test for the resolver and fixture tests for the demo rule.

Passes composer complete-check and composer rector locally.

@TomasVotruba
TomasVotruba force-pushed the simple-scope-tier3-poc branch from 623a225 to 25cc6ae Compare September 5, 2026 11:53
Introduce a standalone, dependency-free type layer as a first step toward
reducing PHPStan coupling:

- SimpleTypeInterface + concrete scalar/array/object/null/mixed types
- SimpleScope resolves an expression to a SimpleType
- SimpleScopeResolver builds a scope from params and local assigns
- DemoObjectMethodCallRenameRector shows a Tier-3 name-matcher rule doing
  its own type resolution with zero PHPStan usage

Nothing existing is changed; the island proves the model before any real
rule migration.
@TomasVotruba
TomasVotruba force-pushed the simple-scope-tier3-poc branch from a6773d3 to ede5d41 Compare September 5, 2026 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants