Functions

  • All functions MUST be namespaced with the full module or theme name as a prefix.
  • A leading underscore MUST be prefixed to the function name for 'private' functions.
  • Private functions SHOULD never be called from outside of the module in which they are declared.
  • Private functions SHOULD be declared at the bottom of a file.
  • Functions MUST be documented with one of two types of comments:
    • a one-liner comment (referred to as 'one-liners' in the rest of this document) that is literally a one line summary only
      OR
    • a full description comment (referred to as 'docblocks' in the rest of this document) with a summary, parameters and result returned where appropriate.
  • Function documentation comments, both one-liners and docblocks, MUST comply with the Drupal API documentation standards for functions.
  • All function parameters (@param) and returned values (@return) MUST be documented if using docblocks.
  • All parameters (@param) listed in docblocks SHOULD be type hinted to indicate the data types expected.
  • If values are returned as a result (@return) then docblocks MUST indicate the data types returned.

Please refer to RFC2119 for meaning of words MUST, SHOULD and MAY.

All donations are forwarded to Drupal Association.

Drupal is a registered trademark of Dries Buytaert.