Skip to content

Instantly share code, notes, and snippets.

@puggan
Last active August 21, 2019 15:10
Show Gist options
  • Save puggan/2b668969917409c54ae2222ae147b2c2 to your computer and use it in GitHub Desktop.
Save puggan/2b668969917409c54ae2222ae147b2c2 to your computer and use it in GitHub Desktop.
PSR-12 extended by puggan

The base is PSR-12 from https://www.php-fig.org/psr/psr-12/

Here is some aditions that are allowed, but not enforced by PSR-12:

2.3 Lines

  • PSR-12 says:
    • Blank lines MAY be added to improve readability and to indicate related blocks of code except where explicitly forbidden.
  • I add:
    • There MUST NOT be more then one consecutive blank line.

3. Declare Statements, Namespace, and Import Statements

  • PSR-12 says:
    • Compound namespaces with a depth of more than two MUST NOT be used.
  • I add:
    • Compound namespaces MUST NOT be used.

5.1 if, elseif, else

  • PSR-12 says:
    • Boolean operators between conditions MUST always be at the beginning or at the end of the line, not a mix of both.
  • I add:
    • Boolean operators between conditions MUST always be at the end of the line.

6.1. Unary operators

  • PSR-12 says:
    • nothing about the ! operator
  • I add:
    • The ! Operator MUST NOT have any space between the operator and operand.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment