Fork me on GitHub
a Sensio Labs Product

Folding Bike (v3.91.3) edition

Rule multiline_promoted_properties

Promoted properties must be on separate lines.

Warnings

This rule is EXPERIMENTAL

Rule is not covered with backward compatibility promise and may produce unstable or unexpected results, use it at your own risk. Rule’s behaviour may be changed at any point, including rule’s name; its options’ names, availability and allowed values; its default configuration. Rule may be even removed without prior notice. Feel free to provide feedback and help with determining final state of the rule.

This rule is CONFIGURABLE

You can configure this rule using the following options: keep_blank_lines, minimum_number_of_parameters.

Configuration

keep_blank_lines

Whether to keep blank lines between properties.

Allowed types: bool

Default value: false

minimum_number_of_parameters

Minimum number of parameters in the constructor to fix.

Allowed types: int

Default value: 1

Examples

Example #1

Default configuration.

--- Original
+++ New
 <?php
 class Foo {
-    public function __construct(private array $a, private bool $b, private int $i) {}
+    public function __construct(
+        private array $a,
+        private bool $b,
+        private int $i
+    ) {}
 }

Example #2

With configuration: ['minimum_number_of_parameters' => 3].

--- Original
+++ New
 <?php
 class Foo {
-    public function __construct(private array $a, private bool $b, private int $i) {}
+    public function __construct(
+        private array $a,
+        private bool $b,
+        private int $i
+    ) {}
 }
 class Bar {
     public function __construct(private array $x) {}
 }

References

The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.