diff --git a/include/class_ldapGeneralizedTime.inc b/include/class_ldapGeneralizedTime.inc
index 720d0c603379184e951da81ef30d31395c01d1c6..4d2b1db5a6513d9c7723f4d948f666eaf402d093 100644
--- a/include/class_ldapGeneralizedTime.inc
+++ b/include/class_ldapGeneralizedTime.inc
@@ -111,9 +111,8 @@ class LdapGeneralizedTime
     \param DateTime $date DateTime object to convert
     \param boolean $setToUTC Whether or not to set the date timezone to UTC. Defaults to TRUE.
   */
-  public static function toString ($date, $setToUTC = TRUE)
+  public static function toString (DateTime $date, $setToUTC = TRUE)
   {
-    assert($date instanceof DateTime);
     if ($setToUTC) {
       $date->setTimezone(new DateTimeZone('UTC'));
     }
diff --git a/include/functions.inc b/include/functions.inc
index 3188df56be4c05d745b1e47d5d7001a4d9e60a94..9cee2767f0cb0c2c0fc20a5b60a0625b776ed31c 100644
--- a/include/functions.inc
+++ b/include/functions.inc
@@ -365,13 +365,9 @@ function array_remove_entries_ics(array $needles, array $haystack)
  *
  * \return array
  */
-function array_merge_unique($ar1, $ar2)
+function array_merge_unique(array $ar1, array $ar2)
 {
-  if (!is_array($ar1) || !is_array($ar2)) {
-    trigger_error('Specified parameter(s) are not valid arrays.');
-  } else {
-    return array_values(array_unique(array_merge($ar1, $ar2)));
-  }
+  return array_values(array_unique(array_merge($ar1, $ar2)));
 }
 
 
@@ -1142,7 +1138,7 @@ function strict_uid_mode()
  *
  *
  */
-function gen_locked_message($locks, $dn, $allow_readonly = FALSE)
+function gen_locked_message(array $locks, $dn, $allow_readonly = FALSE)
 {
   session::set('dn', $dn);
   $remove = FALSE;
@@ -1463,7 +1459,7 @@ function _recurse_gen_uids($rule, $variables)
  *
  * \return array List of valid not used uids
  */
-function gen_uids($rule, $attributes)
+function gen_uids($rule, array $attributes)
 {
   global $config;
 
@@ -1894,7 +1890,7 @@ function array_key_ics($ikey, array $items)
  *
  * \return boolean TRUE or FALSE
  */
-function array_differs($src, $dst)
+function array_differs(array $src, array $dst)
 {
   /* If the count is differing, the arrays differ */
   if (count ($src) != count ($dst)) {
@@ -1952,7 +1948,7 @@ function normalizeLdap($input)
  *
  * \param string $cfg A config object
  */
-function check_schema($cfg)
+function check_schema(array $cfg)
 {
   $checks = array();
 
diff --git a/include/simpleplugin/attributes/class_BaseSelectorAttribute.inc b/include/simpleplugin/attributes/class_BaseSelectorAttribute.inc
index 9d0b9000c1eb1ae9e6a5e4a520868d8a21cd5cb6..73c5f185cfb27c702122894f0b2f1fc19ccf3d1d 100644
--- a/include/simpleplugin/attributes/class_BaseSelectorAttribute.inc
+++ b/include/simpleplugin/attributes/class_BaseSelectorAttribute.inc
@@ -46,7 +46,7 @@ class BaseSelectorAttribute extends Attribute
     $this->ou = $ou;
   }
 
-  function setManagedAttributes ($dontcare)
+  function setManagedAttributes (array $dontcare)
   {
     trigger_error('method setManagedAttributes is not supported for BaseSelectorAttribute');
   }
@@ -174,7 +174,7 @@ class BaseSelectorAttribute extends Attribute
     }
   }
 
-  function serializeAttribute(&$attributes, $form = TRUE)
+  function serializeAttribute(array &$attributes, $form = TRUE)
   {
     if (!$form || $this->visible) {
       parent::serializeAttribute($attributes, $form);
diff --git a/include/simpleplugin/attributes/class_BooleanAttribute.inc b/include/simpleplugin/attributes/class_BooleanAttribute.inc
index 78e343da64a691f87adf64991d0a778684ad4db0..877f80138cb195dfa4f59ec270fb2d8647000074 100644
--- a/include/simpleplugin/attributes/class_BooleanAttribute.inc
+++ b/include/simpleplugin/attributes/class_BooleanAttribute.inc
@@ -127,7 +127,7 @@ class ObjectClassBooleanAttribute extends BooleanAttribute
     $this->setInLdap(FALSE);
   }
 
-  function loadValue ($attrs)
+  function loadValue (array $attrs)
   {
     if (isset($attrs['objectClass'])) {
       $missing_oc = array_udiff($this->objectclasses, $attrs['objectClass'], 'strcasecmp');
@@ -138,7 +138,7 @@ class ObjectClassBooleanAttribute extends BooleanAttribute
     $this->initialValue = $this->value;
   }
 
-  function fillLdapValue (&$attrs)
+  function fillLdapValue (array &$attrs)
   {
     if ($this->getValue()) {
       $attrs['objectClass'] = array_merge_unique($this->objectclasses, $attrs['objectClass']);
diff --git a/include/simpleplugin/attributes/class_CompositeAttribute.inc b/include/simpleplugin/attributes/class_CompositeAttribute.inc
index 6c7d080da1b03b3f8f0429b0c84a9e934f936808..22f06fadb19deb38aa89f8ec34b3d84b43b94d2f 100644
--- a/include/simpleplugin/attributes/class_CompositeAttribute.inc
+++ b/include/simpleplugin/attributes/class_CompositeAttribute.inc
@@ -42,7 +42,7 @@ class CompositeAttribute extends Attribute
    *  \param string $acl The name of the acl for this attribute if he does not use its own. (Leave empty if he should use its own like most attributes do)
    *  \param string $label The label to show for this attribute. Only useful if you put this attribute inside a SetAttribute, or if you use a specific template that needs it.
    */
-  function __construct ($description, $ldapName, $attributes, $readFormat, $writeFormat, $acl = "", $label = NULL)
+  function __construct ($description, $ldapName, array $attributes, $readFormat, $writeFormat, $acl = "", $label = NULL)
   {
     if ($label === NULL) {
       $label = $ldapName;
@@ -53,7 +53,7 @@ class CompositeAttribute extends Attribute
     $this->setAttributes($attributes);
   }
 
-  function setAttributes ($attributes)
+  function setAttributes (array $attributes)
   {
     $this->attributes   = $attributes;
     foreach ($this->attributes as &$attribute) {
@@ -80,7 +80,7 @@ class CompositeAttribute extends Attribute
     unset($attribute);
   }
 
-  function setManagedAttributes ($dontcare)
+  function setManagedAttributes (array $dontcare)
   {
     trigger_error('method setManagedAttributes is not supported for CompositeAttribute');
   }
@@ -112,7 +112,7 @@ class CompositeAttribute extends Attribute
     return array_fill(0, count($this->attributes), '');
   }
 
-  function writeValues($values)
+  function writeValues(array $values)
   {
     if ($this->writeFormat === FALSE) {
       return $values;
@@ -213,7 +213,7 @@ class CompositeAttribute extends Attribute
     unset($attribute);
   }
 
-  function renderAttribute(&$attributes, $readOnly)
+  function renderAttribute(array &$attributes, $readOnly)
   {
     if ($this->visible) {
       if ($this->linearRendering) {
@@ -238,7 +238,7 @@ class CompositeAttribute extends Attribute
     }
   }
 
-  function serializeAttribute(&$attributes, $form = TRUE)
+  function serializeAttribute(array &$attributes, $form = TRUE)
   {
     if ($form) {
       if ($this->visible) {
diff --git a/include/simpleplugin/attributes/class_DateAttribute.inc b/include/simpleplugin/attributes/class_DateAttribute.inc
index 7b19e65216de64fa13f2e175153492d147b411ea..59d1587d6a2f6627a354acfe058273d590d94df2 100644
--- a/include/simpleplugin/attributes/class_DateAttribute.inc
+++ b/include/simpleplugin/attributes/class_DateAttribute.inc
@@ -81,7 +81,7 @@ class DateAttribute extends Attribute
     }
   }
 
-  protected function dateToLdap($dateValue)
+  protected function dateToLdap(DateTime $dateValue)
   {
     return $dateValue->format($this->format);
   }
@@ -178,7 +178,7 @@ class GeneralizedTimeDateAttribute extends DateAttribute
     }
   }
 
-  protected function dateToLdap($dateValue)
+  protected function dateToLdap(DateTime $dateValue)
   {
     return LdapGeneralizedTime::toString($dateValue);
   }
@@ -231,7 +231,7 @@ class TimeHisAttribute extends CompositeAttribute
     return $values;
   }
 
-  function writeValues($values)
+  function writeValues(array $values)
   {
     if ($this->convert) {
       $datetime = new DateTime('T'.implode(':', $values), timezone::getDefaultTimeZone());
diff --git a/include/simpleplugin/attributes/class_FileAttribute.inc b/include/simpleplugin/attributes/class_FileAttribute.inc
index a7a2455e4f7a3a969dcd7d1b81c4eac6ca2a0c18..181f2dfa7329a7688a46fe4714478ccf3e2fdee6 100644
--- a/include/simpleplugin/attributes/class_FileAttribute.inc
+++ b/include/simpleplugin/attributes/class_FileAttribute.inc
@@ -79,7 +79,7 @@ class FileAttribute extends Attribute
    * \param array &$attributes the attributes array
    * \param boolean $form
    */
-  function serializeAttribute(&$attributes, $form = TRUE)
+  function serializeAttribute(array &$attributes, $form = TRUE)
   {
     if (!$form || $this->visible) {
       parent::serializeAttribute($attributes, $form);
@@ -180,7 +180,7 @@ class FileDownloadAttribute extends FileAttribute
     return $ids;
   }
 
-  function renderAttribute(&$attributes, $readOnly)
+  function renderAttribute(array &$attributes, $readOnly)
   {
     if ($this->upload == FALSE) {
       parent::renderAttribute($attributes, FALSE);
@@ -401,7 +401,7 @@ class ImageAttribute extends FileAttribute
 
   /*! \brief Fill LDAP value in the attrs array
    */
-  function fillLdapValue (&$attrs)
+  function fillLdapValue (array &$attrs)
   {
     if ($this->isInLdap()) {
       $value = $this->computeLdapValue();
diff --git a/include/simpleplugin/attributes/class_PhoneNumberAttribute.inc b/include/simpleplugin/attributes/class_PhoneNumberAttribute.inc
index f1d489d9c6fba819a05b291016b66fc1efe5584d..047c58dd18512567620d69ed773f3bec4a024e93 100644
--- a/include/simpleplugin/attributes/class_PhoneNumberAttribute.inc
+++ b/include/simpleplugin/attributes/class_PhoneNumberAttribute.inc
@@ -174,7 +174,7 @@ class PhoneNumberButtonAttribute extends PhoneNumberAttribute
     }
   }
 
-  function handleDialogResult ($dn, $attrs)
+  function handleDialogResult ($dn, array $attrs)
   {
     if (isset($attrs['telephoneNumber'][0])) {
       $this->setValue($attrs['telephoneNumber'][0]);
diff --git a/include/simpleplugin/attributes/class_SelectAttribute.inc b/include/simpleplugin/attributes/class_SelectAttribute.inc
index 5e3bcc278d710c869a6867b089d62a7b390a1e51..bc6b2fa3c09d4b780055624a523c5f9aa9d2feef 100644
--- a/include/simpleplugin/attributes/class_SelectAttribute.inc
+++ b/include/simpleplugin/attributes/class_SelectAttribute.inc
@@ -57,7 +57,7 @@ class SelectAttribute extends Attribute
    *  \param array $choices The choices this select should offer
    *  \param array $outputs The labels corresponding to the choices, leave to NULL if you want to display the choices themselves
    */
-  function setChoices ($choices, $outputs = NULL)
+  function setChoices (array $choices, array $outputs = NULL)
   {
     $this->outputs = NULL;
     if (!$this->isRequired() && !in_array('', $choices, TRUE)) {
@@ -82,7 +82,7 @@ class SelectAttribute extends Attribute
    *
    *  \param array $values The labels corresponding to the choices, in the same order as the choices
    */
-  function setDisplayChoices ($values)
+  function setDisplayChoices (array $values)
   {
     $this->outputs = array();
     $values = array_values($values);
@@ -183,7 +183,7 @@ class SelectAttribute extends Attribute
     return $this->renderAcl($display);
   }
 
-  function serializeAttribute(&$attributes, $form = TRUE)
+  function serializeAttribute(array &$attributes, $form = TRUE)
   {
     if (!$form || $this->visible) {
       parent::serializeAttribute($attributes, $form);
diff --git a/include/simpleplugin/attributes/class_SetAttribute.inc b/include/simpleplugin/attributes/class_SetAttribute.inc
index 16e2399d250eec7f7edc0f0715a5ade2ea97f330..f0210f3836614ef61c0f1b416423e66894144bca 100644
--- a/include/simpleplugin/attributes/class_SetAttribute.inc
+++ b/include/simpleplugin/attributes/class_SetAttribute.inc
@@ -47,7 +47,7 @@ class SetAttribute extends Attribute
     $this->valueUnicity = $valueUnicity;
   }
 
-  function setManagedAttributes ($dontcare)
+  function setManagedAttributes (array $dontcare)
   {
     trigger_error('method setManagedAttributes is not supported for SetAttributes');
   }
@@ -57,7 +57,7 @@ class SetAttribute extends Attribute
     $this->linearRendering = $bool;
   }
 
-  protected function loadAttrValue ($attrs)
+  protected function loadAttrValue (array $attrs)
   {
     if (isset($attrs[$this->getLdapName()]["count"])) {
       $this->value = array();
@@ -222,7 +222,7 @@ class SetAttribute extends Attribute
     }
   }
 
-  function renderAttribute(&$attributes, $readOnly)
+  function renderAttribute(array &$attributes, $readOnly)
   {
     if ($this->attribute === FALSE) {
       return parent::renderAttribute($attributes, $readOnly);
@@ -250,7 +250,7 @@ class SetAttribute extends Attribute
     }
   }
 
-  function serializeAttribute(&$attributes, $form = TRUE)
+  function serializeAttribute(array &$attributes, $form = TRUE)
   {
     parent::serializeAttribute($attributes, $form);
     if ($this->attribute === FALSE) {
@@ -322,7 +322,7 @@ class SetAttribute extends Attribute
     return $result;
   }
 
-  function foreignKeyUpdate($oldvalue, $newvalue, $source)
+  function foreignKeyUpdate($oldvalue, $newvalue, array $source)
   {
     foreach ($this->value as $key => &$value) {
       if (($source['FIELD'] == 'dn') && ($source['MODE'] == 'move')) {
@@ -346,7 +346,7 @@ class SetAttribute extends Attribute
     unset($value);
   }
 
-  function foreignKeyCheck($value, $source)
+  function foreignKeyCheck($value, array $source)
   {
     return in_array($value, $this->value);
   }
@@ -425,7 +425,7 @@ class OrderedArrayAttribute extends SetAttribute
     return $ldapValue;
   }
 
-  protected function loadAttrValue ($attrs)
+  protected function loadAttrValue (array $attrs)
   {
     if (isset($attrs[$this->getLdapName()]["count"])) {
       $this->value = array();
@@ -697,7 +697,7 @@ class SubNodesAttribute extends OrderedArrayAttribute
     }
   }
 
-  protected function loadAttrValue ($attrs)
+  protected function loadAttrValue (array $attrs)
   {
     global $config;
     /* Should we take dn from attrs or plugin? */
@@ -720,7 +720,7 @@ class SubNodesAttribute extends OrderedArrayAttribute
   }
 
   /* Not saving anything into base node */
-  function fillLdapValue (&$attrs)
+  function fillLdapValue (array &$attrs)
   {
   }
 
diff --git a/include/simpleplugin/class_Attribute.inc b/include/simpleplugin/class_Attribute.inc
index 83f063dac1d628122676c6f2650b071a812ec74d..32814aacf541f937bea557c6772a369610cf1265 100644
--- a/include/simpleplugin/class_Attribute.inc
+++ b/include/simpleplugin/class_Attribute.inc
@@ -292,7 +292,7 @@ class Attribute
 
   /*! \brief If in LDAP, loads this attribute value from the attrs array
    */
-  function loadValue ($attrs)
+  function loadValue (array $attrs)
   {
     if ($this->inLdap) {
       $this->loadAttrValue($attrs);
@@ -302,7 +302,7 @@ class Attribute
 
   /*! \brief Loads this attribute value from the attrs array
    */
-  protected function loadAttrValue ($attrs)
+  protected function loadAttrValue (array $attrs)
   {
     if (isset($attrs[$this->getLdapName()])) {
       $this->setValue($this->inputValue($attrs[$this->getLdapName()][0]));
@@ -346,7 +346,7 @@ class Attribute
   /*! \brief Set a list of attributes that are managed by this attributes.
    * See FusionDirectory wiki for detailed documentation
    */
-  function setManagedAttributes ($mAttributes)
+  function setManagedAttributes (array $mAttributes)
   {
     if (isset($mAttributes['multiplevalues'])) {
       $this->managedAttributesMultipleValues = $mAttributes['multiplevalues'];
@@ -413,7 +413,7 @@ class Attribute
 
   /*! \brief Fill LDAP value in the attrs array
    */
-  function fillLdapValue (&$attrs)
+  function fillLdapValue (array &$attrs)
   {
     if ($this->inLdap) {
       $value = $this->computeLdapValue();
@@ -427,7 +427,7 @@ class Attribute
 
   /*! \brief Post-modify the attrs array if needed (used for erasing managed attributes)
    */
-  function fillLdapValueHook (&$attrs)
+  function fillLdapValueHook (array &$attrs)
   {
     foreach ($this->managedAttributes as $prefix => $array) {
       if ($prefix != 'erase') {
@@ -567,7 +567,7 @@ class Attribute
    *
    *  \param bool $readOnly should we show text or input
    */
-  function renderAttribute(&$attributes, $readOnly)
+  function renderAttribute(array &$attributes, $readOnly)
   {
     if ($this->visible) {
       if ($readOnly) {
@@ -602,7 +602,7 @@ class Attribute
    * \param array &$attributes the attributes array
    * \param boolean $form
    */
-  function serializeAttribute(&$attributes, $form = TRUE)
+  function serializeAttribute(array &$attributes, $form = TRUE)
   {
     if (!$form || $this->visible) {
       $class = get_class($this);
@@ -708,7 +708,7 @@ class Attribute
     return $this->renderFormInput();
   }
 
-  function foreignKeyUpdate($oldvalue, $newvalue, $source)
+  function foreignKeyUpdate($oldvalue, $newvalue, array $source)
   {
     if ($source['MODE'] == 'move') {
       if ($source['FIELD'] == 'dn') {
@@ -723,12 +723,12 @@ class Attribute
     }
   }
 
-  function foreignKeyCheck($value, $source)
+  function foreignKeyCheck($value, array $source)
   {
     return ($this->getValue() == $value);
   }
 
-  protected function renderInputField($type, $name, $attributes = array())
+  protected function renderInputField($type, $name, array $attributes = array())
   {
     $input  = '<input type="'.$type.'" '.
               'name="'.$name.'" id="'.$name.'"'.
@@ -770,7 +770,7 @@ class HiddenAttribute extends Attribute
  */
 class HiddenArrayAttribute extends HiddenAttribute
 {
-  protected function loadAttrValue ($attrs)
+  protected function loadAttrValue (array $attrs)
   {
     if (isset($attrs[$this->getLdapName()]['count'])) {
       $this->value = array();
@@ -794,7 +794,7 @@ class FakeAttribute extends Attribute
     $this->setInLdap(FALSE);
   }
 
-  function renderAttribute(&$attributes, $readOnly)
+  function renderAttribute(array &$attributes, $readOnly)
   {
     $attributes[$this->getLdapName()] = $this->getValue();
   }
@@ -841,7 +841,7 @@ class DisplayLDAPAttribute extends Attribute
  */
 class ReadOnlyLDAPAttribute extends DisplayLDAPAttribute
 {
-  function fillLdapValue (&$attrs)
+  function fillLdapValue (array &$attrs)
   {
   }
 }
@@ -852,7 +852,7 @@ class ReadOnlyLDAPAttribute extends DisplayLDAPAttribute
  */
 class DisplayLDAPArrayAttribute extends Attribute
 {
-  protected function loadAttrValue ($attrs)
+  protected function loadAttrValue (array $attrs)
   {
     if (isset($attrs[$this->getLdapName()]['count'])) {
       $this->value = array();
diff --git a/include/simpleplugin/class_dialogAttributes.inc b/include/simpleplugin/class_dialogAttributes.inc
index 9188182b89f94b27c79a609605b1422cec2e52a4..e607373912ae1d3280655935cf62fe414e1dd52a 100644
--- a/include/simpleplugin/class_dialogAttributes.inc
+++ b/include/simpleplugin/class_dialogAttributes.inc
@@ -405,7 +405,7 @@ class GenericDialogAttribute extends DialogAttribute
     return $this->displays;
   }
 
-  function setDisplayValues ($array)
+  function setDisplayValues (array $array)
   {
     $this->displays = $array;
   }
@@ -450,7 +450,7 @@ class GenericDialogAttribute extends DialogAttribute
     }
   }
 
-  function foreignKeyUpdate($oldvalue, $newvalue, $source)
+  function foreignKeyUpdate($oldvalue, $newvalue, array $source)
   {
     foreach ($this->value as $key => &$value) {
       if (($source['FIELD'] == 'dn') && ($source['MODE'] == 'move')) {
@@ -736,7 +736,7 @@ class UserAttribute extends DialogButtonAttribute
     $this->setRequired($required);
   }
 
-  function handleDialogResult ($dn, $attrs)
+  function handleDialogResult ($dn, array $attrs)
   {
     $this->setValue($dn);
     $this->buttonText = $attrs['cn'][0];
@@ -812,7 +812,7 @@ class UserAttribute extends DialogButtonAttribute
   {
   }
 
-  protected function loadAttrValue ($attrs)
+  protected function loadAttrValue (array $attrs)
   {
     global $config;
     parent::loadAttrValue($attrs);
diff --git a/include/simpleplugin/class_helpersAttribute.inc b/include/simpleplugin/class_helpersAttribute.inc
index 0e27fe8cd59eccc6c5efaf07f2f546bac8bff841..b6c6183c80d3db69507738947dba8e127b468aa2 100644
--- a/include/simpleplugin/class_helpersAttribute.inc
+++ b/include/simpleplugin/class_helpersAttribute.inc
@@ -154,7 +154,7 @@ class CharSeparatedCompositeAttribute extends CompositeAttribute
     return explode($this->sep, $value);
   }
 
-  function writeValues($values)
+  function writeValues(array $values)
   {
     return join($this->sep, $values);
   }
@@ -198,7 +198,7 @@ class CommaListAttribute extends CompositeAttribute
     }
   }
 
-  function writeValues($values)
+  function writeValues(array $values)
   {
     return join($this->sep, $values[0]);
   }
@@ -242,7 +242,7 @@ class UnitIntAttribute extends CompositeAttribute
     return array($value / $choices[$i], $choices[$i]);
   }
 
-  function writeValues($values)
+  function writeValues(array $values)
   {
     if ($values[0] === '') {
       return '';