Zum Inhalt springen

Concrete dependency injection (ARCH7199)

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

Key php.quality.concrete-dependency · Severity info · Category quality

Typing dependencies as concrete classes violates the dependency inversion principle (DIP) and couples the class to a specific implementation. Depend on interfaces.

<?php
class ReportService
{
public function __construct(private MySqlReportRepository $repo) {}
}
<?php
class ReportService
{
public function __construct(private ReportRepository $repo) {}
}

Type constructor dependencies as interfaces/abstractions rather than concrete classes.