class CommonClass {
public function foo() {/*...*/}
public function bar() {/*...*/}
}
class ConcreteClass1 extends CommonClass {
public function doSomething1() {/*...*/}
public function doSomething2() {/*...*/}
}
class ConcreteClass2 {
public function doSomething1() {/* тот же код из ConcreteClass1 */}
public function doSomething2() {/* тот же код из ConcreteClass1 */}
public function doSomething3() {/*...*/}
}
public function doSomething1() {/*...*/}
public function doSomething2() {/*...*/}
class CommonClass {
public function foo() {/*...*/}
public function bar() {/*...*/}
}
class ConcreteClass1 extends CommonClass {
include "common.php";
}
class ConcreteClass2 {
include "common.php";
public function doSomething3() {/*...*/}
}
class CommonClass {
public function foo() {/*...*/}
public function bar() {/*...*/}
}
class ConcreteClass1 extends CommonClass {
public function doSomething1() {/*...*/}
public function doSomething2() {/*...*/}
}
class ConcreteClass2 {
ConcreteClass1 concreteClass1 = new ConcreteClass1();
public function doSomething1() {concreteClass1.doSomething1()}
public function doSomething2() {concreteClass1.doSomething2()}
public function doSomething3() {/*...*/}
}
interface Common {
void foo();
void bar();
}
interface ConcreteWithSomething {
void doSomething1();
void doSomething2();
}
interface Concrete1 extends Common, ConcreteWithSomething {}
interface Concrete2 extends ConcreteWithSomething {
void doSomething3();
}
class Concrete2Impl implements Concrete2 {
@Inject private Concrete1 delegate;
public void doSomething1() { delegate.doSomething1(); }
public void doSomething2() { delegate.doSomething2(); }
public void doSomething3() {/*...*/}
}
потому в ConcreteClass2 методы foo() и bar() из CommonClass не должны быть.
public function foo() { return null; }
public function doSomething1() {
$cl = new ConcreteClass1();
return $cl->doSomething1();