如果我在 PHP 中使用 Stricts Standarts 编写此代码,则不符合要求:
class Readable {};
class Atom extends Readable {};
class Reader {
public function read(Readable $readable){}
}
class AtomReader extends Reader {
public function read(Atom $readable){}
}
PHP Strict standards: Declaration of AtomReader::read() should be compatible with Reader::read(Readable $readable) in php shell code on line 2
这里失败的原理(如SOLId,...)是什么?
注意:如果我是对的,此代码尊重 Liskov 原则。