What are the potential pitfalls of using inheritance in PHP classes, as seen in the example provided?

One potential pitfall of using inheritance in PHP classes is that it can lead to tight coupling between classes, making the codebase harder to maintain and extend. To mitigate this issue, consider using composition over inheritance, where classes are composed of objects of other classes rather than inheriting from them directly.

// Using composition over inheritance

class Engine {
    public function start() {
        echo "Engine started";
    }
}

class Car {
    private $engine;

    public function __construct(Engine $engine) {
        $this->engine = $engine;
    }

    public function startEngine() {
        $this->engine->start();
    }
}

$engine = new Engine();
$car = new Car($engine);
$car->startEngine();