diff --git a/lib/SimpleSAML/Utils/System.php b/lib/SimpleSAML/Utils/System.php index d76bd84565de74399456e6e43de227969f8b84bf..1ac6018709b92648eca92a0d5884fa4e3574f79b 100644 --- a/lib/SimpleSAML/Utils/System.php +++ b/lib/SimpleSAML/Utils/System.php @@ -202,6 +202,7 @@ class System $res = @file_put_contents($tmpFile, $data); if ($res === false) { + /** @var array|null $error */ $error = error_get_last(); throw new Error\Exception( 'Error saving file "' . $tmpFile . '": ' . @@ -212,8 +213,8 @@ class System if (self::getOS() !== self::WINDOWS) { if (!chmod($tmpFile, $mode)) { unlink($tmpFile); + /** @var array|null $error */ $error = error_get_last(); - //$error = (is_array($error) ? $error['message'] : 'no error available'); throw new Error\Exception( 'Error changing file mode of "' . $tmpFile . '": ' . (is_array($error) ? $error['message'] : 'no error available') @@ -223,6 +224,7 @@ class System if (!rename($tmpFile, $filename)) { unlink($tmpFile); + /** @var array|null $error */ $error = error_get_last(); throw new Error\Exception( 'Error moving "' . $tmpFile . '" to "' . $filename . '": ' . diff --git a/lib/SimpleSAML/Utils/XML.php b/lib/SimpleSAML/Utils/XML.php index bf8de00853f444746b869aa0f845b9124c3d48ca..b8d102a752d6c833fc508be863f1ebd9cf42fffc 100644 --- a/lib/SimpleSAML/Utils/XML.php +++ b/lib/SimpleSAML/Utils/XML.php @@ -436,7 +436,7 @@ class XML * @param array $context * @return string|null */ - function (string $public = null, string $system, array $context) { + function (string $public = null, string $system, /** @scrutinizer ignore-unused */ array $context) { if (filter_var($system, FILTER_VALIDATE_URL) === $system) { return null; } diff --git a/lib/SimpleSAML/XML/Parser.php b/lib/SimpleSAML/XML/Parser.php index 7996e73ba5b28ddb8aa1e7298eb0a546e7b3e47e..ea601d8b874a010a040c2179e89c565e55dd9746 100644 --- a/lib/SimpleSAML/XML/Parser.php +++ b/lib/SimpleSAML/XML/Parser.php @@ -78,7 +78,9 @@ class Parser */ public function getValue(string $xpath, bool $required = false): ?string { + /** @var array|null $result */ $result = $this->simplexml->xpath($xpath); + if (!is_array($result) || empty($result)) { if ($required) { throw new \Exception( @@ -88,7 +90,7 @@ class Parser return null; } } - return (string) $result[0]; + return strval($result[0]); } @@ -106,6 +108,7 @@ class Parser return $seek; } } + if ($required) { throw new \Exception( 'Could not get value from XML document using multiple alternative XPath expressions.' diff --git a/modules/core/lib/Auth/Process/AttributeAlter.php b/modules/core/lib/Auth/Process/AttributeAlter.php index b9a0b3875960391d6116355c80a0086601df3602..0f4f6d3ef8a58885c4e45744ea1463e2ac40a644 100644 --- a/modules/core/lib/Auth/Process/AttributeAlter.php +++ b/modules/core/lib/Auth/Process/AttributeAlter.php @@ -151,7 +151,7 @@ class AttributeAlter extends Auth\ProcessingFilter if (preg_match($this->pattern, $value, $matches) > 0) { $new_value = $matches[0]; - if ($this->replacement !== false) { + if (is_string($this->replacement)) { $new_value = $this->replacement; } diff --git a/modules/core/lib/Auth/Process/PHP.php b/modules/core/lib/Auth/Process/PHP.php index ad3454fbd4b66116a8815c4e4705f80717458890..30ca1c35d53fc575dcaec99a2c50477dfb0cad34 100644 --- a/modules/core/lib/Auth/Process/PHP.php +++ b/modules/core/lib/Auth/Process/PHP.php @@ -60,8 +60,8 @@ class PHP extends Auth\ProcessingFilter * @param array &$state */ $function = /** @return void */ function ( - array &$attributes, - array &$state + /** @scrutinizer ignore-unused */ array &$attributes, + /** @scrutinizer ignore-unused */ array &$state ) { eval($this->code); }; diff --git a/modules/cron/lib/Controller/Cron.php b/modules/cron/lib/Controller/Cron.php index 62eae0770e5b66fd72a5b7e3a396a1140ac1994b..b7de7617958dc6ba49cfffeb7f3b610307e44f7b 100644 --- a/modules/cron/lib/Controller/Cron.php +++ b/modules/cron/lib/Controller/Cron.php @@ -78,11 +78,10 @@ class Cron /** * Show cron info. * - * @param \Symfony\Component\HttpFoundation\Request $request * @return \SimpleSAML\XHTML\Template * An HTML template or a redirection if we are not authenticated. */ - public function info(Request $request): Template + public function info(): Template { $this->authUtils::requireAdmin(); @@ -117,7 +116,6 @@ class Cron * * This controller will start a cron operation * - * @param \Symfony\Component\HttpFoundation\Request $request * @param string $tag The tag * @param string $key The secret key * @param string $output The output format, defaulting to xhtml @@ -127,7 +125,7 @@ class Cron * * @throws \SimpleSAML\Error\Exception */ - public function run(Request $request, string $tag, string $key, string $output = 'xhtml'): Response + public function run(string $tag, string $key, string $output = 'xhtml'): Response { $configKey = $this->cronconfig->getValue('key', 'secret'); if ($key !== $configKey) { diff --git a/www/_include.php b/www/_include.php index fa3035c15942a56072b0967b1ef94786e24318a7..eabeef4cfa471c588c1e09fe858246a586688c4c 100644 --- a/www/_include.php +++ b/www/_include.php @@ -25,7 +25,7 @@ function SimpleSAML_exception_handler($exception) set_exception_handler('SimpleSAML_exception_handler'); // log full backtrace on errors and warnings -function SimpleSAML_error_handler($errno, $errstr, $errfile = null, $errline = 0, $errcontext = null) +function SimpleSAML_error_handler($errno, $errstr, $errfile = null, $errline = 0, /** @scrutinizer ignore-unused */ $errcontext = null) { if (\SimpleSAML\Logger::isErrorMasked($errno)) { // masked error