coding-standard icon indicating copy to clipboard operation
coding-standard copied to clipboard

Idea: Require trailing comma in multi-line annotations

Open alcaeus opened this issue 7 years ago • 2 comments

This sniff would compare to SlevomatCodingStandard.Arrays.TrailingArrayCommaSniff and require a trailing comma on each line of a multi-line annotation. The idea is to reduce the diff size when adding a new property or item in a list. Caveat: I'm not sure if it's possible to properly check coding standards in docblocks - my parser knowledge ends well before that.

/**
 * @ODM\Document(
 *     collection="user",
 *     repositoryClass=UserRepository::class,
 *     indexes={
 *         @ODM\Index(keys={"canonicalUsername"="asc"}, unique=true),
 *         @ODM\Index(keys={"affiliateHash"="asc"}, unique=true),
 *     },
 * )
 */

alcaeus avatar May 23 '18 05:05 alcaeus

if it's possible to properly check coding standards in docblocks

It's possible but it's difficult. We'll see :)

kukulich avatar May 23 '18 06:05 kukulich

I like the idea, but this is Doctrine-specific. Although Doctrine Annotations are widespread enough so it should imho be fine here. My suggestion: Wait for Annotations 2.0, there will be proper grammar & grammar-based parser, maybe also AST. Should be fully backward compatible. :)

Majkl578 avatar May 23 '18 12:05 Majkl578