Checks that there is a certain number of blank lines between promoted properties in constructor.
Sniff provides the following settings:
minLinesCountBeforeWithComment: minimum number of lines before promoted property with a documentation comment or attribute (default value is 1)
maxLinesCountBeforeWithComment: maximum number of lines before promoted property with a documentation comment or attribute (default value is 1)
minLinesCountBeforeWithoutComment: minimum number of lines before promoted property without a documentation comment or attribute (default value is 0)
maxLinesCountBeforeWithoutComment: maximum number of lines before promoted property without a documentation comment or attribute (default value is 1)
Code Samples
final class AddAddress implements Command
{
public function __construct(
#[NotBlank]
public string $street,
#[NotBlank]
#[Regex(pattern: '/^[0-9]{5}$/', message: 'postcode.must_be_5_digit_number')]
public string $postcode,
#[NotBlank]
public string $city,
) {
}
}
final readonly class AddAddressHandler implements CommandHandler
{
public function __construct(
private AddressRepository $repository,
private EventBus $eventBus,
) {
}
}
Documentation
SlevomatCodingStandard.Classes.ConstructorPropertyPromotionSpacing 🔧
Checks that there is a certain number of blank lines between promoted properties in constructor.
Sniff provides the following settings:
minLinesCountBeforeWithComment
: minimum number of lines before promoted property with a documentation comment or attribute (default value is 1)maxLinesCountBeforeWithComment
: maximum number of lines before promoted property with a documentation comment or attribute (default value is 1)minLinesCountBeforeWithoutComment
: minimum number of lines before promoted property without a documentation comment or attribute (default value is 0)maxLinesCountBeforeWithoutComment
: maximum number of lines before promoted property without a documentation comment or attribute (default value is 1)Code Samples