Skip to content

Latest commit

 

History

History
59 lines (50 loc) · 1.88 KB

CODING_GUIDELINE.md

File metadata and controls

59 lines (50 loc) · 1.88 KB

CODING GUIDELINE

Fork the project, create a feature branch, and send us a pull request. Preferably on a distinct branch.

To ensure a consistent code base, you should make sure the code follows the PSR-12: Extended Coding Style. You can also run php-cs-fixer with the configuration file that can be found in the project root directory.

If you would like to help, take a look at the list of open issues.

PHPFASTCACHE's specialties

As of the V7 your contributions MUST comply the following standards:

PHP CORE FUNCTIONS

  • To improve Opcode efficiency, you MUST prefix core function by a '\'
    • E.g: $var = \str_replace('value', '', $var);

PHP CORE CONSTANTS

  • To improve Opcode efficiency, you MUST prefix core constants by a '\'
    • E.g: $dateFormat = \DATE_ISO8601

PHP CORE CLASSES

  • Do not import non-namespaced classes, use an absolute path instead:
    • E.g: $date = new \DateTime();

CODE STYLE

  • Unneeded/inconsistent else statements have to be shortened.
    • E.g:
<?phpfunctionsetAcme($acme) { if ($acmeinstanceof Acme) { $this->acme = $acme; return$this; } else { thrownewphpFastCacheInvalidArgumentException('Invalid acme instance'); } }
  • This example can be safely replaced by this one:
<?phpfunctionsetAcme($acme) { if ($acmeinstanceof Acme) { $this->acme = $acme; return$this; } thrownewphpFastCacheInvalidArgumentException('Invalid acme instance'); }

Read this thread on StackExchange for more information This list is non-exhaustive and will may subject to evolve at any time.

close