Abstract methods should not have a definition. They are used to define a contract that derived classes must implement. Therefore implementing an abstract method itself violates the meaning of defining the method as abstract
.
It is recommended to get rid of the body from the abstract method. Or, if you want to implement the method, drop the abstract
keyword.
abstract class User
{
abstract public function setUser(string $name): void
{
}
}
Either remove the body:
abstract class User
{
abstract public function setUser(string $name): void;
}
Or, do not define it as abstract
:
abstract class User
{
public function setUser(string $name): void
{
}
}