Final public method for abstract class

All public methods of abstract classes should be final. Enforce API encapsulation in an inheritance architecture. If you want to override a method, use the Template method pattern.
This commit is contained in:
MathiasReker
2022-06-16 21:09:49 +02:00
parent 7b24e1185a
commit 6ec696d00b
6 changed files with 8 additions and 8 deletions

View File

@@ -11,12 +11,12 @@ abstract class BookPrototype
abstract public function __clone();
public function getTitle(): string
final public function getTitle(): string
{
return $this->title;
}
public function setTitle(string $title): void
final public function setTitle(string $title): void
{
$this->title = $title;
}