techdeco/coding-standard

Coding Standard for projects of Frank Koornstra

This package's canonical repository appears to be gone and the package has been frozen as a result.

Installs: 241

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:phpcodesniffer-standard

v1.0.0 2018-02-10 11:14 UTC

This package is auto-updated.

Last update: 2020-06-06 00:05:25 UTC


README

Customised PHPCS ruleset to standardise the style of my projects

Standards

The coding standard is based on PSR-1 and PSR-2, with some noticeable exceptions/differences/extensions (✅ are the implemented sniffs):

  • Keep the nesting of control structures per method as small as possible
  • Prefer early exit over nesting conditions or using else
  • ✅ Align equals (=) signs in assignments
  • ✅ Add spaces around a concatenation operator $foo = 'Hello ' . 'World!';
  • ✅ Add spaces between assignment, control and return statements
  • ✅ Add spaces after a negation operator if (! $cond)
  • ✅ Add spaces around a colon in return type declaration function () : void {}
  • ✅ Add spaces after a type cast $foo = (int) '12345';
  • ✅ Use apostrophes for enclosing strings
  • ✅ Always use strict comparisons
  • ✅ Always add declare(strict_types=1) at the beginning of a file
  • ✅ Always add native types where possible
  • ✅ Omit phpDoc for parameters/returns with native types, unless adding description
  • ✅ Don't use @author, @since and similar annotations that duplicate Git information
  • ✅ Assignment in condition is not allowed

More info: