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
true and false are not considered subtypes of bool when checking type variance #1024
Since PHP 8.0 (false) and PHP 8.2 (true), both are standalone types and subtypes of bool. Narrowing a return type from bool to false/true, or widening a parameter type from false/true to bool, is allowed by PHP's inheritance rules (https://3v4l.org can confirm):
class P { functiona(): bool { returntrue; } functionb(false$x) {} }
class C extends P { functiona(): false { returnfalse; } functionb(bool$x) {} } // OK
TypeIsCovariant and TypeIsContravariant don't know about this relationship, so these changes are reported as BC breaks wherever variance is checked (final classes, final methods, functions):
[BC] CHANGED: The return type of X\Foo#isOk() changed from bool to the non-covariant false
[BC] CHANGED: The parameter $f of X\Foo#set() changed from false to a non-contravariant bool
2 backwards-incompatible changes detected
Neither change can break a caller: every value of false is a bool, and every argument accepted as false is still accepted as bool.
Activity