It is mainly PSR-2 with a few exceptions.
- Opening braces MUST go on the same line, and MUST NOT have spaces before.
else if
MUST be written aselseif
. (It is in PSR-2, but using a SHOULD)- Control structure keywords or opening braces MUST NOT have one space before or after them.
- Code MUST use tabs for indenting.
- Long arrays MAY be split across multiple lines, where each subsequent line is indented once.
- Files MUST use only the
<?php
tag. - Files MUST NOT have an ending
?>
tag. - Code MUST use namespaces.
- Strings SHOULD use the double quote
"
except when the single quote is required. - All code SHOULD have parameter and type declarations where possible.
- Strict types SHOULD be enabled on new files where it is sensible to do so.
- All constant declarations SHOULD be preceded by a visibility modifier.
- Declare return type if the return type is clear.
<?php
declare(strict_types=1);
namespace alvin0319\TestCase;
class TestCase{
/** @var array */
private $config = [];
/** @var \mysqli */
protected $mysqli;
public function __construct(array $args, \mysqli $mysql){
$this->config = $args;
$this->mysqli = $mysqli;
}
public function getArgs() : array{
return $this->args;
}
public function getMysqli() : \mysqli{
return $this->mysqli;
}
public function setArgs(array $args) : void{
$this->config = $args;
}
}
Reference: PMMP Contributing.md