Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

evgeny-laravel's avatar

Laravel Pint: How to make formatting of empty classes and methods the same as non-empty ones?

Here is the code for my pint.json file:

{
  "preset": "laravel",
  "rules": {
    "not_operator_with_successor_space": false,
    "concat_space": {
      "spacing": "one"
    },
    "class_attributes_separation": {
      "elements": {
        "method": "one"
      }
    },
    "array_syntax": {
      "syntax": "short"
    },
    "list_syntax": {
      "syntax": "long"
    },
    "braces": {
      "position_after_functions_and_oop_constructs": "next"
    }
  }
}

The project has this code:

namespace App\Providers;

class SomeClass1
{
    public function register(): void
    {
    }
}

Laravel Pint changes it to this code:

class SomeClass1
{
    public function register(): void {}
}

The same goes for the class. The project has this code:

class SomeClass2
{
}

Laravel Pint changes it to this code:

class SomeClass2 {}

I do not like it. I want the formatting of empty classes and methods to look the same as non-empty ones. How can I prevent Laravel Pint from removing newlines from empty methods and classes?

0 likes
4 replies
aleahy's avatar

I set this in the pint.json to achieve that:

"single_line_empty_body": false
Tray2's avatar

@aleahy Yeah, but it is not configurable

Summary Empty body of class, interface, trait, enum or function must be abbreviated as {} and placed on the same line as the previous symbol, separated by a single space. Used in presets @PER@[email protected]@PhpCsFixer@Symfony Configuration This fixer is not configurable

aleahy's avatar

@Tray2 True, but at least it turns it off and prevents pint from modifying all your files if your project is already set up with the braces on two lines.

Please or to participate in this conversation.