Skip to content

Latest commit

 

History

History
95 lines (63 loc) · 2.02 KB

single_class_element_per_statement.rst

File metadata and controls

95 lines (63 loc) · 2.02 KB

Rule single_class_element_per_statement

There MUST NOT be more than one property or constant declared per statement.

Configuration

elements

List of strings which element should be modified.

Allowed values: a subset of ['const', 'property']

Default value: ['const', 'property']

Examples

Example #1

Default configuration.

--- Original
+++ New
 <?php
 final class Example
 {
-    const FOO_1 = 1, FOO_2 = 2;
-    private static $bar1 = array(1,2,3), $bar2 = [1,2,3];
+    const FOO_1 = 1;
+    const FOO_2 = 2;
+    private static $bar1 = array(1,2,3);
+    private static $bar2 = [1,2,3];
 }

Example #2

With configuration: ['elements' => ['property']].

--- Original
+++ New
 <?php
 final class Example
 {
     const FOO_1 = 1, FOO_2 = 2;
-    private static $bar1 = array(1,2,3), $bar2 = [1,2,3];
+    private static $bar1 = array(1,2,3);
+    private static $bar2 = [1,2,3];
 }

Rule sets

The rule is part of the following rule sets:

  • @PER with config:

    ['elements' => ['property']]

  • @PER-CS with config:

    ['elements' => ['property']]

  • @PER-CS1.0 with config:

    ['elements' => ['property']]

  • @PER-CS2.0 with config:

    ['elements' => ['property']]

  • @PSR2 with config:

    ['elements' => ['property']]

  • @PSR12 with config:

    ['elements' => ['property']]

  • @PhpCsFixer

  • @Symfony

Source class

PhpCsFixer\Fixer\ClassNotation\SingleClassElementPerStatementFixer