PHP 8.6 vyšlo. DressCode na něj váš kód přepíše. Přechod na novější PHP →

Velikost písmen

NULL, StrLen() i new datetime fungují, protože PHP v klíčových slovech a ve jménech tříd a funkcí velikost písmen nerozlišuje. Sekce casing dá jednotný zápis klíčovým slovům, true, false a null, magickým konstantám jako __DIR__, vestavěným typům a jménům tříd, funkcí a metod.

Takový zápis se ale čte hůř a každý projekt ho píše trochu jinak. Klíče sekce sjednotí zápis na ten, který má deklarace: strlen, DateTime, stdClass. Bez analýzy typů zná DressCode jen deklarace PHP a rozšíření, která se s PHP dodávají, takže jména z vašeho projektu a balíčků nechá, jak jsou, a u metod srovná jen magické metody PHP, třeba __toString(): která metoda se doopravdy volá, se pozná jen z typů. S typeAnalysis: phpstan se ptá PHPStanu a srovná i new orderitem na new OrderItem podle deklarace v projektu, volání $order->gettotal() na $order->getTotal() a metodu přepisující metodu předka na zápis předka.

casing:
	keyword: lowercase
	trueFalseNull: lowercase
	class: declared
	function: declared
$items = Array();  // The keyword `Array` must be written `array`.
if ($value === NULL) {  // The literal `NULL` must be written `null`.
	$date = new datetime();  // The class name `datetime` must be written `DateTime`.
	$length = StrLen($name);  // The function `StrLen()` must be written `strlen()`.
}
$items = array();
if ($value === null) {
	$date = new DateTime();
	$length = strlen($name);
}

casing.keyword

The case of keywords, self and parent included.

  • lowercase: if, function, self, parent
  • keep: nic se nevynucuje, kód zůstane, jak je

Výchozí keep · standardy: perCs lowercase, psr12 lowercase, nette lowercase, symfony lowercase, laravel lowercase · pokrývá lowercase_keywords, lowercase_static_reference, Generic.PHP.LowerCaseKeyword, Generic.PHP.LowerCaseType, PSR2.ControlStructures.SwitchDeclaration, Squiz.ControlStructures.ForEachLoopDeclaration, Squiz.ControlStructures.LowercaseDeclaration, Squiz.Functions.LowercaseFunctionKeywords

casing.trueFalseNull

The case of true, false and null, a leading backslash staying.

  • lowercase: true, false, null
  • uppercase: TRUE, FALSE, NULL
  • keep: nic se nevynucuje, kód zůstane, jak je

Výchozí keep · standardy: perCs lowercase, psr12 lowercase, nette lowercase, symfony lowercase, laravel lowercase · pokrývá constant_case, Generic.PHP.LowerCaseConstant

casing.magicConstant

The case of the magic constants such as __DIR__.

  • uppercase: __DIR__, __CLASS__
  • lowercase: __dir__, __class__
  • keep: nic se nevynucuje, kód zůstane, jak je

Výchozí keep · standardy: perCs keep, psr12 keep, nette uppercase, symfony uppercase, laravel uppercase · pokrývá magic_constant_casing

casing.type

The case of the built-in types of a declaration; array, callable, static, self and parent are keywords.

  • lowercase: int, string, void
  • keep: nic se nevynucuje, kód zůstane, jak je

Výchozí keep · standardy: perCs lowercase, psr12 lowercase, nette lowercase, symfony lowercase, laravel lowercase · pokrývá native_type_declaration_casing, Generic.PHP.LowerCaseType

casing.class

The case of a class, an interface, a trait or an enum as its declaration writes it, of one PHP declares only where the configuration sets no typeAnalysis.

  • declared: stdClass, DateTime, never datetime
  • keep: nic se nevynucuje, kód zůstane, jak je

Výchozí keep · standardy: perCs keep, psr12 keep, nette declared, symfony declared, laravel keep · pokrývá class_reference_name_casing

casing.function

The case of a function as its declaration writes it, of one PHP declares only where the configuration sets no typeAnalysis.

  • declared: strlen, never StrLen
  • keep: nic se nevynucuje, kód zůstane, jak je

Výchozí keep · standardy: perCs keep, psr12 keep, nette declared, symfony declared, laravel declared · pokrývá native_function_casing, Squiz.PHP.LowercasePHPFunctions

casing.method

The case of the name of a method called, as its declaration writes it, and of a method overriding another, as the overridden one writes it; a magic method of PHP as PHP writes it, the others only with the types of the code.

  • declared: $order->getTotal(), never $order->gettotal()
  • keep: nic se nevynucuje, kód zůstane, jak je

Výchozí keep · standardy: perCs keep, psr12 keep, nette declared, symfony declared, laravel keep

casing.hexDigit

The digits A to F of a hexadecimal number; the prefixes 0x, 0b and 0o stand in lowercase either way.

  • uppercase: 0xFF
  • lowercase: 0xff
  • keep: nic se nevynucuje, kód zůstane, jak je

Výchozí keep · standardy: perCs keep, psr12 keep, nette keep, symfony keep, laravel uppercase · pokrývá integer_literal_case

Zobrazit na GitHubu · Nahlásit problém se stránkou na GitHubu · 7. 11. 2026