Page tree
Skip to end of metadata
Go to start of metadata

PSR-12: Extended Coding Style

  • Namespaces and classes MUST follow an “autoloading” PSR-0, PSR-4
  • Class names MUST be declared in StudlyCaps/PascalCase
  • CONSTANTS MUST be declared in all upper case with underscore separators
  • Method names MUST be declared in camelCase
  • Variable names MUST be written in camelCase and the name describe for what it is (not simply $item, better $termEntryTig)
  • UTF-8
  • Next file line delimiter: Unix
  • Tabs: 4 Spaces

Link to PSR-12 article: https://www.php-fig.org/psr/psr-12/

Principles:

  • YAGNI: You ain’t gonna need it (wiki)
  • KISS: Keep It Simple, Stupid (wiki)
  • DRY: Don’t Repeat Yourself (wiki)
  • SOLID: (wiki)
    - Single-Responsibility-Prinzip
    - Open-Closed-Prinzip
    - Liskovsches Substitutionsprinzip
    - Interface-Segregation-Prinzip
    - Dependency-Inversion-Prinzip


  • No labels

1 Comment

  1. seeeehr hilfreich wären immer kurze Beispiele.
    Bsp:

    • Class names MUST be declared in StudlyCaps/PascalCase

    bringt mir nicht so viel wie:

    • Class names MUST be declared in StudlyCaps/PascalCase. Sample: "ThisIsMyClassname"