Why is this an issue?

It is recommended not to declare more than one property per statement for the sake of code readability and maintainability. Declaring multiple properties in a single statement can make the code harder to understand and debug. It also increases the risk of introducing errors or overlooking specific property assignments.

How to fix it

By declaring one property per statement, developers can easily identify and modify individual properties, improving code clarity and reducing potential mistakes.

Code examples

Noncompliant code example

<?php
class Foo
{
   private $bar = 1, $bar2 = 2;
}

Compliant solution

<?php
class Foo
{
   private $bar1 = 1;
   private $bar2 = 2;
}

Resources

Documentation