diff --git a/lib/SimpleSAML/Error/Assertion.php b/lib/SimpleSAML/Error/Assertion.php
index c16f61164ceb5a1afb84f91bd9a7762b15e6449c..691f2c90410b5fa38fd78f1513ca097f9b08d964 100644
--- a/lib/SimpleSAML/Error/Assertion.php
+++ b/lib/SimpleSAML/Error/Assertion.php
@@ -53,6 +53,7 @@ class Assertion extends Exception
      *
      * This function will register this assertion handler. If will not enable assertions if they are
      * disabled.
+     * @return void
      */
     public static function installHandler()
     {
@@ -71,6 +72,7 @@ class Assertion extends Exception
      * @param string $file  The file assert was called from.
      * @param int $line  The line assert was called from.
      * @param mixed $message  The expression which was passed to the assert-function.
+     * @return void
      */
     public static function onAssertion($file, $line, $message)
     {
diff --git a/lib/SimpleSAML/Error/AuthSource.php b/lib/SimpleSAML/Error/AuthSource.php
index e075aa7bc45a5036300550bdd440de478acaae1a..4b29f3e555c210d769361396e8c21de799b741f9 100644
--- a/lib/SimpleSAML/Error/AuthSource.php
+++ b/lib/SimpleSAML/Error/AuthSource.php
@@ -12,13 +12,15 @@ namespace SimpleSAML\Error;
 class AuthSource extends Error
 {
     /**
-     * Authsource module name.
+     * Authsource module name
+     * @var string
      */
     private $authsource;
 
 
     /**
      * Reason why this request was invalid.
+     * @var string
      */
     private $reason;
 
@@ -28,6 +30,7 @@ class AuthSource extends Error
      *
      * @param string $authsource  Authsource module name from where this error was thrown.
      * @param string $reason  Description of the error.
+     * @param Exception|null $cause
      */
     public function __construct($authsource, $reason, $cause = null)
     {
diff --git a/lib/SimpleSAML/Error/BadRequest.php b/lib/SimpleSAML/Error/BadRequest.php
index 1deb08c0bf3e9c3d2b9982868454168fc76dc29a..418f184b4ff8b89748cf42efb3202a07c075e778 100644
--- a/lib/SimpleSAML/Error/BadRequest.php
+++ b/lib/SimpleSAML/Error/BadRequest.php
@@ -16,6 +16,7 @@ class BadRequest extends Error
 {
     /**
      * Reason why this request was invalid.
+     * @var string
      */
     private $reason;
 
diff --git a/lib/SimpleSAML/Error/CriticalConfigurationError.php b/lib/SimpleSAML/Error/CriticalConfigurationError.php
index d41367fbf051cd6800045888928c134a47551798..064a30fb3cf3c1cfaa3f193952af485bf963c07e 100644
--- a/lib/SimpleSAML/Error/CriticalConfigurationError.php
+++ b/lib/SimpleSAML/Error/CriticalConfigurationError.php
@@ -60,7 +60,7 @@ class CriticalConfigurationError extends ConfigurationError
 
 
     /**
-     * @param ConfigurationError $exception
+     * @param \Exception $exception
      *
      * @return CriticalConfigurationError
      */
diff --git a/lib/SimpleSAML/Error/Error.php b/lib/SimpleSAML/Error/Error.php
index 615da09c01e8b816cfbd7c8a1b5ca4232bdbfa10..7d56196be750004d891a227e351eea3ba6bd5108 100644
--- a/lib/SimpleSAML/Error/Error.php
+++ b/lib/SimpleSAML/Error/Error.php
@@ -155,6 +155,7 @@ class Error extends Exception
      * Set the HTTP return code for this error.
      *
      * This should be overridden by subclasses who want a different return code than 500 Internal Server Error.
+     * @return void
      */
     protected function setHTTPCode()
     {
@@ -208,6 +209,7 @@ class Error extends Exception
      * Display this error.
      *
      * This method displays a standard SimpleSAMLphp error page and exits.
+     * @return void
      */
     public function show()
     {
diff --git a/lib/SimpleSAML/Error/Exception.php b/lib/SimpleSAML/Error/Exception.php
index 5ab59f4821213500199c53e50b15968bc3e58124..78267a17c7fef8c3d963f01047cb7a3793bb299c 100644
--- a/lib/SimpleSAML/Error/Exception.php
+++ b/lib/SimpleSAML/Error/Exception.php
@@ -21,15 +21,15 @@ class Exception extends \Exception
      *
      * @var array
      */
-    private $backtrace;
+    private $backtrace = [];
 
 
     /**
      * The cause of this exception.
      *
-     * @var Exception
+     * @var Exception|null
      */
-    private $cause;
+    private $cause = null;
 
 
     /**
@@ -77,6 +77,7 @@ class Exception extends \Exception
      * Load the backtrace from the given exception.
      *
      * @param \Exception $exception The exception we should fetch the backtrace from.
+     * @return void
      */
     protected function initBacktrace(\Exception $exception)
     {
@@ -193,6 +194,8 @@ class Exception extends \Exception
 
     /**
      * Print the backtrace to the log if the 'debug' option is enabled in the configuration.
+     * @param int $level
+     * @return void
      */
     protected function logBacktrace($level = \SimpleSAML\Logger::DEBUG)
     {
@@ -231,6 +234,7 @@ class Exception extends \Exception
      * Override to allow errors extending this class to specify the log level themselves.
      *
      * @param int $default_level The log level to use if this method was not overridden.
+     * @return void
      */
     public function log($default_level)
     {
@@ -248,6 +252,7 @@ class Exception extends \Exception
      * Print the exception to the log with log level error.
      *
      * This function will write this exception to the log, including a full backtrace.
+     * @return void
      */
     public function logError()
     {
@@ -260,6 +265,7 @@ class Exception extends \Exception
      * Print the exception to the log with log level warning.
      *
      * This function will write this exception to the log, including a full backtrace.
+     * @return void
      */
     public function logWarning()
     {
@@ -272,6 +278,7 @@ class Exception extends \Exception
      * Print the exception to the log with log level info.
      *
      * This function will write this exception to the log, including a full backtrace.
+     * @return void
      */
     public function logInfo()
     {
@@ -284,6 +291,7 @@ class Exception extends \Exception
      * Print the exception to the log with log level debug.
      *
      * This function will write this exception to the log, including a full backtrace.
+     * @return void
      */
     public function logDebug()
     {