Probably very obvious, but it's late and I'm having a little session of "alcohol fuelled development" but could someone explain why I'm receiving the error:-
Fatal error: Can't inherit abstract function EnglishBreakfast::hasHashBrowns() (previously declared abstract in NorthernBreakfast) in C:\webroot\www\f.php on line 17
PHP Code:
<?php
interface EnglishBreakfast
{
public function getBeans();
public function getBacon();
public function getSausage();
public function getEggs();
public function getToast();
public function hasHashBrowns();
}
abstract class NorthernBreakfast implements EnglishBreakfast
{
abstract public function hasHashBrowns();
public function getBeans()
{
return 'Heinz';
}
public function getBacon()
{
return 'Danish Back';
}
public function getSausage()
{
return 'Cumberland';
}
public function getEggs()
{
return 'Scrambled';
}
public function getToast()
{
return 'Dark, both sides, dry';
}
public function hasBlackPudding()
{
return true;
}
}
class SilversBreakfast extends NorthernBreakfast
{
public function hasHashBrowns()
{
return 'of course!';
}
}
class Meals
{
protected $aMealsToday = array();
public function setBreakfast(EnglishBreakfast $oBreakfast)
{
array_push($this->aMealsToday, $oBreakfast);
}
}
$oMeals = new Meals();
$oMeals->setBreakfast(new SilversBreakfast());
?>
Surely it must be possible for an object to implement an interface whilst leaving a child object to fulfil an abstract method, even moving the declaration of the interface implementation to the child object fails with the same error.
Should I just stop coding and go to bed?
Bookmarks