I'll try get straight to the point:
class C1 {}
class C2 extends C1 {}

abstract class Work1 {
 public function f1(C1 $c);
}

class Work2 extends Work1 {
 public function f1(C2 $c);
}

This code violates the LSP (*) - if you have object $X of type C1, you can call $work1->f1($X) but not $work2->f1($X) - so $work2 can't be substituted for $work1. Meaning if you had this code:

function foo(Work1 $object) {
  $X = new C1();
  $object->f1($X);
}

it would break with passing Work2 object into it, which violates the principles of inheritance.

(*) http://en.wikipedia.org/wiki/Liskov_substitution_principle
--
Stanislav Malyshev, Zend Products Engineer
[EMAIL PROTECTED]  http://www.zend.com/

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to