From 6842bfd8649f4311967109a34afcfb59db9eee47 Mon Sep 17 00:00:00 2001
From: Jan Wennrich <jan.wennrich@pcsg.de>
Date: Thu, 1 Aug 2024 17:39:27 +0200
Subject: [PATCH] chore: set PHPStan to level 5 with baseline

---
 .phive/phars.xml      |  2 +-
 phpstan-baseline.neon | 36 ++++++++++++++++++++++++++++++++++++
 phpstan.dist.neon     |  4 +++-
 3 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/.phive/phars.xml b/.phive/phars.xml
index 63a030f..ebb5988 100644
--- a/.phive/phars.xml
+++ b/.phive/phars.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <phive xmlns="https://phar.io/phive">
-  <phar name="phpstan" version="1.11.1" installed="1.11.1" location="./tools/phpstan" copy="false"/>
+  <phar name="phpstan" version="1.11.8" installed="1.11.8" location="./tools/phpstan" copy="false"/>
   <phar name="phpunit" version="^10.5.20" installed="10.5.20" location="./tools/phpunit" copy="false"/>
   <phar name="phpcs" version="^3.10.1" installed="3.10.1" location="./tools/phpcs" copy="false"/>
   <phar name="phpcbf" version="^3.10.1" installed="3.10.1" location="./tools/phpcbf" copy="false"/>
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index e69de29..a327597 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -0,0 +1,36 @@
+parameters:
+	ignoreErrors:
+		-
+			message: "#^Call to an undefined method QUI\\\\Interfaces\\\\Users\\\\User\\:\\:checkEditPermission\\(\\)\\.$#"
+			count: 1
+			path: ajax/deleteKeys.php
+
+		-
+			message: "#^Call to an undefined method QUI\\\\Interfaces\\\\Users\\\\User\\:\\:checkEditPermission\\(\\)\\.$#"
+			count: 1
+			path: ajax/generateKey.php
+
+		-
+			message: "#^Call to an undefined method QUI\\\\Interfaces\\\\Users\\\\User\\:\\:checkEditPermission\\(\\)\\.$#"
+			count: 1
+			path: ajax/getKey.php
+
+		-
+			message: "#^Call to an undefined method QUI\\\\Interfaces\\\\Users\\\\User\\:\\:checkEditPermission\\(\\)\\.$#"
+			count: 1
+			path: ajax/getKeys.php
+
+		-
+			message: "#^Call to an undefined method QUI\\\\Interfaces\\\\Users\\\\User\\:\\:checkEditPermission\\(\\)\\.$#"
+			count: 1
+			path: ajax/regenerateRecoveryKeys.php
+
+		-
+			message: "#^Method QUI\\\\Auth\\\\Google2Fa\\\\Auth\\:\\:getPasswordResetControl\\(\\) should return QUI\\\\Control but returns null\\.$#"
+			count: 1
+			path: src/QUI/Auth/Google2Fa/Auth.php
+
+		-
+			message: "#^Property QUI\\\\Auth\\\\Google2Fa\\\\Auth\\:\\:\\$User \\(QUI\\\\Users\\\\User\\) does not accept QUI\\\\Users\\\\Nobody\\|null\\.$#"
+			count: 1
+			path: src/QUI/Auth/Google2Fa/Auth.php
diff --git a/phpstan.dist.neon b/phpstan.dist.neon
index e929f5a..dc33bb4 100644
--- a/phpstan.dist.neon
+++ b/phpstan.dist.neon
@@ -2,8 +2,10 @@ includes:
 	- phpstan-baseline.neon
 
 parameters:
-    level: 8
+    level: 5
     paths:
         - src
         - ajax
+    bootstrapFiles:
+        - tests/phpstan-bootstrap.php
     tipsOfTheDay: false
-- 
GitLab