From 0adf064bf867f42f9c5b8947bfd5092ff04420d2 Mon Sep 17 00:00:00 2001
From: Tim van Dijen <tvdijen@gmail.com>
Date: Sun, 30 Aug 2020 16:23:20 +0200
Subject: [PATCH] Psalm fixes

---
 composer.json                           | 5 +----
 lib/SimpleSAML/Metadata/SAMLBuilder.php | 5 ++++-
 lib/SimpleSAML/Session.php              | 4 +++-
 lib/SimpleSAML/SessionHandlerPHP.php    | 4 ++--
 lib/SimpleSAML/Utilities.php            | 2 --
 lib/SimpleSAML/Utils/HTTP.php           | 4 ++--
 6 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/composer.json b/composer.json
index 88a2abcf0..ca8d9831f 100644
--- a/composer.json
+++ b/composer.json
@@ -95,11 +95,8 @@
     "require-dev": {
         "ext-curl": "*",
         "mikey179/vfsstream": "~1.6",
-        "phpunit/phpunit": "~7.5",
-        "sensiolabs/security-checker": "^6.0.3",
         "simplesamlphp/simplesamlphp-test-framework": "^0.1.2",
-        "squizlabs/php_codesniffer": "^3.5",
-        "vimeo/psalm": "~3.13"
+        "vimeo/psalm": "~3.14"
     },
     "suggest": {
         "predis/predis": "Needed if a Redis server is used to store session information",
diff --git a/lib/SimpleSAML/Metadata/SAMLBuilder.php b/lib/SimpleSAML/Metadata/SAMLBuilder.php
index 60adb3003..f038854a2 100644
--- a/lib/SimpleSAML/Metadata/SAMLBuilder.php
+++ b/lib/SimpleSAML/Metadata/SAMLBuilder.php
@@ -156,7 +156,10 @@ class SAMLBuilder
         $metadata = Configuration::loadFromArray($metadata, $metadata['entityid']);
         $defaultEndpoint = $metadata->getDefaultEndpoint('SingleSignOnService');
 
-        /** @psalm-suppress UndefinedClass */
+        /**
+         * @psalm-var \SAML2\XML\md\RoleDescriptor $e
+         * @psalm-suppress UndefinedClass
+         */
         $e = new SecurityTokenServiceType();
         $e->setLocation($defaultEndpoint['Location']);
 
diff --git a/lib/SimpleSAML/Session.php b/lib/SimpleSAML/Session.php
index ea78e0eca..927f74e8b 100644
--- a/lib/SimpleSAML/Session.php
+++ b/lib/SimpleSAML/Session.php
@@ -47,8 +47,10 @@ class Session implements \Serializable, Utils\ClearableState
      * This variable holds the instance of the session - Singleton approach.
      *
      * Warning: do not set the instance manually, call Session::load() instead.
+     *
+     * @var \SimpleSAML\Session|null
      */
-    private static $instance;
+    private static $instance = null;
 
     /**
      * The global configuration.
diff --git a/lib/SimpleSAML/SessionHandlerPHP.php b/lib/SimpleSAML/SessionHandlerPHP.php
index 3a4f2ed18..cfde6bf26 100644
--- a/lib/SimpleSAML/SessionHandlerPHP.php
+++ b/lib/SimpleSAML/SessionHandlerPHP.php
@@ -80,7 +80,7 @@ class SessionHandlerPHP extends SessionHandler
 
         if (!headers_sent()) {
             if (version_compare(PHP_VERSION, '7.3.0', '>=')) {
-                /** @psalm-suppress InvalidArgument  This annotation may be removed in Psalm >=3.0.15 */
+                /** @psalm-suppress InvalidArgument */
                 session_set_cookie_params([
                     'lifetime' => $params['lifetime'],
                     'path' => $params['path'],
@@ -372,7 +372,7 @@ class SessionHandlerPHP extends SessionHandler
         }
 
         if (version_compare(PHP_VERSION, '7.3.0', '>=')) {
-            /** @psalm-suppress InvalidArgument  This annotation may be removed in Psalm >=3.0.15 */
+            /** @psalm-suppress InvalidArgument */
             session_set_cookie_params($cookieParams);
         } else {
             session_set_cookie_params(
diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php
index be12e719b..e395084bb 100644
--- a/lib/SimpleSAML/Utilities.php
+++ b/lib/SimpleSAML/Utilities.php
@@ -237,8 +237,6 @@ class Utilities
      */
     private static function doRedirect(string $url, array $parameters = []): void
     {
-        Assert::NotEmpty($url);
-
         if (!empty($parameters)) {
             $url = self::addURLparameter($url, $parameters);
         }
diff --git a/lib/SimpleSAML/Utils/HTTP.php b/lib/SimpleSAML/Utils/HTTP.php
index 141a2233b..3fdacdfc0 100644
--- a/lib/SimpleSAML/Utils/HTTP.php
+++ b/lib/SimpleSAML/Utils/HTTP.php
@@ -1206,7 +1206,7 @@ class HTTP
         if (version_compare(PHP_VERSION, '7.3.0', '>=')) {
             /* use the new options array for PHP >= 7.3 */
             if ($params['raw']) {
-                /** @psalm-suppress InvalidArgument  Remove when Psalm >= 3.4.10 */
+                /** @psalm-suppress InvalidArgument */
                 $success = @setrawcookie(
                     $name,
                     $value,
@@ -1220,7 +1220,7 @@ class HTTP
                     ]
                 );
             } else {
-                /** @psalm-suppress InvalidArgument  Remove when Psalm >= 3.4.10 */
+                /** @psalm-suppress InvalidArgument */
                 $success = @setcookie(
                     $name,
                     $value,
-- 
GitLab