Hello internals,
I have an outstanding PR where I implemented resolution of the parent and self types at compile time. [1]
The reasoning for this is to attempt to add various methods to ReflectionType, such as isCovariant/isContravariant and other type relation methods.
Currently, we cannot do this easily, as we need a "scope" with the ReflectionType to resolve the relative class types self, parent, and static.
The current implementation uses two new bit flags to mark the type as self and parent, to be able to preserve BC with existing code relying on the names self/parent.
However, we are limited in flag numbers available and using two bits for this seems wasteful.
The question: Is it an issue if the self and parent types are resolved at compile time? (when possible)
In its simplest form, this would affect error messages (such as type errors) and also the compile time type redundancy check. [2]
Note: traits and unbound Closures would still require a way to provide the "scope" but those seem to be cases of limited use for analysing/comparing ReflectionTypes.
Best regards,
Gina P. Banyard
[1] https://github.com/php/php-src/pull/11460
[2] If a class Foo declares a method with union type Foo|self no compile time error is thrown at the moment, this would change as self would correspond to Foo and the type would be Foo|Foo which is redundant