Search code examples
phpphpstorm

Prevent PhpStorm from arranging constructor arguments like a table


The arguments of my constructor are written on different lines. When I press Ctrl+Alt+Shift+L to format code PhpStorm adds spaces to the shorter argument types so that the columns become of equal length.

I can't figure out which code style settings is responsible for that. I want to disable it.

What it does:

public function __construct(
    AdvertisingDetailsAdapter $advertisingDetailsAdapter,
    AdAccountService          $adAccountService,
    BusinessManagerService    $businessManagerService
)

What I want:

public function __construct(
    AdvertisingDetailsAdapter $advertisingDetailsAdapter,
    AdAccountService $adAccountService,
    BusinessManagerService $businessManagerService
)

Solution

  • I believe the relevant configuration toggle is shown on the picture

    enter image description here

    If the picture does not load:

    1. Press Alt+F7 to open the Settings (or choose File => Settings from the main menu)
    2. In the settings dialog, navigate to Editor => Code Style => PHP (from the left pane)
    3. In the right pane, choose the tab Wrapping and Brances
    4. Inside that tab, untoggle the checkmark (tick) from the setting Function declaration parameters => Align when multiline