/**
  * Checks if the block of code need braces.
  *
  * This function is called we the current token is ) and we are in a control statement.
  */
 private function _checkNeedBraces()
 {
     if ($this->_isActive('needBraces')) {
         $stmt = strtolower($this->_currentStatement);
         if (in_array($stmt, array('if', 'elseif', 'do', 'for', 'foreach')) || $stmt == "while" && !$this->statementStack->getParentStackItem()->afterDoStatement) {
             if (!$this->tokenizer->checkNextValidToken(T_BRACES_OPEN)) {
                 $msg = $this->_getMessage('NEED_BRACES', $stmt);
                 $this->_writeError('needBraces', $msg);
             }
         } else {
             if ($stmt == "else") {
                 if (!$this->tokenizer->checkNextValidToken(T_BRACES_OPEN) && !$this->tokenizer->checkNextValidToken(T_IF)) {
                     $msg = $this->_getMessage('NEED_BRACES', $stmt);
                     $this->_writeError('needBraces', $msg);
                 }
             }
         }
         if ($stmt == "while") {
             $this->statementStack->getCurrentStackItem()->afterDoStatement = false;
         }
     }
 }