diff --git a/modules/consentAdmin/hooks/hook_frontpage.php b/modules/consentAdmin/hooks/hook_frontpage.php
index b1903a580ab08beeed8ecc3b742b09a1ea3cf67a..5059384b6e6f1c232cf9cd62df046b2175ffb184 100644
--- a/modules/consentAdmin/hooks/hook_frontpage.php
+++ b/modules/consentAdmin/hooks/hook_frontpage.php
@@ -1,10 +1,11 @@
 <?php
+
 /**
  * Hook to add the consentAdmin module to the frontpage.
  *
  * @param array &$links  The links on the frontpage, split into sections.
+ * @return void
  */
-
 function consentAdmin_hook_frontpage(&$links)
 {
     assert(is_array($links));
diff --git a/modules/consentAdmin/www/consentAdmin.php b/modules/consentAdmin/www/consentAdmin.php
index 00716e1e3883d99170dd88ed0e94d64b2f337a78..51b15b6e9d9d5b851c25f1e5dfabb61fdb957e02 100644
--- a/modules/consentAdmin/www/consentAdmin.php
+++ b/modules/consentAdmin/www/consentAdmin.php
@@ -11,7 +11,7 @@
  * Author: Mads Freek <freek@ruc.dk>, Jacob Christiansen <jach@wayf.dk>
  */
 
-/*
+/**
  * Runs the processing chain and ignores all filter which have user
  * interaction.
  *
@@ -185,7 +185,7 @@ if ($action !== null && $sp_entityid !== null) {
         'consentAdmin:consentadminajax.php',
         'consentAdmin:consentadmin'
     );
-    $translator = $t->getTranslator();
+    $translator = $template->getTranslator();
 
     // Get SP metadata
     $sp_metadata = $metadata->getMetaData($sp_entityid, 'saml20-sp-remote');
diff --git a/modules/core/hooks/hook_frontpage.php b/modules/core/hooks/hook_frontpage.php
index d2b6eef9c0b15aa8d0020dd8cdd29472c1cf2edf..cbb1469c03a63179cd4d405d0e637b330f90e7f7 100644
--- a/modules/core/hooks/hook_frontpage.php
+++ b/modules/core/hooks/hook_frontpage.php
@@ -1,10 +1,11 @@
 <?php
+
 /**
  * Hook to add the modinfo module to the frontpage.
  *
  * @param array &$links  The links on the frontpage, split into sections.
+ * @return void
  */
-
 function core_hook_frontpage(&$links)
 {
     assert(is_array($links));
diff --git a/modules/core/hooks/hook_sanitycheck.php b/modules/core/hooks/hook_sanitycheck.php
index ef4af3049f99106c63bac2cbcad9d7f4a9fe578b..b7701d862cc462e09cdc5adfb281465793a6b4a1 100644
--- a/modules/core/hooks/hook_sanitycheck.php
+++ b/modules/core/hooks/hook_sanitycheck.php
@@ -1,10 +1,11 @@
 <?php
+
 /**
  * Hook to do sanitycheck
  *
  * @param array &$hookinfo  hookinfo
+ * @return void
  */
-
 function core_hook_sanitycheck(&$hookinfo)
 {
     assert(is_array($hookinfo));
diff --git a/modules/core/lib/Auth/Process/AttributeAdd.php b/modules/core/lib/Auth/Process/AttributeAdd.php
index deb3ac310c4f1e8d6d4152080473dacaadc39814..b568998866cb160270989d141257ab1ac077fd18 100644
--- a/modules/core/lib/Auth/Process/AttributeAdd.php
+++ b/modules/core/lib/Auth/Process/AttributeAdd.php
@@ -10,7 +10,6 @@ namespace SimpleSAML\Module\core\Auth\Process;
  * @author Olav Morken, UNINETT AS.
  * @package SimpleSAMLphp
  */
-
 class AttributeAdd extends \SimpleSAML\Auth\ProcessingFilter
 {
     /**
@@ -28,10 +27,10 @@ class AttributeAdd extends \SimpleSAML\Auth\ProcessingFilter
     /**
      * Initialize this filter.
      *
-     * @param array $config  Configuration information about this filter.
+     * @param array &$config  Configuration information about this filter.
      * @param mixed $reserved  For future use.
      */
-    public function __construct($config, $reserved)
+    public function __construct(&$config, $reserved)
     {
         parent::__construct($config, $reserved);
 
@@ -66,6 +65,7 @@ class AttributeAdd extends \SimpleSAML\Auth\ProcessingFilter
      * Add or replace existing attributes with the configured values.
      *
      * @param array &$request  The current request
+     * @return void
      */
     public function process(&$request)
     {
diff --git a/modules/core/lib/Auth/Process/AttributeAlter.php b/modules/core/lib/Auth/Process/AttributeAlter.php
index 0d181a0d7cd45700556bd4d121cf4c90da087704..c8900822a025ac632cdd7e31289a0d8a2280fda4 100644
--- a/modules/core/lib/Auth/Process/AttributeAlter.php
+++ b/modules/core/lib/Auth/Process/AttributeAlter.php
@@ -10,7 +10,6 @@ namespace SimpleSAML\Module\core\Auth\Process;
  * @author Jacob Christiansen, WAYF
  * @package SimpleSAMLphp
  */
-
 class AttributeAlter extends \SimpleSAML\Auth\ProcessingFilter
 {
     /**
@@ -46,11 +45,11 @@ class AttributeAlter extends \SimpleSAML\Auth\ProcessingFilter
     /**
      * Initialize this filter.
      *
-     * @param array $config  Configuration information about this filter.
+     * @param array &$config  Configuration information about this filter.
      * @param mixed $reserved  For future use.
      * @throws \SimpleSAML\Error\Exception In case of invalid configuration.
      */
-    public function __construct($config, $reserved)
+    public function __construct(&$config, $reserved)
     {
         parent::__construct($config, $reserved);
 
@@ -91,6 +90,7 @@ class AttributeAlter extends \SimpleSAML\Auth\ProcessingFilter
      *
      * @param array &$request The current request.
      * @throws \SimpleSAML\Error\Exception In case of invalid configuration.
+     * @return void
      */
     public function process(&$request)
     {
diff --git a/modules/core/lib/Auth/Process/AttributeCopy.php b/modules/core/lib/Auth/Process/AttributeCopy.php
index 1b54da17ae14826a5c6abe82c83b87fef681c6a3..e9fab68d73790c93ca371a394787b247638f39fc 100644
--- a/modules/core/lib/Auth/Process/AttributeCopy.php
+++ b/modules/core/lib/Auth/Process/AttributeCopy.php
@@ -17,7 +17,6 @@ namespace SimpleSAML\Module\core\Auth\Process;
  *         ),
  *
  */
-
 class AttributeCopy extends \SimpleSAML\Auth\ProcessingFilter
 {
     /**
@@ -25,13 +24,14 @@ class AttributeCopy extends \SimpleSAML\Auth\ProcessingFilter
      */
     private $map = [];
 
+
     /**
      * Initialize this filter, parse configuration
      *
-     * @param array $config  Configuration information about this filter.
+     * @param array &$config  Configuration information about this filter.
      * @param mixed $reserved  For future use.
      */
-    public function __construct($config, $reserved)
+    public function __construct(&$config, $reserved)
     {
         parent::__construct($config, $reserved);
 
@@ -54,6 +54,7 @@ class AttributeCopy extends \SimpleSAML\Auth\ProcessingFilter
      * Apply filter to rename attributes.
      *
      * @param array &$request  The current request
+     * @return void
      */
     public function process(&$request)
     {
diff --git a/modules/core/lib/Auth/Process/AttributeLimit.php b/modules/core/lib/Auth/Process/AttributeLimit.php
index b90d1b0cdedad5ec6f3d34264254d30ec8128744..f0789d9a2dda31346619b1d1af532caf53a8f67c 100644
--- a/modules/core/lib/Auth/Process/AttributeLimit.php
+++ b/modules/core/lib/Auth/Process/AttributeLimit.php
@@ -8,7 +8,6 @@ namespace SimpleSAML\Module\core\Auth\Process;
  * @author Olav Morken, UNINETT AS.
  * @package SimpleSAMLphp
  */
-
 class AttributeLimit extends \SimpleSAML\Auth\ProcessingFilter
 {
     /**
@@ -23,14 +22,15 @@ class AttributeLimit extends \SimpleSAML\Auth\ProcessingFilter
      */
     private $isDefault = false;
 
+
     /**
      * Initialize this filter.
      *
-     * @param array $config  Configuration information about this filter.
+     * @param array &$config  Configuration information about this filter.
      * @param mixed $reserved  For future use
      * @throws \SimpleSAML\Error\Exception If invalid configuration is found.
      */
-    public function __construct($config, $reserved)
+    public function __construct(&$config, $reserved)
     {
         parent::__construct($config, $reserved);
 
@@ -61,7 +61,7 @@ class AttributeLimit extends \SimpleSAML\Auth\ProcessingFilter
      * Get list of allowed from the SP/IdP config.
      *
      * @param array &$request  The current request.
-     * @return array|NULL  Array with attribute names, or NULL if no limit is placed.
+     * @return array|null  Array with attribute names, or NULL if no limit is placed.
      */
     private static function getSPIdPAllowed(array &$request)
     {
@@ -83,6 +83,7 @@ class AttributeLimit extends \SimpleSAML\Auth\ProcessingFilter
      *
      * @param array &$request  The current request
      * @throws \SimpleSAML\Error\Exception If invalid configuration is found.
+     * @return void
      */
     public function process(&$request)
     {
diff --git a/modules/core/lib/Auth/Process/AttributeMap.php b/modules/core/lib/Auth/Process/AttributeMap.php
index 7992f8b69d45163974ebc21096e7bdacec83087b..0a648dbccbfd5583545feb2cae627de0e48add48 100644
--- a/modules/core/lib/Auth/Process/AttributeMap.php
+++ b/modules/core/lib/Auth/Process/AttributeMap.php
@@ -8,7 +8,6 @@ namespace SimpleSAML\Module\core\Auth\Process;
  * @author Olav Morken, UNINETT AS.
  * @package SimpleSAMLphp
  */
-
 class AttributeMap extends \SimpleSAML\Auth\ProcessingFilter
 {
     /**
@@ -25,12 +24,12 @@ class AttributeMap extends \SimpleSAML\Auth\ProcessingFilter
     /**
      * Initialize this filter, parse configuration
      *
-     * @param array $config Configuration information about this filter.
+     * @param array &$config Configuration information about this filter.
      * @param mixed $reserved For future use.
      *
      * @throws Exception If the configuration of the filter is wrong.
      */
-    public function __construct($config, $reserved)
+    public function __construct(&$config, $reserved)
     {
         parent::__construct($config, $reserved);
 
@@ -73,6 +72,7 @@ class AttributeMap extends \SimpleSAML\Auth\ProcessingFilter
      * of the SimpleSAMLphp installation, or in the root of a module.
      *
      * @throws Exception If the filter could not load the requested attribute map file.
+     * @return void
      */
     private function loadMapFile($fileName)
     {
@@ -111,6 +111,7 @@ class AttributeMap extends \SimpleSAML\Auth\ProcessingFilter
      * Apply filter to rename attributes.
      *
      * @param array &$request The current request.
+     * @return void
      */
     public function process(&$request)
     {
diff --git a/modules/core/lib/Auth/Process/AttributeRealm.php b/modules/core/lib/Auth/Process/AttributeRealm.php
index f6366e9fe66abb5cd0cd219d173dae82ba3cc7fc..c708ece37927747c46f44aff2e1637aa2ecf0692 100644
--- a/modules/core/lib/Auth/Process/AttributeRealm.php
+++ b/modules/core/lib/Auth/Process/AttributeRealm.php
@@ -13,15 +13,16 @@ namespace SimpleSAML\Module\core\Auth\Process;
 
 class AttributeRealm extends \SimpleSAML\Auth\ProcessingFilter
 {
+    /** @var string */
     private $attributename = 'realm';
 
     /**
      * Initialize this filter.
      *
-     * @param array $config  Configuration information about this filter.
+     * @param array &$config  Configuration information about this filter.
      * @param mixed $reserved  For future use.
      */
-    public function __construct($config, $reserved)
+    public function __construct(&$config, $reserved)
     {
         parent::__construct($config, $reserved);
         assert(is_array($config));
@@ -37,6 +38,7 @@ class AttributeRealm extends \SimpleSAML\Auth\ProcessingFilter
      * Add or replace existing attributes with the configured values.
      *
      * @param array &$request  The current request
+     * @return void
      */
     public function process(&$request)
     {
diff --git a/modules/core/lib/Auth/Process/AttributeValueMap.php b/modules/core/lib/Auth/Process/AttributeValueMap.php
index 9979ea66f27b8d5768c89c122ec10dddbc6be795..189560f0bae0e0f2d66e8a8f6da6fc8ef6e12960 100644
--- a/modules/core/lib/Auth/Process/AttributeValueMap.php
+++ b/modules/core/lib/Auth/Process/AttributeValueMap.php
@@ -8,42 +8,47 @@ namespace SimpleSAML\Module\core\Auth\Process;
  * @author Martin van Es, m7
  * @package SimpleSAMLphp
  */
-
 class AttributeValueMap extends \SimpleSAML\Auth\ProcessingFilter
 {
     /**
      * The name of the attribute we should assign values to (ie: the target attribute).
+     * @var string
      */
     private $targetattribute;
 
     /**
      * The name of the attribute we should create values from.
+     * @var string
      */
     private $sourceattribute;
 
     /**
      * The required $sourceattribute values and target affiliations.
+     * @var array
      */
     private $values = [];
     
     /**
      * Whether $sourceattribute should be kept or not.
+     * @var bool
      */
     private $keep = false;
 
     /**
      * Whether $target attribute values should be replaced by new values or not.
+     * @var bool
      */
     private $replace = false;
     
+
     /**
      * Initialize the filter.
      *
-     * @param array $config Configuration information about this filter.
+     * @param array &$config Configuration information about this filter.
      * @param mixed $reserved For future use.
      * @throws \SimpleSAML\Error\Exception If the configuration is not valid.
      */
-    public function __construct($config, $reserved)
+    public function __construct(&$config, $reserved)
     {
         parent::__construct($config, $reserved);
 
@@ -99,6 +104,7 @@ class AttributeValueMap extends \SimpleSAML\Auth\ProcessingFilter
      * Apply filter.
      *
      * @param array &$request The current request
+     * @return void
      */
     public function process(&$request)
     {
diff --git a/modules/core/lib/Auth/Process/Cardinality.php b/modules/core/lib/Auth/Process/Cardinality.php
index ac4f1aad1edca4ca87a0ab54c71b40fe28fe9902..8e66ad93a7a8af6fa23c40092fec63068af149e4 100644
--- a/modules/core/lib/Auth/Process/Cardinality.php
+++ b/modules/core/lib/Auth/Process/Cardinality.php
@@ -10,7 +10,6 @@ use SimpleSAML\Utils\HttpAdapter;
  * @author Guy Halse, http://orcid.org/0000-0002-9388-8592
  * @package SimpleSAMLphp
  */
-
 class Cardinality extends \SimpleSAML\Auth\ProcessingFilter
 {
     /** @var array Associative array with the mappings of attribute names. */
@@ -25,12 +24,12 @@ class Cardinality extends \SimpleSAML\Auth\ProcessingFilter
     /**
      * Initialize this filter, parse configuration.
      *
-     * @param array $config  Configuration information about this filter.
+     * @param array &$config  Configuration information about this filter.
      * @param mixed $reserved  For future use.
      * @param HTTPAdapter $http  HTTP utility service (handles redirects).
      * @throws \SimpleSAML\Error\Exception
      */
-    public function __construct($config, $reserved, HttpAdapter $http = null)
+    public function __construct(&$config, $reserved, HttpAdapter $http = null)
     {
         parent::__construct($config, $reserved);
         assert(is_array($config));
@@ -98,6 +97,7 @@ class Cardinality extends \SimpleSAML\Auth\ProcessingFilter
      * Process this filter
      *
      * @param array &$request  The current request
+     * @return void
      */
     public function process(&$request)
     {
diff --git a/modules/core/lib/Auth/Process/CardinalitySingle.php b/modules/core/lib/Auth/Process/CardinalitySingle.php
index ac251319beef8ffe40c2e15e3da4db498bd4798b..ca758adec8c0ec7ec95b2911212eb7e4ba11df89 100644
--- a/modules/core/lib/Auth/Process/CardinalitySingle.php
+++ b/modules/core/lib/Auth/Process/CardinalitySingle.php
@@ -13,7 +13,6 @@ use SimpleSAML\Utils\HttpAdapter;
  * @author Guy Halse, http://orcid.org/0000-0002-9388-8592
  * @package SimpleSAMLphp
  */
-
 class CardinalitySingle extends \SimpleSAML\Auth\ProcessingFilter
 {
     /** @var array Attributes that should be single-valued or we generate an error */
@@ -37,11 +36,11 @@ class CardinalitySingle extends \SimpleSAML\Auth\ProcessingFilter
     /**
      * Initialize this filter, parse configuration.
      *
-     * @param array $config  Configuration information about this filter.
+     * @param array &$config  Configuration information about this filter.
      * @param mixed $reserved  For future use.
      * @param HTTPAdapter $http  HTTP utility service (handles redirects).
      */
-    public function __construct($config, $reserved, HttpAdapter $http = null)
+    public function __construct(&$config, $reserved, HttpAdapter $http = null)
     {
         parent::__construct($config, $reserved);
         assert(is_array($config));
@@ -73,10 +72,12 @@ class CardinalitySingle extends \SimpleSAML\Auth\ProcessingFilter
         }
     }
 
+
     /**
      * Process this filter
      *
      * @param array &$request  The current request
+     * @return void
      */
     public function process(&$request)
     {
diff --git a/modules/core/lib/Auth/Process/ExtendIdPSession.php b/modules/core/lib/Auth/Process/ExtendIdPSession.php
index 92102262b572ee8d0b0bfb07e35ef011c106c9a8..adfa3fd1e547f2e5b560cd9c8f553001c02d9be7 100644
--- a/modules/core/lib/Auth/Process/ExtendIdPSession.php
+++ b/modules/core/lib/Auth/Process/ExtendIdPSession.php
@@ -5,9 +5,12 @@ namespace SimpleSAML\Module\core\Auth\Process;
 /**
  * Extend IdP session and cookies.
  */
-
 class ExtendIdPSession extends \SimpleSAML\Auth\ProcessingFilter
 {
+    /**
+     * @param array &$state
+     * @return void
+     */
     public function process(&$state)
     {
         assert(is_array($state));
diff --git a/modules/core/lib/Auth/Process/GenerateGroups.php b/modules/core/lib/Auth/Process/GenerateGroups.php
index ab9d15aad0498e93e46fc9f4e2552455b9529912..0ea05f67cd36f7e29777e3af32b0a96222696370 100644
--- a/modules/core/lib/Auth/Process/GenerateGroups.php
+++ b/modules/core/lib/Auth/Process/GenerateGroups.php
@@ -8,7 +8,6 @@ namespace SimpleSAML\Module\core\Auth\Process;
  * @author Olav Morken, UNINETT AS.
  * @package SimpleSAMLphp
  */
-
 class GenerateGroups extends \SimpleSAML\Auth\ProcessingFilter
 {
     /**
@@ -19,10 +18,10 @@ class GenerateGroups extends \SimpleSAML\Auth\ProcessingFilter
     /**
      * Initialize this filter.
      *
-     * @param array $config  Configuration information about this filter.
+     * @param array &$config  Configuration information about this filter.
      * @param mixed $reserved  For future use.
      */
-    public function __construct($config, $reserved)
+    public function __construct(&$config, $reserved)
     {
         parent::__construct($config, $reserved);
 
@@ -51,6 +50,7 @@ class GenerateGroups extends \SimpleSAML\Auth\ProcessingFilter
      * Apply filter to add groups attribute.
      *
      * @param array &$request  The current request
+     * @return void
      */
     public function process(&$request)
     {
@@ -86,6 +86,7 @@ class GenerateGroups extends \SimpleSAML\Auth\ProcessingFilter
         }
     }
 
+
     /**
      * Determine which realm the user belongs to.
      *
@@ -94,7 +95,7 @@ class GenerateGroups extends \SimpleSAML\Auth\ProcessingFilter
      * a realm, NULL will be returned.
      *
      * @param array $attributes  The attributes of the user.
-     * @return string|NULL  The realm of the user, or NULL if we are unable to determine the realm.
+     * @return string|null  The realm of the user, or NULL if we are unable to determine the realm.
      */
     private static function getRealm($attributes)
     {
@@ -119,6 +120,7 @@ class GenerateGroups extends \SimpleSAML\Auth\ProcessingFilter
         return self::escapeIllegalChars($realm);
     }
 
+
     /**
      * Escape special characters in a string.
      *
@@ -135,6 +137,10 @@ class GenerateGroups extends \SimpleSAML\Auth\ProcessingFilter
 
         return preg_replace_callback(
             '/([^a-zA-Z0-9_@=.])/',
+            /**
+             * @param array $m
+             * @return string
+             */
             function ($m) {
                 return sprintf("%%%02x", ord($m[1]));
             },
diff --git a/modules/core/lib/Auth/Process/LanguageAdaptor.php b/modules/core/lib/Auth/Process/LanguageAdaptor.php
index 771fb6357216575621aeaa067b77036e77c34e3a..952d800bdce52936922a1e02cce6dcd2a707ab2b 100644
--- a/modules/core/lib/Auth/Process/LanguageAdaptor.php
+++ b/modules/core/lib/Auth/Process/LanguageAdaptor.php
@@ -8,18 +8,18 @@ namespace SimpleSAML\Module\core\Auth\Process;
  * @author Andreas Ă…kre Solberg, UNINETT AS.
  * @package SimpleSAMLphp
  */
-
 class LanguageAdaptor extends \SimpleSAML\Auth\ProcessingFilter
 {
+    /** @var string */
     private $langattr = 'preferredLanguage';
 
     /**
      * Initialize this filter.
      *
-     * @param array $config  Configuration information about this filter.
+     * @param array &$config  Configuration information about this filter.
      * @param mixed $reserved  For future use.
      */
-    public function __construct($config, $reserved)
+    public function __construct(&$config, $reserved)
     {
         parent::__construct($config, $reserved);
         assert(is_array($config));
@@ -29,12 +29,14 @@ class LanguageAdaptor extends \SimpleSAML\Auth\ProcessingFilter
         }
     }
 
+
     /**
      * Apply filter to add or replace attributes.
      *
      * Add or replace existing attributes with the configured values.
      *
      * @param array &$request  The current request
+     * @return void
      */
     public function process(&$request)
     {
diff --git a/modules/core/lib/Auth/Process/PHP.php b/modules/core/lib/Auth/Process/PHP.php
index cd424c76e9a01e1b4705eb217014eab2c9ec5ed1..bf0504f52a570e2b6b6a79969f116ffd293b59ac 100644
--- a/modules/core/lib/Auth/Process/PHP.php
+++ b/modules/core/lib/Auth/Process/PHP.php
@@ -21,12 +21,12 @@ class PHP extends \SimpleSAML\Auth\ProcessingFilter
     /**
      * Initialize this filter, parse configuration
      *
-     * @param array $config Configuration information about this filter.
+     * @param array &$config Configuration information about this filter.
      * @param mixed $reserved For future use.
      *
      * @throws \SimpleSAML\Error\Exception if the 'code' option is not defined.
      */
-    public function __construct($config, $reserved)
+    public function __construct(&$config, $reserved)
     {
         parent::__construct($config, $reserved);
 
@@ -43,12 +43,18 @@ class PHP extends \SimpleSAML\Auth\ProcessingFilter
      * Apply the PHP code to the attributes.
      *
      * @param array &$request The current request
+     * @return void
      */
     public function process(&$request)
     {
         assert(is_array($request));
         assert(array_key_exists('Attributes', $request));
 
+        /**
+         * @param array &$attributes
+         * @param array &$state
+         * @return void
+         */
         $function = function (
             /** @scrutinizer ignore-unused */ &$attributes,
             /** @scrutinizer ignore-unused */ &$state
diff --git a/modules/core/lib/Auth/Process/ScopeAttribute.php b/modules/core/lib/Auth/Process/ScopeAttribute.php
index 1db7d3c18a1bf3dd3f1f4cc1a3d1cc1bd090d7d7..f86058c5768a94d3321eb3ec8a6db4af75d8afcd 100644
--- a/modules/core/lib/Auth/Process/ScopeAttribute.php
+++ b/modules/core/lib/Auth/Process/ScopeAttribute.php
@@ -38,29 +38,32 @@ class ScopeAttribute extends \SimpleSAML\Auth\ProcessingFilter
      */
     private $onlyIfEmpty = false;
 
+
     /**
      * Initialize this filter, parse configuration
      *
-     * @param array $config  Configuration information about this filter.
+     * @param array &$config  Configuration information about this filter.
      * @param mixed $reserved  For future use.
      */
-    public function __construct($config, $reserved)
+    public function __construct(&$config, $reserved)
     {
         parent::__construct($config, $reserved);
         assert(is_array($config));
 
-        $config = \SimpleSAML\Configuration::loadFromArray($config, 'ScopeAttribute');
+        $cfg = \SimpleSAML\Configuration::loadFromArray($config, 'ScopeAttribute');
 
-        $this->scopeAttribute = $config->getString('scopeAttribute');
-        $this->sourceAttribute = $config->getString('sourceAttribute');
-        $this->targetAttribute = $config->getString('targetAttribute');
-        $this->onlyIfEmpty = $config->getBoolean('onlyIfEmpty', false);
+        $this->scopeAttribute = $cfg->getString('scopeAttribute');
+        $this->sourceAttribute = $cfg->getString('sourceAttribute');
+        $this->targetAttribute = $cfg->getString('targetAttribute');
+        $this->onlyIfEmpty = $cfg->getBoolean('onlyIfEmpty', false);
     }
 
+
     /**
      * Apply this filter to the request.
      *
      * @param array &$request  The current request
+     * @return void
      */
     public function process(&$request)
     {
diff --git a/modules/core/lib/Auth/Process/ScopeFromAttribute.php b/modules/core/lib/Auth/Process/ScopeFromAttribute.php
index b043de9fd86a0c58ba16e8d332b730c26ded02f6..323fc0038a914083988b57a53bb05f1493615b4d 100644
--- a/modules/core/lib/Auth/Process/ScopeFromAttribute.php
+++ b/modules/core/lib/Auth/Process/ScopeFromAttribute.php
@@ -18,7 +18,6 @@ namespace SimpleSAML\Module\core\Auth\Process;
  * to add a virtual 'scope' attribute from the eduPersonPrincipalName
  * attribute.
  */
-
 class ScopeFromAttribute extends \SimpleSAML\Auth\ProcessingFilter
 {
     /**
@@ -35,26 +34,29 @@ class ScopeFromAttribute extends \SimpleSAML\Auth\ProcessingFilter
      */
     private $targetAttribute;
 
+
     /**
      * Initialize this filter, parse configuration
      *
-     * @param array $config  Configuration information about this filter.
+     * @param array &$config  Configuration information about this filter.
      * @param mixed $reserved  For future use.
      */
-    public function __construct($config, $reserved)
+    public function __construct(&$config, $reserved)
     {
         parent::__construct($config, $reserved);
         assert(is_array($config));
 
-        $config = \SimpleSAML\Configuration::loadFromArray($config, 'ScopeFromAttribute');
-        $this->targetAttribute = $config->getString('targetAttribute');
-        $this->sourceAttribute = $config->getString('sourceAttribute');
+        $cfg = \SimpleSAML\Configuration::loadFromArray($config, 'ScopeFromAttribute');
+        $this->targetAttribute = $cfg->getString('targetAttribute');
+        $this->sourceAttribute = $cfg->getString('sourceAttribute');
     } // end constructor
 
+
     /**
      * Apply this filter.
      *
      * @param array &$request  The current request
+     * @return void
      */
     public function process(&$request)
     {
diff --git a/modules/core/lib/Auth/Process/StatisticsWithAttribute.php b/modules/core/lib/Auth/Process/StatisticsWithAttribute.php
index 86db3063c575396706a4373d8ba5f8db9bc3b3d6..7d796eceec7d6e18282e8290fa02ca1fd957419a 100644
--- a/modules/core/lib/Auth/Process/StatisticsWithAttribute.php
+++ b/modules/core/lib/Auth/Process/StatisticsWithAttribute.php
@@ -8,7 +8,6 @@ namespace SimpleSAML\Module\core\Auth\Process;
  * @author Andreas Ă…kre Solberg, UNINETT AS.
  * @package SimpleSAMLphp
  */
-
 class StatisticsWithAttribute extends \SimpleSAML\Auth\ProcessingFilter
 {
     /**
@@ -31,10 +30,10 @@ class StatisticsWithAttribute extends \SimpleSAML\Auth\ProcessingFilter
     /**
      * Initialize this filter.
      *
-     * @param array $config  Configuration information about this filter.
+     * @param array &$config  Configuration information about this filter.
      * @param mixed $reserved  For future use.
      */
-    public function __construct($config, $reserved)
+    public function __construct(&$config, $reserved)
     {
         parent::__construct($config, $reserved);
 
@@ -64,6 +63,7 @@ class StatisticsWithAttribute extends \SimpleSAML\Auth\ProcessingFilter
      * Log line.
      *
      * @param array &$state  The current state.
+     * @return void
      */
     public function process(&$state)
     {
diff --git a/modules/core/lib/Auth/Process/TargetedID.php b/modules/core/lib/Auth/Process/TargetedID.php
index 710fa7f648861b7b515f5807775e19a9b5ba6699..46a6b04ff662cfe5c61b3b56722ab69b4de0065e 100644
--- a/modules/core/lib/Auth/Process/TargetedID.php
+++ b/modules/core/lib/Auth/Process/TargetedID.php
@@ -30,7 +30,6 @@ namespace SimpleSAML\Module\core\Auth\Process;
  * @author Olav Morken, UNINETT AS.
  * @package SimpleSAMLphp
  */
-
 class TargetedID extends \SimpleSAML\Auth\ProcessingFilter
 {
     /**
@@ -46,13 +45,14 @@ class TargetedID extends \SimpleSAML\Auth\ProcessingFilter
      */
     private $generateNameId = false;
 
+
     /**
      * Initialize this filter.
      *
-     * @param array $config  Configuration information about this filter.
+     * @param array &$config  Configuration information about this filter.
      * @param mixed $reserved  For future use.
      */
-    public function __construct($config, $reserved)
+    public function __construct(&$config, $reserved)
     {
         parent::__construct($config, $reserved);
 
@@ -73,10 +73,12 @@ class TargetedID extends \SimpleSAML\Auth\ProcessingFilter
         }
     }
 
+
     /**
      * Apply filter to add the targeted ID.
      *
      * @param array &$state  The current state.
+     * @return void
      */
     public function process(&$state)
     {
@@ -142,6 +144,7 @@ class TargetedID extends \SimpleSAML\Auth\ProcessingFilter
         $state['Attributes']['eduPersonTargetedID'] = [$nameId];
     }
 
+
     /**
      * Generate ID from entity metadata.
      *
diff --git a/modules/core/lib/Auth/Process/WarnShortSSOInterval.php b/modules/core/lib/Auth/Process/WarnShortSSOInterval.php
index 1d488b9db935886a2a2e2359ffddaf10ef3e4e56..a2cbe71e80c0f24b5f914a14c0f7e15d3a182fa7 100644
--- a/modules/core/lib/Auth/Process/WarnShortSSOInterval.php
+++ b/modules/core/lib/Auth/Process/WarnShortSSOInterval.php
@@ -7,7 +7,6 @@ namespace SimpleSAML\Module\core\Auth\Process;
  *
  * @package SimpleSAMLphp
  */
-
 class WarnShortSSOInterval extends \SimpleSAML\Auth\ProcessingFilter
 {
     /**
@@ -17,6 +16,7 @@ class WarnShortSSOInterval extends \SimpleSAML\Auth\ProcessingFilter
      * If it is to short a while since, we will show a warning to the user.
      *
      * @param array $state  The state of the response.
+     * @return void
      */
     public function process(&$state)
     {
diff --git a/modules/core/lib/Auth/UserPassBase.php b/modules/core/lib/Auth/UserPassBase.php
index 8473344666aa5e02a8df33ef1cde898c586fdfb8..2730c8cb007df717d35e9a34a830437ad0d424cc 100644
--- a/modules/core/lib/Auth/UserPassBase.php
+++ b/modules/core/lib/Auth/UserPassBase.php
@@ -11,7 +11,6 @@ namespace SimpleSAML\Module\core\Auth;
  * @author Olav Morken, UNINETT AS.
  * @package SimpleSAMLphp
  */
-
 abstract class UserPassBase extends \SimpleSAML\Auth\Source
 {
     /**
@@ -72,6 +71,7 @@ abstract class UserPassBase extends \SimpleSAML\Auth\Source
      */
     protected $rememberMeChecked = false;
 
+
     /**
      * Constructor for this authentication source.
      *
@@ -109,10 +109,12 @@ abstract class UserPassBase extends \SimpleSAML\Auth\Source
         $this->rememberMeChecked = $sspcnf->getBoolean('session.rememberme.checked', false);
     }
 
+
     /**
      * Set forced username.
      *
-     * @param string|NULL $forcedUsername  The forced username.
+     * @param string|null $forcedUsername  The forced username.
+     * @return void
      */
     public function setForcedUsername($forcedUsername)
     {
@@ -122,12 +124,14 @@ abstract class UserPassBase extends \SimpleSAML\Auth\Source
 
     /**
      * Return login links from configuration
+     * @return array
      */
     public function getLoginLinks()
     {
         return $this->loginLinks;
     }
 
+
     /**
      * Getter for the authsource config option remember.username.enabled
      * @return bool
@@ -137,6 +141,7 @@ abstract class UserPassBase extends \SimpleSAML\Auth\Source
         return $this->rememberUsernameEnabled;
     }
 
+
     /**
      * Getter for the authsource config option remember.username.checked
      * @return bool
@@ -146,6 +151,7 @@ abstract class UserPassBase extends \SimpleSAML\Auth\Source
         return $this->rememberUsernameChecked;
     }
 
+
     /**
      * Check if the "remember me" feature is enabled.
      * @return bool TRUE if enabled, FALSE otherwise.
@@ -155,6 +161,7 @@ abstract class UserPassBase extends \SimpleSAML\Auth\Source
         return $this->rememberMeEnabled;
     }
 
+
     /**
      * Check if the "remember me" checkbox should be checked.
      * @return bool TRUE if enabled, FALSE otherwise.
@@ -164,6 +171,7 @@ abstract class UserPassBase extends \SimpleSAML\Auth\Source
         return $this->rememberMeChecked;
     }
 
+
     /**
      * Initialize login.
      *
@@ -171,6 +179,7 @@ abstract class UserPassBase extends \SimpleSAML\Auth\Source
      * login page.
      *
      * @param array &$state  Information about the current authentication.
+     * @return void
      */
     public function authenticate(&$state)
     {
@@ -233,6 +242,7 @@ abstract class UserPassBase extends \SimpleSAML\Auth\Source
         assert(false);
     }
 
+
     /**
      * Attempt to log in using the given username and password.
      *
@@ -248,6 +258,7 @@ abstract class UserPassBase extends \SimpleSAML\Auth\Source
      */
     abstract protected function login($username, $password);
 
+
     /**
      * Handle login request.
      *
@@ -258,6 +269,7 @@ abstract class UserPassBase extends \SimpleSAML\Auth\Source
      * @param string $authStateId  The identifier of the authentication state.
      * @param string $username  The username the user wrote.
      * @param string $password  The password the user wrote.
+     * @return void
      */
     public static function handleLogin($authStateId, $username, $password)
     {
diff --git a/modules/core/lib/Auth/UserPassOrgBase.php b/modules/core/lib/Auth/UserPassOrgBase.php
index 33168524c85c692c1f19fac1b3f08b684e3c3878..6eca0d095491f3c16d995fc0c487181a522e115a 100644
--- a/modules/core/lib/Auth/UserPassOrgBase.php
+++ b/modules/core/lib/Auth/UserPassOrgBase.php
@@ -13,7 +13,6 @@ namespace SimpleSAML\Module\core\Auth;
  * @author Olav Morken, UNINETT AS.
  * @package SimpleSAMLphp
  */
-
 abstract class UserPassOrgBase extends \SimpleSAML\Auth\Source
 {
     /**
@@ -127,6 +126,7 @@ abstract class UserPassOrgBase extends \SimpleSAML\Auth\Source
      * If unconfigured, the default is 'none'.
      *
      * @param string $usernameOrgMethod  The method which should be used.
+     * @return void
      */
     protected function setUsernameOrgMethod($usernameOrgMethod)
     {
@@ -151,6 +151,7 @@ abstract class UserPassOrgBase extends \SimpleSAML\Auth\Source
         return $this->usernameOrgMethod;
     }
 
+
     /**
      * Getter for the authsource config option remember.username.enabled
      * @return bool
@@ -160,6 +161,7 @@ abstract class UserPassOrgBase extends \SimpleSAML\Auth\Source
         return $this->rememberUsernameEnabled;
     }
 
+
     /**
      * Getter for the authsource config option remember.username.checked
      * @return bool
@@ -169,6 +171,7 @@ abstract class UserPassOrgBase extends \SimpleSAML\Auth\Source
         return $this->rememberUsernameChecked;
     }
 
+
     /**
      * Getter for the authsource config option remember.organization.enabled
      * @return bool
@@ -178,6 +181,7 @@ abstract class UserPassOrgBase extends \SimpleSAML\Auth\Source
         return $this->rememberOrganizationEnabled;
     }
 
+
     /**
      * Getter for the authsource config option remember.organization.checked
      * @return bool
@@ -187,6 +191,7 @@ abstract class UserPassOrgBase extends \SimpleSAML\Auth\Source
         return $this->rememberOrganizationChecked;
     }
 
+
     /**
      * Initialize login.
      *
@@ -194,6 +199,7 @@ abstract class UserPassOrgBase extends \SimpleSAML\Auth\Source
      * login page.
      *
      * @param array &$state  Information about the current authentication.
+     * @return void
      */
     public function authenticate(&$state)
     {
@@ -251,6 +257,7 @@ abstract class UserPassOrgBase extends \SimpleSAML\Auth\Source
      * @param string $username  The username the user wrote.
      * @param string $password  The password the user wrote.
      * @param string $organization  The id of the organization the user chose.
+     * @return void
      */
     public static function handleLogin($authStateId, $username, $password, $organization)
     {
@@ -301,7 +308,7 @@ abstract class UserPassOrgBase extends \SimpleSAML\Auth\Source
      * This function is used by the login form to get the available organizations.
      *
      * @param string $authStateId  The identifier of the authentication state.
-     * @return array|NULL  Array of organizations. NULL if the user must enter the
+     * @return array|null  Array of organizations. NULL if the user must enter the
      *         organization as part of the username.
      */
     public static function listOrganizations($authStateId)
diff --git a/modules/core/lib/Stats/Output/File.php b/modules/core/lib/Stats/Output/File.php
index cac817c83b784f5e7fca13d3a6dca81d0497ab18..fb95e42e7382d6dea8b1d2a58dc39d6dee2d80a5 100644
--- a/modules/core/lib/Stats/Output/File.php
+++ b/modules/core/lib/Stats/Output/File.php
@@ -7,7 +7,6 @@ namespace SimpleSAML\Module\core\Stats\Output;
  *
  * @package SimpleSAMLphp
  */
-
 class File extends \SimpleSAML\Stats\Output
 {
     /**
@@ -24,10 +23,11 @@ class File extends \SimpleSAML\Stats\Output
 
     /**
      * The current file date.
-     * @var string
+     * @var string|null
      */
     private $fileDate = null;
 
+
     /**
      * Initialize the output.
      *
@@ -44,10 +44,12 @@ class File extends \SimpleSAML\Stats\Output
         }
     }
 
+
     /**
      * Open a log file.
      *
      * @param string $date  The date for the log file.
+     * @return void
      */
     private function openLog($date)
     {
@@ -70,10 +72,12 @@ class File extends \SimpleSAML\Stats\Output
         $this->fileDate = $date;
     }
 
+
     /**
      * Write a stats event.
      *
      * @param array $data  The event.
+     * @return void
      */
     public function emit(array $data)
     {
diff --git a/modules/core/lib/Stats/Output/Log.php b/modules/core/lib/Stats/Output/Log.php
index e3eff86663cac6955df4ff620944547578e4d415..d4919c5795cc2a02efb867e7b209e9df88828f00 100644
--- a/modules/core/lib/Stats/Output/Log.php
+++ b/modules/core/lib/Stats/Output/Log.php
@@ -7,19 +7,20 @@ namespace SimpleSAML\Module\core\Stats\Output;
  *
  * @package SimpleSAMLphp
  */
-
 class Log extends \SimpleSAML\Stats\Output
 {
     /**
      * The logging function we should call.
-     * @var callback
+     * @var callable
      */
     private $logger;
 
+
     /**
      * Initialize the output.
      *
      * @param \SimpleSAML\Configuration $config  The configuration for this output.
+     * @throws \Exception
      */
     public function __construct(\SimpleSAML\Configuration $config)
     {
@@ -30,10 +31,12 @@ class Log extends \SimpleSAML\Stats\Output
         }
     }
 
+
     /**
      * Write a stats event.
      *
-     * @param string $data  The event (as a JSON string).
+     * @param array $data  The event
+     * @return void
      */
     public function emit(array $data)
     {
diff --git a/modules/core/lib/Storage/SQLPermanentStorage.php b/modules/core/lib/Storage/SQLPermanentStorage.php
index 4360d5e84ad015e37438810cdc61712a85aef9ee..0650f7bf2ce9588e1905f0e11ca2f7ea9ad19d6b 100644
--- a/modules/core/lib/Storage/SQLPermanentStorage.php
+++ b/modules/core/lib/Storage/SQLPermanentStorage.php
@@ -14,8 +14,15 @@ namespace SimpleSAML\Module\core\Storage;
 
 class SQLPermanentStorage
 {
+    /** @var \PDO */
     private $db;
 
+
+    /**
+     * @param string $name
+     * @param \SimpleSAML\Configuration|null $config
+     * @throws \Exception
+     */
     public function __construct($name, $config = null)
     {
         if (is_null($config)) {
@@ -57,6 +64,15 @@ class SQLPermanentStorage
         }
     }
 
+
+    /**
+     * @param string $type
+     * @param mixed $key1
+     * @param mixed $key2
+     * @param mixed $value
+     * @param int|null $duration
+     * @return void
+     */
     public function set($type, $key1, $key2, $value, $duration = null)
     {
         if ($this->exists($type, $key1, $key2)) {
@@ -66,6 +82,15 @@ class SQLPermanentStorage
         }
     }
 
+
+    /**
+     * @param string $type
+     * @param mixed $key1
+     * @param mixed $key2
+     * @param mixed $value
+     * @param int|null $duration
+     * @return array
+     */
     private function insert($type, $key1, $key2, $value, $duration = null)
     {
         $expire = is_null($duration) ? null : (time() + $duration);
@@ -82,6 +107,15 @@ class SQLPermanentStorage
         return $results;
     }
 
+
+    /**
+     * @param string $type
+     * @param mixed $key1
+     * @param mixed $key2
+     * @param mixed $value
+     * @param int|null $duration
+     * @return array
+     */
     private function update($type, $key1, $key2, $value, $duration = null)
     {
         $expire = is_null($duration) ? null : (time() + $duration);
@@ -97,6 +131,13 @@ class SQLPermanentStorage
         return $results;
     }
 
+
+    /**
+     * @param string $type
+     * @param mixed $key1
+     * @param mixed $key2
+     * @return array|null
+     */
     public function get($type = null, $key1 = null, $key2 = null)
     {
         $conditions = $this->getCondition($type, $key1, $key2);
@@ -114,8 +155,13 @@ class SQLPermanentStorage
         return $res;
     }
 
-    /*
+    /**
      * Return the value directly (not in a container)
+     *
+     * @param string $type
+     * @param mixed $key1
+     * @param mixed $key2
+     * @return array|null
      */
     public function getValue($type = null, $key1 = null, $key2 = null)
     {
@@ -126,6 +172,13 @@ class SQLPermanentStorage
         return $res['value'];
     }
 
+
+    /**
+     * @param string $type
+     * @param mixed $key1
+     * @param mixed $key2
+     * @return bool
+     */
     public function exists($type, $key1, $key2)
     {
         $query = 'SELECT * FROM data WHERE type = :type AND key1 = :key1 AND key2 = :key2 LIMIT 1';
@@ -136,6 +189,13 @@ class SQLPermanentStorage
         return (count($results) == 1);
     }
 
+
+    /**
+     * @param string $type
+     * @param mixed $key1
+     * @param mixed $key2
+     * @return array|false|null
+     */
     public function getList($type = null, $key1 = null, $key2 = null)
     {
         $conditions = $this->getCondition($type, $key1, $key2);
@@ -154,6 +214,15 @@ class SQLPermanentStorage
         return $results;
     }
 
+
+    /**
+     * @param string $type
+     * @param mixed $key1
+     * @param mixed $key2
+     * @param string $whichKey
+     * @throws \Exception
+     * @return array|null
+     */
     public function getKeys($type = null, $key1 = null, $key2 = null, $whichKey = 'type')
     {
         if (!in_array($whichKey, ['key1', 'key2', 'type'], true)) {
@@ -178,6 +247,12 @@ class SQLPermanentStorage
         return $resarray;
     }
 
+    /**
+     * @param string $type
+     * @param mixed $key1
+     * @param mixed $key2
+     * @return bool
+     */
     public function remove($type, $key1, $key2)
     {
         $query = 'DELETE FROM data WHERE type = :type AND key1 = :key1 AND key2 = :key2';
@@ -188,6 +263,10 @@ class SQLPermanentStorage
         return (count($results) == 1);
     }
 
+
+    /**
+     * @return int
+     */
     public function removeExpired()
     {
         $query = "DELETE FROM data WHERE expire IS NOT NULL AND expire < :expire";
@@ -199,6 +278,11 @@ class SQLPermanentStorage
 
     /**
      * Create a SQL condition statement based on parameters
+     *
+     * @param string $type
+     * @param mixed $key1
+     * @param mixed $key2
+     * @return string
      */
     private function getCondition($type = null, $key1 = null, $key2 = null)
     {