for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Sign;
class Param {
private $_value;
private $_size;
private $_bound = false;
private $_pad = STR_PAD_RIGHT;
public function setValue($value) {
$this->_value = $value;
$this->_bound = true;
}
public function align($type) {
switch ($type) {
case 'left': $this->_pad = STR_PAD_RIGHT;break;
According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.
switch ($expr) { case "A": doSomething(); //right break; case "B": doSomethingElse(); //wrong break;
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.
As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.
break
switch ($expr) { case "A": doSomething(); break; //wrong case "B": doSomething(); break; //right case "C:": doSomething(); return true; //right }
case 'center': $this->_pad = STR_PAD_BOTH;break;
case 'right': $this->_pad = STR_PAD_LEFT;break;
$this->_align = $type;
_align
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
public function value() {
$value = str_pad($this->_value, $this->_size, ' ', $this->_pad);
return $value;
public function bound() {
return $this->_bound;
public function __construct($size) {
$this->_size = $size;
According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.