Contravariance¶
Contravariance allows a parameter type to be less specific in a child method, than that of its parent.
<?php
class v {}
class w extends v {
// This method accepts an object compatible with w, but less specific
function foo(v $arg) { }
}
class wv extends w {
function foo(w $arg) { }
}
?>
Related : Covariance
Added in PHP 7.4+