squizlabs / PHP_CodeSniffer

PHP_CodeSniffer tokenizes PHP files and detects violations of a defined set of coding standards.
BSD 3-Clause "New" or "Revised" License
10.67k stars 1.48k forks source link

No way to configure Generic.Formatting.MultipleStatementAlignment to ignore grouping by newlines #1700

Open mundschenk-at opened 7 years ago

mundschenk-at commented 7 years ago

At the moment, there does not seem to be a way to consciously make Generic.Formatting.MultipleStatementAlignment allow aligment across "groups". For example, I'd like this constructor (slightly simplified from the real world example) to stay as is alignment-wise:

public function __construct( $version, $basename, Transients $transients = null, Cache $cache = null ) {
    // Basic set-up.
    $this->version           = $version;
    $this->local_plugin_path = $basename;

    // Initialize cache handlers.
    $this->transients        = ( null === $transients ) ? new Transients() : $transients;
    $this->cache             = ( null === $cache ) ? new Cache() : $cache;
}
gsherwood commented 7 years ago

No, there is no sniff that will enforce that method, or allow both alignment across code blocks or individual alignment within a block.