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
Extract Type::toObjectTypeForIsACheck() for is_a($x, $class, $allowString)
Replaces `IsAFunctionTypeSpecifyingHelper::determineType()`'s
hand-rolled `TypeTraverser::map` callback with a polymorphic `Type`
method. The helper shrinks to a few lines that:
- call `$classType->toObjectTypeForIsACheck($objectOrClassType, ...)`,
- OR-fold the polymorphic uncertainty with the original
"no constant strings in input" initial state,
- run the same false-positive suppression check.
Per leaf:
- `ConstantStringType`: the only branch with real logic — collapses
to `NeverType` when the input is the same final class
(`!$allowSameClass`), sets uncertainty when the same class name
appears in the input's class names (or when `$allowString` matches
the input's superclass), then projects to `ObjectType($value)` (or
`ObjectType|class-string<X>` if `$allowString`).
- `GenericClassStringType`: projects to its `getGenericType()` (or a
union with the class-string itself if `$allowString`), no
uncertainty.
- All other leaves (default in `NonObjectTypeTrait`,
`MaybeObjectTypeTrait`, `ObjectTypeTrait`, plus direct overrides on
`ObjectType`, `StaticType`, `ClosureType`,
`NonexistentParentClassType`, `MixedType`, `StrictMixedType`):
`ObjectWithoutClassType` (or `ObjectWithoutClassType|class-string`
if `$allowString`), no uncertainty.
- `NeverType`: pass through.
- `UnionType`/`IntersectionType`: distribute, OR-folding uncertainty.
- `LateResolvableTypeTrait`: delegate to `resolve()`.
Reuses the `ClassNameToObjectTypeResult` value object introduced for
`toObjectTypeForInstanceofCheck()`.
Pure refactor: full test suite + phpstan + cs pass.
0 commit comments