Code standards and style

Please follow our code standards and style when contributing to the project.

Note that all Mako repositories include a php-cs-fixer configuration file that enforces most of our coding standard and style requirements. It is recommended to have a php-cs-fixer integration installed for your text editor or IDE of choice so that you won't have to run the fixer manually.


Mako uses the PSR-1 coding standard and the PSR-4 autoloading standard.


Listed below you'll find a list of code style requirements that are currently not possible to handle using php-cs-fixer.


Mako namespaces should always be written in lower case:

// Correct

namespace mako\bar;

// Incorrect

namespace Mako\Bar;
Variables and properties

Variable and property names should always be written in lower camel case:

// Correct

$myVariable = null;

// Incorrect

$myvariable = null;

// Incorrect

$my_variable = null;


Braces associated with a control statement should always be on the next line, indented to the same level as the control statement:

public function foo(): void


Tabs should be used for indentation while spaces should be used to align code:


namespace foo;

class Bar
	public function hello(): void
		$string  = 'Hello ';
		$string .= 'World!';

		echo $string;

All classes, methods and functions are commented using the PHPDoc standard.

This makes it easy to understand what the code does and it also enables IDEs to provide improved code completion, type hinting and debugging.

 * Returns a greeting.
 * @param  string $name Name of the person you want to greet
 * @return string
public function greeting(string $name): string
	return 'Hello, ' . $name . '!';

Double slash (//) comments should be used for all inline comments:

// This is correct