Aller au contenu

File Name Matches Type (ARCH7005)

Ce contenu n’est pas encore disponible dans votre langue.

Key php.naming.file-name-matches-type · Severity info · Category naming

PSR-4 autoloading requires the file name to match the single top-level type it declares. A mismatch both breaks loading and makes the file hard to locate.

invoice.php
<?php
class PaymentProcessor
{
public function charge(int $amount): bool
{
return true;
}
}
PaymentProcessor.php
<?php
class PaymentProcessor
{
public function charge(int $amount): bool
{
return true;
}
}

Rename the file to match the primary type it declares (PaymentProcessor.php).