Skip to content

Instantly share code, notes, and snippets.

@ancarda
Last active July 20, 2018 12:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ancarda/e55502638eaff7d3ff5ce1c94ca09475 to your computer and use it in GitHub Desktop.
Save ancarda/e55502638eaff7d3ff5ce1c94ca09475 to your computer and use it in GitHub Desktop.

Function Naming Conventions

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here.

Get Methods

Covers functions matching ^get. Requirements are as follows:

  • MUST type-hint an appropriate return type, such as string or bool.
  • MUST have exactly zero parameters.
  • MUST NOT call func_get_args(), or otherwise accept input out-of-band (parameter list).
  • MUST NOT mutate any data in the class parameters (either this or parent).

With Methods

Covers functions matching ^with. Requirements are as follows:

  • MUST exactly type-hint this return type: self
  • MUST have at-least one (1) parameter which SHOULD be type-hinted.
  • MUST NOT call func_get_args(), or otherwise accept input out-of-band (parameter list).
  • MUST NOT mutate any data in the class parameters (either this or parent).
  • MUST clone $this exactly once.
  • SHOULD do input verification of some kind, especially if the parameter wasn't type hinted.

Set Methods

Covers functions matching ^set. Requirements are as follows:

  • MUST exactly type-hint no return type (void).
  • MUST have at-least one (1) parameter which SHOULD be type-hinted.
  • MUST NOT call func_get_args(), or otherwise accept input out-of-band (parameter list).
  • MUST mutate at-least one class parameter (either this or parent).
  • SHOULD do input verification of some kind, especially if the parameter wasn't type hinted.

Is Methods

Covers functions matching ^is, ^has, ^was, and ^did. Requirements are as follows:

  • MUST exactly type-hint this return type: bool.
  • MUST have exactly zero parameters.
  • MUST NOT call func_get_args(), or otherwise accept input out-of-band (parameter list).
  • MUST NOT mutate any data in the class parameters (either this or parent).
  • MUST read at-least one class parameter (either this or parent).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment