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

skoobi's avatar
Level 13

Php-cs-fixer Help

Hi.

I have got Php-cs-fixer up and running and its doing its thing, but I want it to automatically add a line above and below if else statements, i.e::

// from this 

if ($payment_type == 1) { // New Account
    $update_duration = $this->updateDuration($user, $duration);
    $update_balance = CustomerCreditBalance::where('user_id', $user->id)->update(['current' => 20 - ($balance_transaction->fee / 100),]);
    $account = CustomerAccount::where('user_id', $user->id)->update(['status_id' => 3]);
    $payment = Ledgers::save($user, $transaction_type, $cost, $charge->id, null, $payment_title . ' - ' . $user->username, null, null, 5, $balance_transaction->fee / 100, 'Stripe');
    event(new AccountSetupComplete($user, $payment));
} elseif ($payment_type == 2) {   // Renewal 2-3

// To this

if ($payment_type == 1) { // New Account

    $update_duration = $this->updateDuration($user, $duration);
    $update_balance = CustomerCreditBalance::where('user_id', $user->id)->update(['current' => 20 - ($balance_transaction->fee / 100),]);
    $account = CustomerAccount::where('user_id', $user->id)->update(['status_id' => 3]);
    $payment = Ledgers::save($user, $transaction_type, $cost, $charge->id, null, $payment_title . ' - ' . $user->username, null, null, 5, $balance_transaction->fee / 100, 'Stripe');
    event(new AccountSetupComplete($user, $payment));

} elseif ($payment_type == 2) {   // Renewal 2-3

Any ideas on how to do it. I can seem to find the settings in the docs.

Cheers

0 likes
2 replies
skoobi's avatar
Level 13

Cheers for the reply. I gave that a shot but it didn't do anything. Im not sure whats going on there. Ill give it another try in the morning just in case! Heres what I have in my .phpcsfixer

return PhpCsFixer\Config::create()
->setRules([
    '@PSR2' => true,
    'array_syntax' => ['syntax' => 'short'],
    'no_unused_imports' => true,
    'ordered_imports' => ['sort_algorithm' => 'alpha'],
    'blank_line_before_statement' => ['if']
])

Please or to participate in this conversation.