Key class has a non-abstract method getDescription() (for many purposes).
Key class is extended by (one of) "a child abstract class".
"A child abstract class" is extended by "a concrete class".
I want to force "a concrete class" to implement getDescription() method and try to redeclare it in "a child abstract class" as an abstract method, but fail.
So, is it possible to redeclare non-abstract method as abstract in php? If not - how to force a concrete method to be implemented?
The key class. I need getDescription as declared in this way for many purposes.
abstract class beverage{
public $description = "Unknown beverage";
public function getDescription(){return $this->description;}
};
The abstract class, overriden getDescription() - but does not work.
abstract class condimentDecorator extends beverage {
//public abstract function getDescription();
};
Concrete class, which MUST reimpliment getDescription.
class milk extends condimentDecorator{
public $beverage;
public function __construct(beverage $beverage){$this->beverage = $beverage;}
public function getDescription(){return $this->beverage->getDescription().", Milk";}
};