You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running Laravel Pint locally without modifying the file layout, no changes are applied, but adding an extra newline triggers reordering and spacing fixes. This inconsistency can lead to unexpected modifications in trait ordering and blank-line placement. It appears that the interaction between the class_attributes_separation, ordered_traits, and related fixers depends on subtle differences in the file’s layout. Moreover, when run on GitHub Actions, Pint applies a change or break the pipeline that isn’t caught locally.
I suspect this behavior results from the order in which the fixers are applied. It would be helpful to determine if there is a way to control or change the order of fixers applied by Laravel Pint (or PHP-CS-Fixer?) so that the output is consistent regardless of minor whitespace differences.
I am willing to contribute code to help resolve this issue, but I need guidance on the proper approach for controlling the fixers' order or handling inline comments with trait uses.
Steps To Reproduce
I have a file like this
classPRextends BaseModel
{
// uncomment to enable raw datause RawDataTrait;
// uncomment to enable compressionuse CompressorTrait;
use HasFactory;
}
classPRextends BaseModel
{
// uncomment to enable compressionuse CompressorTrait;
use HasFactory;
// uncomment to enable raw datause RawDataTrait;
}
If I run the command again, no changes will be applied.
Modify the File:
Add an extra newline after the last trait so that the snippet becomes:
classPRextends BaseModel
{
// uncomment to enable compressionuse CompressorTrait;
use HasFactory;
// uncomment to enable raw datause RawDataTrait;
<---- here has a new line now
}
Why it does not fix when I run the command again without adding an extra line?
Is there a way to change the sequence of fixes applied
Is it a php-cs-fixer issue or is there something the I can do here to avoid it
I know that it is a major bug, but I would like to understand and see if I can avoid it or even see if there is a way to contribute with code.
The text was updated successfully, but these errors were encountered:
thiagovictorino
changed the title
Inconsistent Trait Ordering and Spacing Fixes When Running Laravel Pint
Inconsistent trait ordering and spacing fixes when running Pint
Feb 4, 2025
Pint Version
1.20
PHP Version
8.1.31
Description
When running Laravel Pint locally without modifying the file layout, no changes are applied, but adding an extra newline triggers reordering and spacing fixes. This inconsistency can lead to unexpected modifications in trait ordering and blank-line placement. It appears that the interaction between the
class_attributes_separation
,ordered_traits
, and related fixers depends on subtle differences in the file’s layout. Moreover, when run on GitHub Actions, Pint applies a change or break the pipeline that isn’t caught locally.I suspect this behavior results from the order in which the fixers are applied. It would be helpful to determine if there is a way to control or change the order of fixers applied by Laravel Pint (or PHP-CS-Fixer?) so that the output is consistent regardless of minor whitespace differences.
I am willing to contribute code to help resolve this issue, but I need guidance on the proper approach for controlling the fixers' order or handling inline comments with trait uses.
Steps To Reproduce
It applied the following rules
Changing the class that now looks like
If I run the command again, no changes will be applied.
Add an extra newline after the last trait so that the snippet becomes:
Run the command again
Now the applied rules were
And the file changed to
My
pint.json
isMy main questions are
php-cs-fixer
issue or is there something the I can do here to avoid itI know that it is a major bug, but I would like to understand and see if I can avoid it or even see if there is a way to contribute with code.
The text was updated successfully, but these errors were encountered: