diff --git a/contrib/smarty/plugins/block.render.php b/contrib/smarty/plugins/block.render.php
index ba57fe4d0c5b08ed757b7df4766fc4f31834236d..67b988d0cd74bee9b9fc06e1a9ae6b770947b0dc 100644
--- a/contrib/smarty/plugins/block.render.php
+++ b/contrib/smarty/plugins/block.render.php
@@ -74,8 +74,6 @@ function smarty_block_render($params, $text, &$smarty)
     "\\1 \\2"
   );
 
-  $text = preg_replace($from, $to, $text);
-
-  return $text;
+  return preg_replace($from, $to, $text);
 }
 ?>
diff --git a/html/class_passwordRecovery.inc b/html/class_passwordRecovery.inc
index 569fdb62c5a69a91364a288c34ba91e799c79177..c775e96990b003ffbeb7827ac4cd646319fecc59 100644
--- a/html/class_passwordRecovery.inc
+++ b/html/class_passwordRecovery.inc
@@ -218,8 +218,7 @@ class standAlonePage {
     foreach ($keys as $key) {
       $params .= "&$key=".urlencode($this->$key);
     }
-    $params = preg_replace('/^&/', '?', $params);
-    return $params;
+    return preg_replace('/^&/', '?', $params);
   }
 
   static function generateRandomHash()
@@ -566,9 +565,9 @@ class passwordRecovery extends standAlonePage {
     @DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $reinit_link, 'Setting link to');
 
     /* Send the mail */
-    $mail_body = sprintf($this->mail_body, $this->login, $reinit_link);
+    $body = sprintf($this->mail_body, $this->login, $reinit_link);
 
