Skip to content
Snippets Groups Projects
Commit 7cf3718a authored by Tim van Dijen's avatar Tim van Dijen
Browse files

Fix several Psalm issues

parent 16c9f1f9
Branches
Tags
No related merge requests found
......@@ -15,7 +15,7 @@ use Symfony\Component\Routing\RouterInterface;
class RouterDebugCommand extends Command
{
/**
* @var string
* @var string|null
*/
protected static $defaultName = 'debug:router';
......
......@@ -14,6 +14,10 @@ use Symfony\Contracts\Translation\TranslatorInterface;
class TwigTranslator implements TranslatorInterface
{
/** @var string|null $locale */
private ?string $locale = null;
/** @var callable $translator */
private $translator;
/**
......
......@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace SimpleSAML;
use Exception;
use SimpleSAML\Assert\Assert;
use SimpleSAML\Kernel;
use SimpleSAML\Utils;
......@@ -348,7 +349,7 @@ class Module
return $mod_config[$module];
}
throw new \Exception("Invalid module.enable value for the '$module' module.");
throw new Exception("Invalid module.enable value for the '$module' module.");
}
$core_module = array_key_exists($module, self::$core_modules) ? true : false;
......@@ -375,7 +376,7 @@ class Module
$dh = scandir($path);
if ($dh === false) {
throw new \Exception('Unable to open module directory "' . $path . '".');
throw new Exception('Unable to open module directory "' . $path . '".');
}
foreach ($dh as $f) {
......@@ -420,14 +421,14 @@ class Module
// no module involved
$className = $tmp[0];
if (!class_exists($className)) {
throw new \Exception("Could not resolve '$id': no class named '$className'.");
throw new Exception("Could not resolve '$id': no class named '$className'.");
}
} elseif (!in_array($tmp[0], self::getModules())) {
// Module not installed
throw new \Exception('No module named \'' . $tmp[0] . '\' has been installed.');
throw new Exception('No module named \'' . $tmp[0] . '\' has been installed.');
} elseif (!self::isModuleEnabled($tmp[0])) {
// Module installed, but not enabled
throw new \Exception('The module \'' . $tmp[0] . '\' is not enabled.');
throw new Exception('The module \'' . $tmp[0] . '\' is not enabled.');
} else {
// should be a module
// make sure empty types are handled correctly
......@@ -437,7 +438,7 @@ class Module
}
if ($subclass !== null && !is_subclass_of($className, $subclass)) {
throw new \Exception(
throw new Exception(
'Could not resolve \'' . $id . '\': The class \'' . $className
. '\' isn\'t a subclass of \'' . $subclass . '\'.'
);
......
......@@ -24,6 +24,6 @@ class Random
*/
public function generateID(): string
{
return '_' . bin2hex(openssl_random_pseudo_bytes((int) ((self::ID_LENGTH - 1) / 2)));
return '_' . bin2hex(openssl_random_pseudo_bytes((self::ID_LENGTH - 1) / 2));
}
}
......@@ -47,7 +47,8 @@ class SQLPermanentStorage
}
$dbfile = 'sqlite:' . $sqllitedir . $name . '.sqlite';
if ($this->db = new PDO($dbfile)) {
$this->db = new PDO($dbfile);
if ($this->db) {
$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
$q = @$this->db->query('SELECT key1 FROM data LIMIT 1');
if ($q === false) {
......
......@@ -512,7 +512,7 @@ class SP extends \SimpleSAML\Auth\Source
$policy = null;
if (is_string($state['saml:NameIDPolicy'])) {
$policy = [
'Format' => (string) $state['saml:NameIDPolicy'],
'Format' => $state['saml:NameIDPolicy'],
'AllowCreate' => true,
];
} elseif (is_array($state['saml:NameIDPolicy'])) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment