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
self, parent and static types are not resolved to classes when checking type variance #1025
BetterReflection reports self, parent and static as built-in types (ReflectionNamedType#isBuiltin() returns true for them). TypeIsCovariant and TypeIsContravariant treat every built-in type as unrelated to any class, so swapping a class name for the equivalent self/parent, or narrowing a return type to static, is reported as a BC break:
[BC] CHANGED: The return type of X\Foo#withA() changed from X\Foo to the non-covariant self
[BC] CHANGED: The return type of X\Foo#withB() changed from self to the non-covariant static
[BC] CHANGED: The parameter $other of X\Foo#equals() changed from self to a non-contravariant X\Foo
[BC] CHANGED: The parameter $other of X\Foo#accept() changed from X\Foo to a non-contravariant parent
[BC] CHANGED: The return type of X\Foo#make() changed from object to the non-covariant static
5 backwards-incompatible changes detected
None of these changes can break a caller. The same applies to property types: public Foo $foo → public self $foo in Foo is reported by PropertyTypeChanged.
ReflectionNamedType#getClass() already resolves self, parent and static to the class they refer to, so the variance checks can use it. static needs care: it may refer to any child class, so static → self is still not covariant.
Activity