godaddy-wordpress / godaddy-wordpress/php-coding-standards

Comments in between multi-line variable assignments should validate

Aperta
#1 0 commenti 1 reazione 0 assegnatari Vedi su GitHub
Lingua principale
Nessun dato sulla lingua
Stelle
0
Fork
2
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Suppose you have:

```php
// group 1

$foo = 1;
$barbaz = 'variable';
$boo = null;
$anothervar = new \stdClass();

// group 2

// some comment about $foo
$foo = 1;
// some comment about $barbaz
$barbaz = 'variable';
$boo = null;
// some comment about $anothervar
$anothervar = new \stdClass();
```

With the current PHPCS ruleset group 1 would pass but group 2 would not and generate errors.

In my opinion this should be legal for single line small comments to exist in a multi-line group.

I am not sure though that this would be supported by a PHPCS rule. Probably not? Maybe we could turn off spaces before equals sign or set to severity 0. The thing is this pattern often exists in our codebase (for example [here](https://github.com/skyverge/wc-plugins/pull/3359/files#r351621661)). If we have a reason why we allow and like the alignment in group 1, we should allow here as well.

By the way this would also apply to values assignment in arrays:

```php

$my_array = [
'id' => 0,
// some comment about this key:
'name' => 'Foo',
// some comment about this other key
'location' => 123,
'etc' => null,
];
```

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.