Reputation: 3293
I frequently use single-line comments at the end of a statement. One such case is the use
statement at the beginning of a class definition to add traits to the class. My project uses Laravel and other packages, so I often put a URL in the comment after the use
. In other cases, I use these comments to indicate what functionality is being added to the class by the trait.
I use PHP CS Fixer through Laravel Pint to clean up my code. I run Pint rather frequently so that I can focus on coding and clean it up later before I commit. My project's composer.json currently specifies version "^1.2" for Pint.
I composer update
d my project a day or so and I'm running into a very disruptive problem with the aforementioned comments. They are being separated from the use
commands they followed. For example, in one class I had this series of use
statements:
use \Illuminate\Database\Eloquent\Factories\HasFactory; // adds the factory static methods
use \App\Methods\SetCasts;
use \Illuminate\Database\Eloquent\SoftDeletes; // https://laravel.com/docs/9.x/eloquent#soft-deleting
After running Pint, this code was changed to the following:
// adds the factory static methods
use \App\Methods\SetCasts;
use \Illuminate\Database\Eloquent\Factories\HasFactory;
use \Illuminate\Database\Eloquent\SoftDeletes; // https://laravel.com/docs/9.x/eloquent#soft-deleting
I do not have a problem with the sorting. The problem is that the comment // adds the factory static methods
was separated from the trait that it references.
How do I tell PHP CS Fixer to stop doing this and leave these particular comments alone?
Upvotes: 0
Views: 97