laravel / pint

Laravel Pint is an opinionated PHP code style fixer for minimalists.

Home Page:https://laravel.com/docs/pint

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fixing indentation is broken in Laravel preset since 1.8.0

hjanos1 opened this issue · comments

Pint Version

1.9.0

PHP Version

8.2.0

Description

Fixing indentation is broken in the Laravel preset since #166 was merged.

This is caused by the statement_indentation rule not being enabled in the Laravel preset.

Before the above PR was merged, the rule was being run by the braces rule.

Resolution: statement_indentation rule should be enabled in the Laravel preset. Sending a PR.

Steps To Reproduce

  1. Edit a file so that the indentation is broken
  2. Run pint
  3. Formatting (indentation) should be fixed, but it is not.

Example on a new laravel project, edited app/Providers/AppServiceProvider.php:

➜  pint-test git:(master) ✗ cat app/Providers/AppServiceProvider.php
<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
/**
 * Register any application services.
 */
public function register(): void
{
       //
    }

    /**
     * Bootstrap any application services.
     */
    public function boot(): void
    {
        //
    }
}
➜  pint-test git:(master) ✗ ./vendor/bin/pint --version
Pint 1.9.0
➜  pint-test git:(master) ✗ ./vendor/bin/pint app/Providers/AppServiceProvider.php

  .

  ───────────────────────────────────────────────────────────────────────────────── Laravel
    PASS   ......................................................................... 1 file

Yeah that seems to fix it (see pint.json below).

I assumed there was a reason statement_indentation was already disabled beforehand and so I didn't touch it further.

{
    "preset": "laravel",
    "rules": {
        "statement_indentation": true
    }
}