Fork me on GitHub
a Sensio Labs Product

Oliva (v3.13.0) edition

Rule phpdoc_separation

Annotations in PHPDoc should be grouped together so that annotations of the same type immediately follow each other. Annotations of a different type are separated by a single blank line.

Configuration

groups

Sets of annotation types to be grouped together.

Allowed types: string[][]

Default value: [['deprecated', 'link', 'see', 'since'], ['author', 'copyright', 'license'], ['category', 'package', 'subpackage'], ['property', 'property-read', 'property-write']]

Examples

Example #1

Default configuration.

--- Original
+++ New
 <?php
 /**
  * Hello there!
  *
  * @author John Doe
+ *
  * @custom Test!
  *
  * @throws Exception|RuntimeException foo
+ *
  * @param string $foo
+ * @param bool   $bar Bar
  *
- * @param bool   $bar Bar
  * @return int  Return the number of changes.
  */

Example #2

With configuration: ['groups' => [['deprecated', 'link', 'see', 'since'], ['author', 'copyright', 'license'], ['category', 'package', 'subpackage'], ['property', 'property-read', 'property-write'], ['param', 'return']]].

--- Original
+++ New
 <?php
 /**
  * Hello there!
  *
  * @author John Doe
+ *
  * @custom Test!
  *
  * @throws Exception|RuntimeException foo
+ *
  * @param string $foo
- *
  * @param bool   $bar Bar
  * @return int  Return the number of changes.
  */

Example #3

With configuration: ['groups' => [['author', 'throws', 'custom'], ['return', 'param']]].

--- Original
+++ New
 <?php
 /**
  * Hello there!
  *
  * @author John Doe
  * @custom Test!
+ * @throws Exception|RuntimeException foo
  *
- * @throws Exception|RuntimeException foo
  * @param string $foo
- *
  * @param bool   $bar Bar
  * @return int  Return the number of changes.
  */

Rule sets

The rule is part of the following rule sets:

@PhpCsFixer

Using the @PhpCsFixer rule set will enable the phpdoc_separation rule with the default config.

@Symfony

Using the @Symfony rule set will enable the phpdoc_separation rule with the default config.

The logo is © 2010-2022 Sensio Labs