Giusto per completare il tutto ... nell'esempio sfrutto doSomethingN dentro gli altri metodi, in realtà basta sfruttare l'overload anche dentro i metodi stessi ...
codice:
class Overload {
protected function doSomething0(A $a) {
return 'Recieved an A instance with value: '.$a;
}
protected function doSomething1(B $b) {
return 'Recieved a B instance with value: '.$b;
}
protected function doSomething2(A $a, B $b) {
return $this->doSomething($a).' and '.$this->doSomething($b).' too';
}
protected function doSomething3(B $b, A $a) {
return $this->doSomething($b).' and '.$this->doSomething($a).' too';
}
public function __call($method, $arguments){
...
}
}