Repository navigation
Answer maybe in ObjectType::isInstanceOf() where a subclass may be an instance - #7173
Merged
Merged
Conversation
… instance
- ObjectType::isInstanceOf() returned no when the asked class is an
interface and this class is not an interface, although a subclass of a
non-final class may implement it (isSuperTypeOf() already says maybe).
It also returned no for a final subclass of this class. is_iterable() on
stdClass, instanceof stdClass on iterable and Exception&iterable were
narrowed to never.
- ConstantArrayType: a sealed [classOrObject, method] shape whose slots
cannot hold an object or a string and a string is not callable, as the
unsealed path already checks - list{int, int} was maybe callable while
list<int> was not.
- turbo-ext: the same in ObjectType.cpp and ConstantArrayType.cpp.
- ObjectTypeTest/StaticTypeTest: DateTime may be iterable through a
subclass; Closure (final) still is not.
Amp-Thread-ID: https://ampcode.com/threads/T-01a17eac-1199-74a6-b3f7-dfbd8a084465
…r objects The check that the [classOrObject, method] slots can hold a callable compared them with isSuperTypeOf() against object|string and string. Both directions answer no for every slot type the check meets, so mutation testing could not tell them apart. isObject()/isString() ask the same question directly. New cases cover a slot that may be an object or a string (int|object, int|string) and a method slot that may be a string (int|string). turbo-ext: the same in ConstantArrayType.cpp. Amp-Thread-ID: https://ampcode.com/threads/T-01a17eac-1199-74a6-b3f7-dfbd8a084465
This was referenced Nov 26, 2026
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.
ObjectType::isInstanceOf()answered no where a subclass may be an instance of the asked class:isSuperTypeOf()already answers maybe here), andSo
is_iterable($stdClass)was reported as always false and narrowed to*NEVER*,$iterable instanceof stdClasswas always false, andException&iterablewasnever, while$stdClass instanceof Traversablecorrectly gavestdClass&Traversable(non-monotone disjointness; it also madeTypeCombinator::intersect()non-associative).Errors that need an iterable (
foreach,yield from, unpacking,iterable/Traversableparameters) still report a non-iterableDateTime- they require yes.ConstantArrayType::isCallable()had the same non-monotonicity:list<int>was never callable while its subtypelist{int, int}was maybe callable. A sealed[classOrObject, method]shape whose slots cannot holdobject|stringandstringis now not callable, as the unsealed path already checked.turbo-ext mirrors both changes.