Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal for Sniff: SlevomatCodingStandard.Classes.ConstructorPropertyPromotionSpacing #1684

Open
freerich opened this issue May 28, 2024 · 0 comments

Comments

@freerich
Copy link
Contributor

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

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,
    ) {
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant