I think there is a problem in the implementation of PHP-OOP.
EDIT: Consider a more visual example:
abstract class Animal {
public $name;
public abstract function Communicate(Animal $partner);
}
class Panda extends Animal {
public function Communicate(Panda $partner) {
echo "Hi {$partner->name} I'm a Panda";
}
}
class Human extends Animal {
public function Communicate(Human $partner) {
echo "Hi {$partner->name} I'm a Human";
}
}
$john = new Human(); $john->name = 'John';
$mary = new Human(); $mary->name = 'Mary';
$john->Communicate($mary);
$zuzi = new Panda(); $zuzi->name = 'Zuzi';
$zuzi->Communicate($john);
The problem is that when Animal :: Communicate is an abstract method, php reports that the following methods are illegal:
"public function Communicate (Panda $ partner)" "public function Communicate (Human $ partner)"
but when Animal :: Communicate is not abstract, but has a zero implementation, Php considers these methods to be legal. So, in my opinion, this is not so, because we do redefinition in both cases, and both cases are equal, so it seems that this is a mistake ...
The old part of the message:
Pay attention to the following code:
Framework.php
namespace A
{
class Component { ... }
abstract class Decorator {
public abstract function Decorate(\A\Component $component);
}
}
Implementation.php
namespace B
{
class MyComponent extends \A\Component { ... }
}
Mydecorator.php
namespace A
{
class MyDecorator extends Decorator {
public function Decorate(\B\MyComponent $component) { ... }
}
}
MyDecorator.php,
: MyDecorator:: Decorate() A\Decorator:: Decorate() MyDecorator.php on line...
Framework.php:: Decorator :
abstract class Decorator {
public function Decorate(\A\Component $component) {}
}
.