I have an abstract class that I inherit from:
abstract class Test
{
public function GetTests()
{
}
}
and I have a specific question that most of the time I use the implementation of abstract classes:
class Concrete extends Test
{
}
I recently had to implement a different version of the GetTests method, and actually I wanted to overwrite it, as it is built into my entire routing:
class Concrete extends Test
{
public function GetTests( $newArgument )
{
}
}
However, I get this error message:
Declaration of Concrete::GetTests() should be compatible with Test::GetTests()
Besides copying the entire function from the abstract class to this particular one, although I only need to implement this method differently ... Is there a way around this?
I understand that I could:
abstract class Test
{
abstract public function GetTests();
}
But that's why I am a snooker, because I no longer have the opportunity to modify how the base class Test ... doh is implemented! ... If I really don't need to ...
Thanks to all the great answers ...
( , ), Test Concrete, Test, Test... , ( ) ...
:
class UnitOfWorkController
{
public function GetUnits()
{
return View::make(...);
}
}
...
class SomethingController /* no longer extends the UnitOfWorkController */
{
private $unitOfWorkController;
public function __Construct()
{
$this->unitOfWorkController = new UnitOfWorkController();
}
public function GetUnits()
{
return $this->unitOfWorkController->GetUnits();
}
}