Last active
January 31, 2022 15:50
-
-
Save hxtree/d4eca6bba3f4d3cb17d82decc6095cd0 to your computer and use it in GitHub Desktop.
PHP Naming Methods Recommendation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Formula | |
METHOD_NAME = [CONTEXT] + VERB + [HOW] | |
METHOD_NAME | |
Must use camelCase (reference Zend Certificated Engineer study manual, Composer, and PSR standards). | |
Must not start with “__” unless it’s a predefined magic method. | |
Must start with an alphabetical character. | |
CONTEXT | |
Should be a noun. | |
Should be the name of the thing modified by VERB. | |
Should be omitted if the CONTEXT is implied by object. | |
VERB | |
Required. | |
Should be the name of the function that is being performed. | |
Should be based on a defined list of house terms (e.g. get, load, fetch). | |
Reference thesaurus for assistance. | |
`is` and `has` indicate and should be used to indicate boolean return types. | |
HOW | |
Should be omitted if parameters are optional. | |
May be omitted if multiple parameters are required. | |
Prefixed by the word "By". | |
Examples | |
$doc->loadByPath($path); | |
$user->loadByName($username); | |
$user->armDisableById($id); | |
$user->add($username, $id); | |
$user->load(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment