Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. if, elseif, while, for: need a space between the if keyword and the parentheses ().

    Code Block
    borderStylesolid
    if (<condition>)
    
    while (<condition>)
    
  2. When a combination of if and else is used and both can return a value, the else statement has to be omitted.

    Code Block
    borderStylesolid
    if (<condition>)
    	return false;
    return true;
    
    Note
    titleRecommendation

    We recommend you to use only one return statement per method/function.

  3. When a method/function returns a boolean and the current method/function's returned value depends on it, the if statement has to be avoided.

    Code Block
    borderStylesolid
    public aFirstMethod()
    {
    	return $this->aSecondMethod();
    }
    
  4. Tests must be grouped by entity.

    Code Block
    borderStylesolid
    if ($price AND&& !empty($price))
    	...
    if (!Validate::$myObject OR|| $myObject->id === NULL)
    	...
    

...

  1. It is forbidden to use a ternary into another ternary, such as echo ((true ? 'true' : false) ? 't' : 'f');.
  2. We recommend the use of && and || into your conditions instead of AND and OR: echo ('X' == 0 && 'X' == true).
  3. Please refrain from using reference parameters, such as:

    Code Block
    function is_ref_to(&$a, &$b) { ... }

...