Re: [PHP-DEV] function overriding and class inheritance

2007-05-29 Thread Paweł Stradomski
Emil Ivanov wrote: > class C1 {} > class C2 extends C1 {} > > abstract class Work1 { >  public function f1(C1 $c); > } > > class Work2 extends Work1 { >  public function f1(C2 $c); > } Strange thing is I don't get any error message here, although there definitely should be one. PHP 5.2.2-pl1-gen

Re: [PHP-DEV] function overriding and class inheritance

2007-05-29 Thread Marcus Boerger
Hello Emil, learn inheritance rules! And besides PHP follows strict is_a rules. Even if PHP weren't following strict is_a rules: Every Work2 is a Work1 so and so any place that uses with Work1 objects can take Work2 objects. Now "$o->f1($c);" might be using a $o being a work1 or a work2. That m

Re: [PHP-DEV] function overriding and class inheritance

2007-05-29 Thread Stanislav Malyshev
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->