refactor: model static and $this as bounded types in the type system#287
Merged
Conversation
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Add PhpType::StaticType(Atom) and PhpType::ThisType(Atom) variants
that preserve late-static-binding semantics instead of flattening
static/$this to a bare class name. StaticType carries the bound
class ("at least this class or a subclass"), ThisType is more
specific ("the exact runtime instance type").
The subtype chain is ThisType(A) <: StaticType(A) <: Named(A).
Display: static(Foo), $this(Foo) -- shows the bound class.
Production sites updated:
- replace_self(fqn) now delegates to resolve_self_refs_bounded()
so static -> StaticType(fqn) and $this -> ThisType(fqn);
replace_self_with_type(&receiver) is unchanged (preserves full
generic receiver types for accurate chain resolution)
- Subject resolution: $this -> ThisType, static -> StaticType
- First-class callable partial application: preserves static/this
- Template substitution: preserve_static path uses bounded types
- new static() -> StaticType instead of Named
- Diagnostic param checking: resolve_self_refs_bounded() produces
bounded types so class-string<static> is properly validated
Subtype checking updated:
- StaticType(A) <: Named(A) and ThisType(A) <: Named(A)
- ThisType(A) <: StaticType(A)
- base_name(), top_level_class_names(), collect_class_names() all
handle the new variants
Peripheral sites updated:
- return_type_is_mixin_self handles StaticType/ThisType
- is_simple_php_type handles StaticType/ThisType
- Union member deduplication handles StaticType/ThisType
calebdw
force-pushed
the
calebdw/push-sonmumonmmzk
branch
from
July 26, 2026 01:52
f0d570a to
4abfa75
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add PhpType::StaticType(Atom) and PhpType::ThisType(Atom) variants that preserve late-static-binding semantics instead of flattening static/$this to a bare class name. StaticType carries the bound class ("at least this class or a subclass"), ThisType is more specific ("the exact runtime instance type").
The subtype chain is ThisType(A) <: StaticType(A) <: Named(A).
Display: static(Foo), $this(Foo) -- shows the bound class.
Production sites updated:
Subtype checking updated:
Peripheral sites updated:
Checklist
If applicable:
CHANGELOG.mdREADME.md,docs/,examples/)config-schema.json)how it works, how it's organized), including any code drafted by an LLM.
an eye towards deleting anything that is irrelevant, clarifying anything
that is confusing, and adding details that are relevant. This includes,
for example, commit descriptions, PR descriptions, and code comments.