Currently, code from 1a0576e6043d allows to check if a variable or the callable return type matches the expected type.
This resolution is a direct match. If class A extends the class B, and the class B implements the interface I, it would be useful to be able to check if A is a B or is a I.
For example, it would be useful to know if the concrete implementation CacheVoid is an instance of Psr\Cache\CacheInterface.
Use case
Zed is implementing a simple services container built on the top of OmniTools HashMap.
Such container could also be useful for Obsidian Workspaces too.
Scope
- CallableElement, in addition to hasReturnType
- CodeVariable, in addition to hasType
Unit tests
Comprehensive unit tests need to be devised to handle the following cases:
- scalar types
- object types <- our regular case
- union types (X|Y is not warranted to be a A if only X: A, but not Y, so would only be true if all types implement/extends the target type)
- PHP 8.1+ intersection types (A&B is warranted to be a A, so here if one satisfies the condition, we're good)
Parent tasks