-    if (mail_utf8($this->email_address, FALSE, $this->from_mail, $this->mail_subject, $mail_body)) {
+    if (mail_utf8($this->email_address, FALSE, $this->from_mail, $this->mail_subject, $body)) {
       $this->step = 3;
     } else {
       $this->message[] = msgPool::invalid(_("Contact your administrator, there was a problem with mail server"));
@@ -641,9 +640,9 @@ class passwordRecovery extends standAlonePage {
     }
 
     /* Send the mail */
-    $mail_body = sprintf($this->mail2_body, $this->login);
+    $body = sprintf($this->mail2_body, $this->login);
 
-    if (mail_utf8($this->email_address, FALSE, $this->from_mail, $this->mail2_subject, $mail_body)) {
+    if (mail_utf8($this->email_address, FALSE, $this->from_mail, $this->mail2_subject, $body)) {
       $smarty = get_smarty();
       $this->step = 5;
       $smarty->assign('changed', TRUE);
diff --git a/html/include/datepicker.js b/html/include/datepicker.js
index 909099b96cbcd06ff6097e0d1074efc8842923b0..2edabb72af84c239c91097d2e276cf114342b39d 100644
--- a/html/include/datepicker.js
+++ b/html/include/datepicker.js
@@ -483,7 +483,7 @@ DatePicker.prototype  = {
         default:
           Effect.Fade(this._id_datepicker, {  duration : this._closeEffectDuration });
         break;
-      };
+      }
     } else {
       $(this._id_datepicker).hide();
     }
@@ -533,7 +533,7 @@ DatePicker.prototype  = {
     try {
       while ( tbody.hasChildNodes() )
       tbody.removeChild(tbody.childNodes[0]);
-    } catch ( e ) {};
+    } catch ( e ) {}
 
     /* generate day headers */
     var trDay = new Element('tr');
diff --git a/html/include/fusiondirectory.js b/html/include/fusiondirectory.js
index 1bf81670aaab84754f9836e6f13563da94c9e935..f55608b152e320dc0653b189b1ecf3a7839b0bff 100644
--- a/html/include/fusiondirectory.js
+++ b/html/include/fusiondirectory.js
@@ -124,7 +124,7 @@ function focus_field()
     i++;
   }
 
-  if (element && found) {
+  if (element) {
     element.blur();
     element.focus();
   }
diff --git a/html/main.php b/html/main.php
index 33ee1bfe8a05cc9f4f084392ed093023a6e6b833..1fe54dd68a6b1fcab0b9f561d9fe6848c8d1527e 100644
--- a/html/main.php
+++ b/html/main.php
@@ -197,10 +197,8 @@ if ($old_plugin_dir != $plugin_dir && $old_plugin_dir != "") {
 eval_sizelimit();
 
 /* Check for memory */
-if (function_exists("memory_get_usage")) {
-  if (memory_get_usage() > (to_byte(ini_get('memory_limit')) - 2048000 )) {
-    msg_dialog::display(_("Configuration error"), _("Running out of memory!"), WARNING_DIALOG);
-  }
+if (memory_get_usage() > (to_byte(ini_get('memory_limit')) - 2048000 )) {
+  msg_dialog::display(_("Configuration error"), _("Running out of memory!"), WARNING_DIALOG);
 }
 
 /* Redirect on back event */
@@ -293,14 +291,13 @@ $smarty->assign("contents", $display);
 $smarty->assign("sessionLifetime", $config->get_cfg_value("sessionLifetime", 60 * 60 * 2));
 
 /* If there's some post, take a look if everything is there... */
-if (isset($_POST) && count($_POST)) {
-  if (!isset($_POST['php_c_check'])) {
-    msg_dialog::display(
-            _("Configuration Error"),
-            sprintf(_("Fatal error: not all POST variables have been transfered by PHP - please inform your administrator!")),
-            FATAL_ERROR_DIALOG);
-    exit();
-  }
+if (isset($_POST) && count($_POST) && !isset($_POST['php_c_check'])) {
+  msg_dialog::display(
+    _('Configuration Error'),
+    sprintf(_('Fatal error: not all POST variables have been transfered by PHP - please inform your administrator!')),
+    FATAL_ERROR_DIALOG
+  );
+  exit();
 }
 
 /* Assign errors to smarty */
diff --git a/include/class_CopyPasteHandler.inc b/include/class_CopyPasteHandler.inc
index 4604791764cfd57dfe764da8cdd4f2927b29b209..9315f038e1bc1aa26491402fce2d0d92196c3b2a 100644
--- a/include/class_CopyPasteHandler.inc
+++ b/include/class_CopyPasteHandler.inc
@@ -131,7 +131,7 @@ class CopyPasteHandler
    */
   function entries_queued()
   {
-    return ((count($this->queue) > 0) || ($this->current != FALSE));
+    return ((count($this->queue) > 0) || ($this->current !== FALSE));
   }
 
   /*!
@@ -190,9 +190,8 @@ class CopyPasteHandler
         $cut_acl  = $ui->is_cutable($entry['dn'], $entry['aclCategory'], $entry['mainTab']);
 
         /* Check permissions */
-        if (($entry['method'] == 'copy') && !$copy_acl) {
-          $this->disallowed_objects[$key] = $entry;
-        } elseif (($entry['method'] == 'cut') && !$cut_acl) {
+        if ( (($entry['method'] == 'copy') && !$copy_acl)
+          || (($entry['method'] == 'cut') && !$cut_acl)) {
           $this->disallowed_objects[$key] = $entry;
         } else {
           $this->clean_objects[$key] = $entry;
@@ -255,9 +254,7 @@ class CopyPasteHandler
       }
       if ($this->current) {
         $display = $this->current['object']->execute();
-        if ($this->current['object']->dialogOpened()) {
-          return $display;
-        } else {
+        if (!$this->current['object']->dialogOpened()) {
           // Display ok, (apply) and cancel buttons
           $display .= '<p class="plugbottom">'."\n";
           $display .= '<input type="submit" name="edit_finish" style="width:80px" value="'.msgPool::okButton().'"/>'."\n";
@@ -265,8 +262,8 @@ class CopyPasteHandler
           $display .= '<input type="submit" name="abort_current_cut-copy_operation" value="'.msgPool::cancelButton().'"/>'."\n";
           $display .= '<input type="submit" name="abort_all_cut-copy_operations" value="'._('Cancel all').'"/>'."\n";
           $display .= '</p>';
-          return $display;
         }
+        return $display;
       }
     }
     return '';
diff --git a/include/class_IconTheme.inc b/include/class_IconTheme.inc
index 3b892ea9f90a8d889e67a0b801cdef870641e764..f0482a04e393babb4fb3e6e3574c6456bec5bfaa 100644
--- a/include/class_IconTheme.inc
+++ b/include/class_IconTheme.inc
@@ -71,9 +71,9 @@ class IconThemeDir
     switch ($this->Type) {
       case 'Fixed':
         return ($this->Size == $size);
-      default:
       case 'Threshold':
       case 'Scalable':
+      default:
         return (($this->MinSize <= $size) && ($size <= $this->MaxSize));
     }
   }
@@ -83,9 +83,9 @@ class IconThemeDir
     switch ($this->Type) {
       case 'Fixed':
         return abs($this->Size - $size);
-      default:
       case 'Threshold':
       case 'Scalable':
+      default:
         if ($size < $this->MinSize) {
           return $this->MinSize - $size;
         }
@@ -149,11 +149,11 @@ class IconTheme
     }
 
     if ($this->parent !== NULL) {
-      $parent = $this->findTheme($this->parent);
-      if ($parent === NULL) {
-        $parent = $this->findTheme(static::$default_theme);
+      $parentTheme = $this->findTheme($this->parent);
+      if ($parentTheme === NULL) {
+        $parentTheme = $this->findTheme(static::$default_theme);
       }
-      return $parent->FindIconHelper($context, $icon, $size);
+      return $parentTheme->FindIconHelper($context, $icon, $size);
     }
 
     return NULL;
diff --git a/include/class_Language.inc b/include/class_Language.inc
index d15453854104bcb61f3f8a2641969744c39a8b77..5790aa99ba3e8b4884ab45cf29cd36130260ad6f 100644
--- a/include/class_Language.inc
+++ b/include/class_Language.inc
@@ -42,7 +42,7 @@ class Language
       $lang = static::detect();
     }
 
-    list ($language, $country, $char) = parse_gettext_lang($lang);
+    list ($language, , $char) = parse_gettext_lang($lang);
     putenv('LANGUAGE=');
     putenv("LANG=$lang");
     $langset = setlocale(LC_ALL, $lang, $language.'.'.$char);
diff --git a/include/class_config.inc b/include/class_config.inc
index 6251bb6369ffc5ded10b4eab41c1e0f338482d24..579e3f6122e9f66f7ac4c173e2b82e812683cc6a 100644
--- a/include/class_config.inc
+++ b/include/class_config.inc
@@ -981,11 +981,11 @@ class config
 
           if (isset($this->data['OBJECTS'][$obj])) {
             $this->data['OBJECTS'][$obj]['management'] = $class;
-            if (isset($class::$skipTemplates) && ($class::$skipTemplates == FALSE)) {
+            if (isset($class::$skipTemplates) && !$class::$skipTemplates) {
               $this->data['OBJECTS'][$obj]['templateActive']  = TRUE;
               $this->data['CATEGORIES'][$cat]['classes'][]    = 'template';
             }
-            if (isset($class::$skipSnapshots) && ($class::$skipSnapshots == FALSE)) {
+            if (isset($class::$skipSnapshots) && !$class::$skipSnapshots) {
               $this->data['OBJECTS'][$obj]['snapshotActive']  = TRUE;
               $this->data['CATEGORIES'][$cat]['classes'][]    = 'SnapshotHandler';
             }
diff --git a/include/class_divSelectBox.inc b/include/class_divSelectBox.inc
index 6d9b56c94fe75a1c7e332fccaa05594cc11ea187..5da72beb0e0768b1e6c87d22f9ffe25f7d101d2e 100644
--- a/include/class_divSelectBox.inc
+++ b/include/class_divSelectBox.inc
@@ -1,9 +1,8 @@
 <?php
-
 /*
   This code is part of FusionDirectory (http://www.fusiondirectory.org/)
   Copyright (C) 2003-2010  Cajus Pollmeier
-  Copyright (C) 2011-2016  FusionDirectory
+  Copyright (C) 2011-2018  FusionDirectory
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -119,8 +118,7 @@ class divSelectBox
    */
   function _numentries()
   {
-    $cnt = count($this->a_entries);
-    return $cnt;
+    return count($this->a_entries);
   }
 
   /*!
@@ -157,13 +155,9 @@ class divSelectBox
    */
   function _generateBody()
   {
-    $s_value  = '';
-    $s_key    = '';
-    $s_return = '';
-    $str      = '';
-
     /* If divselectbox is empty, append a single white entry */
     if (count($this->a_entries) == 0) {
+      $str = '';
       if ($this->headers !== FALSE) {
         $this->cols = count($this->headers);
         $str .= '<tr>';
@@ -181,8 +175,9 @@ class divSelectBox
       return $str;
     }
 
+    $s_return = '';
     $i = $this->_numEntries();
-    foreach ($this->a_entries as $s_key => $s_value) {
+    foreach ($this->a_entries as $s_value) {
       $i--;
 
       $s_return .= "\n<tr>";
diff --git a/include/class_filter.inc b/include/class_filter.inc
index 7517105cfab6e8ac66996f1dbb85072f8437d628..b578e79300fdd6ab5ef1ca0542f04c566de1ac8a 100644
--- a/include/class_filter.inc
+++ b/include/class_filter.inc
@@ -184,13 +184,12 @@ class filter
   function getCheckbox($element)
   {
     $tag      = $element['tag'];
-    $checked  = "";
-    if ($this->elementValues[$tag] == "true") {
-      $checked = " checked";
+    $checked  = '';
+    if ($this->elementValues[$tag] == 'true') {
+      $checked = ' checked="checked"';
     }
 
-    $result = "<input class='filter_checkbox' id='$tag' name='$tag' type='checkbox' onClick='document.mainform.submit();' value='true'$checked>";
-    return $result;
+    return '<input type="checkbox" class="filter_checkbox" id="'.$tag.'" name="'.$tag.'" onClick="document.mainform.submit();" value="true"'.$checked.'/>';
   }
 
   /*!
diff --git a/include/class_ldap.inc b/include/class_ldap.inc
index bf5db49ea999459febebfc535705866a205bcf99..1b367ca7406b216ac33aa76d0a695adc54114fb7 100644
--- a/include/class_ldap.inc
+++ b/include/class_ldap.inc
@@ -261,8 +261,8 @@ class LDAP
         case 'one':
           $this->sr[$srp] = @ldap_list($this->cid, $this->basedn, $filter, $attrs);
           break;
-        default:
         case 'subtree':
+        default:
           $this->sr[$srp] = @ldap_search($this->cid, $this->basedn, $filter, $attrs);
           break;
       }
@@ -348,8 +348,7 @@ class LDAP
         $this->connect();
       }
       $res  = @ldap_read($this->cid, $dn, $filter, array("objectClass"));
-      $rv   = @ldap_count_entries($this->cid, $res);
-      return $rv;
+      return @ldap_count_entries($this->cid, $res);
     } else {
       $this->error = "Could not connect to LDAP server";
       return FALSE;
@@ -859,13 +858,13 @@ class LDAP
   /*!
    * \brief Get the LDAP additional error
    *
-   * \return string $error containts LDAP_OPT_ERROR_STRING
+   * \return string containts LDAP_OPT_ERROR_STRING
    */
   function get_additional_error()
   {
-    $error = "";
-    @ldap_get_option ($this->cid, LDAP_OPT_ERROR_STRING, $error);
-    return $error;
+    $additional_error = '';
+    @ldap_get_option ($this->cid, LDAP_OPT_ERROR_STRING, $additional_error);
+    return $additional_error;
   }
 
   /*!
@@ -1186,12 +1185,9 @@ class LDAP
    */
   function get_objectclasses($force_reload = FALSE)
   {
-    $objectclasses = array();
-
     /* Return the cached results. */
     if (class_available('session') && session::global_is_set('LDAP_CACHE::get_objectclasses') && !$force_reload) {
-      $objectclasses = session::global_get('LDAP_CACHE::get_objectclasses');
-      return $objectclasses;
+      return session::global_get('LDAP_CACHE::get_objectclasses');
     }
 
     // Get base to look for schema
diff --git a/include/class_listing.inc b/include/class_listing.inc
index 2a2276264a43f8bee0aad5cf00a13b4f20929f73..e5bbeaf87a6330b90356b5d45e380a4bbb1be4c7 100644
--- a/include/class_listing.inc
+++ b/include/class_listing.inc
@@ -59,7 +59,6 @@ class listing
   protected $snapshotHandler  = NULL;
   var $exporter       = array();
   var $exportColumns  = array();
-  var $height         = 0;
   var $scrollPosition = 0;
   var $baseSelector;
   protected $filterCache = array();
@@ -139,16 +138,6 @@ class listing
     $this->copyPasteHandler = $handler;
   }
 
-  /*!
-   * \brief Set the height
-   *
-   * \param integer $height
-   */
-  function setHeight($height)
-  {
-    $this->height = $height;
-  }
-
   /*!
    * \brief Set a SnapshotHandler
    *
@@ -352,11 +341,6 @@ class listing
     // Initialize list
     $result = '<input type="hidden" value="'.$this->pid.'" name="PID"/>'."\n";
     $result .= '<input type="hidden" name="position_'.$this->pid.'" id="position_'.$this->pid.'"/>'."\n";
-    $height = 450;
-    if ($this->height != 0) {
-      $result .= '<input type="hidden" value="'.$this->height.'" id="d_height"/>'."\n";
-      $height = $this->height;
-    }
 
     $result .= '<div id="d_scrollbody" style="width:100%;">'."\n";
     $result .= '<table style="width:100%;" id="t_scrolltable" class="listingTable">'."\n";
@@ -756,9 +740,7 @@ class listing
     }
 
     // Watch out for filters and prepare to execute them
-    $data = $this->processElementFilter($table, $index, $data, $cfg, $row);
-
-    return $data;
+    return $this->processElementFilter($table, $index, $data, $cfg, $row);
   }
 
 
@@ -1431,6 +1413,8 @@ class listing
         case 'daemon':
           $result .= $this->renderDaemonMenu($separator);
           break;
+
+        default:
       }
 
       $separator = "";