Glossary

Abstract Class

An abstract class is a class from which you cannot create an instance directly. It defines a common structure and may contain both implemented methods and abstract ones (signature only; implementation in subclasses).

When to choose abstract class vs interface

Example

abstract class Shape {
  abstract public function area(): float;

  public function describe(): string {
    return "Area: " . $this->area(); // shared code
  }
}

class Circle extends Shape {
  public function area(): float { return M_PI * $this->r ** 2; }
}