From 6263795beb2a69d9bf4bdafecea2b60ab4214963 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= <come.chilliet@fusiondirectory.org> Date: Thu, 29 Jul 2021 09:45:41 +0200 Subject: [PATCH] :ambulance: fix(core) Fix type errors reported by phpstan issue #6134 --- include/functions.inc | 4 +++- include/simpleplugin/attributes/class_DateAttribute.inc | 2 +- include/simpleplugin/class_Attribute.inc | 5 +++++ plugins/addons/dashboard/class_dashboard.inc | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/include/functions.inc b/include/functions.inc index 71842772f..7946508fc 100644 --- a/include/functions.inc +++ b/include/functions.inc @@ -1573,9 +1573,11 @@ function fopenWithErrorHandling (...$args) { $errors = []; set_error_handler( - function ($errno, $errstr, $errfile, $errline, $errcontext) use (&$errors) + function (int $errno, string $errstr, string $errfile, int $errline, array $errcontext) use (&$errors): bool { $errors[] = $errstr; + + return TRUE; } ); $fh = @fopen(...$args); diff --git a/include/simpleplugin/attributes/class_DateAttribute.inc b/include/simpleplugin/attributes/class_DateAttribute.inc index fa7981fce..59820d400 100644 --- a/include/simpleplugin/attributes/class_DateAttribute.inc +++ b/include/simpleplugin/attributes/class_DateAttribute.inc @@ -396,7 +396,7 @@ class EpochDaysDateAttribute extends DateAttribute protected function ldapToDate ($ldapValue) { - $date = DateTime::createFromFormat('U', $ldapValue * static::$secondsPerDay, timezone::utc()); + $date = DateTime::createFromFormat('U', (string)($ldapValue * static::$secondsPerDay), timezone::utc()); if ($date !== FALSE) { return $date; } else { diff --git a/include/simpleplugin/class_Attribute.inc b/include/simpleplugin/class_Attribute.inc index b9f81b8df..190cd6c26 100644 --- a/include/simpleplugin/class_Attribute.inc +++ b/include/simpleplugin/class_Attribute.inc @@ -778,6 +778,11 @@ class Attribute return $js; } + function renderFormInput (): string + { + throw new \FusionDirectoryException('Not implemented in base class (abstract method)'); + } + function renderTemplateInput (): string { return $this->renderFormInput(); diff --git a/plugins/addons/dashboard/class_dashboard.inc b/plugins/addons/dashboard/class_dashboard.inc index 13cac88f2..7de55de5f 100644 --- a/plugins/addons/dashboard/class_dashboard.inc +++ b/plugins/addons/dashboard/class_dashboard.inc @@ -114,7 +114,7 @@ class dashboard extends simplePlugin usort($stats, function ($a, $b) { - return ($b['priority'] < $a['priority']); + return ($a['priority'] <=> $b['priority']); } ); -- GitLab