We basically follow the coding style related PSR standards issued by the PHP Framework Interoperability Group:
The string concatenation operator MUST be preceded and followed by a space.
// bad
$string = 'Hello '.$name;
// good
$string = 'Hello ' . $name;
Scalar values should use short/abbreviated form in all applicable locations including function parameter type hints, function return types, and annotations.
// bad
private function (integer $timeout, string $phrase, boolean $enabled)
// good
private function (int $timeout, string $phrase, bool $enabled)
About the names of identifiers like classes, functions, methods, variables:
- A name SHOULD be descriptive, distinctive, precise and readable.
- A name SHOULD NOT be abbreviated.
A long name is not a problem, since our IDE has auto completion.
Consecutive assignments or declarations SHOULD NOT be aligned. Adding one item may require you to re-align the other items, resulting in unnecessary changes in your commit.
// bad
$short = 1;
$veryLongItem = 2;
// good
$short = 1;
$veryLongItem = 2;