This is my code:
interface ValidatorInterface
{
public function hasErrors ();
public function validate (stdClass $metadata);
public function getFeedback ();
}
abstract class ValidatorAbstract implements ValidatorInterface
{
protected $feedback;
public function __construct ()
{
$this->feedback = new FormFeedback();
}
public function getFeedback ()
{
return $this->feedback;
}
public function hasErrors ()
{
return $this->getFeedback()->hasErrors();
}
}
class RegistrationValidator extends ValidatorAbstract
{
public function validate (stdClass $metadata)
{
$this->getFeedback()->addError('Testing');
return !!$this->hasErrors();
}
}
This is the error:
Fatal error: Class RegistrationValidator contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (ValidatorInterface::hasErrors)
The abstract class ValidatorAbstract
satisfies the requirements imposed by ValidatorInterface
to have the hasErrors()
and getFeedback()
methods.
The class RegistrationValidator
extends ValidatorAbstract
and satisfies the last remaining requirement to declare a validate()
method.
Why then am I getting an error saying that RegistrationValidator
contains an abstract method, when it doesn't, and that it must implement hasErrors()
when that method is already implemented by its parent class?