Core: Style guide

Created on 27 Dec 2016  路  3Comments  路  Source: php-telegram-bot/core

Just a short issue to discuss a few style things.
I suggest we vote on these to agree on a certain style that we can all go by, to prevent to-and-fro overwrites of little things.

Following are just a few that have different variants in the codebase at the moment. Most things are already managed thanks to following PSR-2 guidelines, but some things need to be defined by us (or I haven't found the PSR-2 equivalent, in which case let me know please!)

(in these examples, I favour the first suggestions)

  • Type cast spacing: (int) $var vs. (int)$var
  • New line before return statements: 1 empty line vs. 0 empty lines
    lastLineOfCode();

    return $something;
}

vs.

    lastLineOfCode();
    return $something;
}
  • Align variable assignments (also for arrays): yes vs. no
$short        = 'short';
$a_bit_longer = 'a_bit_longer';

vs.

$short = 'short';
$a_bit_longer = 'a_bit_longer';

summoning @akalongman @MBoretto @jacklul

Most helpful comment

I am vote for each, except "Align variable assignments". I think align for arrays is good, but for variables - not.

All 3 comments

I am vote for each, except "Align variable assignments". I think align for arrays is good, but for variables - not.

Ok 馃憤
Initially I would have liked it like that as well and looked for an option in PhpStorm and thought there was only 1 option for both alignments. Now I looked again and found both, one for each setting. So I'm more than happy to have arrays aligned and assignments not.

First and second: first suggestions,
Third: Neutral, I'm fine with not using extra spaces at all unless it improves readability in those lines (DB.php lines 815+)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mohsenshahab picture mohsenshahab  路  4Comments

tchibomann picture tchibomann  路  3Comments

sayjeyhi picture sayjeyhi  路  3Comments

NabiKAZ picture NabiKAZ  路  3Comments

nesttle picture nesttle  路  4Comments