You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 0fb1068
Browse filesBrowse the repository at this point in the historyBrowse files
Give a generic static type a class reflection with its type arguments
GenericStaticType::getStaticObjectType() handed the class reflection of the
declaring class, whose template types are unresolved, to the
GenericObjectType it builds, and getClassReflection() returned that
reflection too. Members of a `static<int, string>` then resolved against
`TKey`/`TValue` instead of `int`/`string` whenever the type was used inside
the class - `$this->concrete()->all()`, a `@param static<...>` parameter,
`static::` calls and properties, `new static(...)` with inferred type
arguments, promoted properties typed by the constructor's `@param`, and
every `static<...>` of a final class.
getClassReflection() now returns the reflection with the type arguments,
like GenericObjectType does, and getStaticObjectType() builds on it.
getAncestorWithClassName() keeps the type arguments the static object type
has for the ancestor class: through changeBaseClass(), which can only carry
them down to a subclass, an ancestor got its template bounds instead.
This replaces the workaround in
CalledOnTypeUnresolvedMethodPrototypeReflection that rebuilt the object type
without the reflection for method calls from outside the class (#6695); its
tests are kept.
Three expectations pinned the bug:
- bug-4590: `return new static(["ok" => "hello"])` from a method returning
`static<array<string, string>>` now infers `T` from the return type, like
`return new OkResponse([...])` in the same file already did. A real
mismatch is added instead.
- pr-5880: after `@phpstan-assert-if-true static<A> $this`, `$this->get()`
is `A` and `->a()` exists.
- bug-12575: after `@phpstan-self-out static<T&U>`, `$this->getT()` is
`A&T`.
The native GenericStaticType declares its properties from the generated
declarations now, so the new memo property keeps the slots in step with the
PHP twin.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011i2xTiyrXgfVkG1tmwMtUM
$this->assertSame('Call to an undefined method (T of PR5880EndlessRecursion\A = PR5880EndlessRecursion\A|PR5880EndlessRecursion\B)|T of PR5880EndlessRecursion\B = PR5880EndlessRecursion\A|PR5880EndlessRecursion\B::a().', $errors[0]->getMessage());
0 commit comments