Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/admin/src/Controller/Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*
* @package SimpleSAML\Module\admin
*/
class Test

Check warning on line 26 in modules/admin/src/Controller/Test.php

View workflow job for this annotation

GitHub Actions / Quality control

UnusedClass

modules/admin/src/Controller/Test.php:26:7: UnusedClass: Class SimpleSAML\Module\admin\Controller\Test is never used (see https://psalm.dev/075)
{
/**
* @var \SimpleSAML\Utils\Auth
Expand Down Expand Up @@ -101,7 +101,7 @@
* @param string|null $as
* @return \SimpleSAML\XHTML\Template|\SimpleSAML\HTTP\RunnableResponse
*/
public function main(Request $request, string $as = null): Response
public function main(Request $request, ?string $as = null): Response
{
$this->authUtils->requireAdmin();
if (is_null($as)) {
Expand Down
4 changes: 2 additions & 2 deletions modules/core/src/Auth/Process/Cardinality.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ class Cardinality extends Auth\ProcessingFilter
*
* @param array &$config Configuration information about this filter.
* @param mixed $reserved For future use.
* @param \SimpleSAML\Utils\HTTP $httpUtils HTTP utility service (handles redirects).
* @param \SimpleSAML\Utils\HTTP|null $httpUtils HTTP utility service (handles redirects).
* @throws \SimpleSAML\Error\Exception
*/
public function __construct(array &$config, $reserved, Utils\HTTP $httpUtils = null)
public function __construct(array &$config, $reserved, ?Utils\HTTP $httpUtils = null)
{
parent::__construct($config, $reserved);

Expand Down
4 changes: 2 additions & 2 deletions modules/core/src/Auth/Process/CardinalitySingle.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ class CardinalitySingle extends Auth\ProcessingFilter
*
* @param array &$config Configuration information about this filter.
* @param mixed $reserved For future use.
* @param \SimpleSAML\Utils\HTTP $httpUtils HTTP utility service (handles redirects).
* @param \SimpleSAML\Utils\HTTP|null $httpUtils HTTP utility service (handles redirects).
*/
public function __construct(array &$config, $reserved, Utils\HTTP $httpUtils = null)
public function __construct(array &$config, $reserved, ?Utils\HTTP $httpUtils = null)
{
parent::__construct($config, $reserved);

Expand Down
22 changes: 11 additions & 11 deletions modules/core/src/Storage/SQLPermanentStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class SQLPermanentStorage
* @param \SimpleSAML\Configuration|null $config
* @throws \Exception
*/
public function __construct(string $name, Configuration $config = null)
public function __construct(string $name, ?Configuration $config = null)
{
if (is_null($config)) {
$config = Configuration::getInstance();
Expand Down Expand Up @@ -81,7 +81,7 @@ public function __construct(string $name, Configuration $config = null)
* @param string $value
* @param int|null $duration
*/
public function set(string $type, string $key1, string $key2, string $value, int $duration = null): void
public function set(string $type, string $key1, string $key2, string $value, ?int $duration = null): void
{
if ($this->exists($type, $key1, $key2)) {
$this->update($type, $key1, $key2, $value, $duration);
Expand All @@ -99,7 +99,7 @@ public function set(string $type, string $key1, string $key2, string $value, int
* @param int|null $duration
* @return array
*/
private function insert(string $type, string $key1, string $key2, string $value, int $duration = null): array
private function insert(string $type, string $key1, string $key2, string $value, ?int $duration = null): array
{
$expire = is_null($duration) ? null : (time() + $duration);

Expand All @@ -125,7 +125,7 @@ private function insert(string $type, string $key1, string $key2, string $value,
* @param int|null $duration
* @return array
*/
private function update(string $type, string $key1, string $key2, string $value, int $duration = null): array
private function update(string $type, string $key1, string $key2, string $value, ?int $duration = null): array
{
$expire = is_null($duration) ? null : (time() + $duration);

Expand All @@ -148,7 +148,7 @@ private function update(string $type, string $key1, string $key2, string $value,
* @param string|null $key2
* @return array|null
*/
public function get(string $type = null, string $key1 = null, string $key2 = null): ?array
public function get(?string $type = null, ?string $key1 = null, ?string $key2 = null): ?array
{
$conditions = $this->getCondition($type, $key1, $key2);
$query = 'SELECT * FROM data WHERE ' . $conditions;
Expand All @@ -173,7 +173,7 @@ public function get(string $type = null, string $key1 = null, string $key2 = nul
* @param string|null $key2
* @return string|null
*/
public function getValue(string $type = null, string $key1 = null, string $key2 = null): ?string
public function getValue(?string $type = null, ?string $key1 = null, ?string $key2 = null): ?string
{
$res = $this->get($type, $key1, $key2);
if ($res === null) {
Expand Down Expand Up @@ -206,7 +206,7 @@ public function exists(string $type, string $key1, string $key2): bool
* @param string|null $key2
* @return array|false
*/
public function getList(string $type = null, string $key1 = null, string $key2 = null)
public function getList(?string $type = null, ?string $key1 = null, ?string $key2 = null)
{
$conditions = $this->getCondition($type, $key1, $key2);
$query = 'SELECT * FROM data WHERE ' . $conditions;
Expand Down Expand Up @@ -234,9 +234,9 @@ public function getList(string $type = null, string $key1 = null, string $key2 =
* @return array|null
*/
public function getKeys(
string $type = null,
string $key1 = null,
string $key2 = null,
?string $type = null,
?string $key1 = null,
?string $key2 = null,
string $whichKey = 'type',
): ?array {
if (!in_array($whichKey, ['key1', 'key2', 'type'], true)) {
Expand Down Expand Up @@ -299,7 +299,7 @@ public function removeExpired(): int
* @param string|null $key2
* @return string
*/
private function getCondition(string $type = null, string $key1 = null, string $key2 = null): string
private function getCondition(?string $type = null, ?string $key1 = null, ?string $key2 = null): string
{
$conditions = [];
if (!is_null($type)) {
Expand Down
2 changes: 1 addition & 1 deletion modules/cron/src/Cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Cron
* @param \SimpleSAML\Configuration $cronconfig The cron configuration to use. If not specified defaults
* to `config/module_cron.php`
*/
public function __construct(Configuration $cronconfig = null)
public function __construct(?Configuration $cronconfig = null)
{
if ($cronconfig == null) {
$cronconfig = Configuration::getConfig('module_cron.php');
Expand Down
4 changes: 2 additions & 2 deletions modules/debugsp/src/Controller/Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function setAuthState(Auth\State $authState): void
* @param string|null $as
* @return \SimpleSAML\XHTML\Template|\SimpleSAML\HTTP\RunnableResponse
*/
private function makeSPList(Request $request, string $as = null): Response
private function makeSPList(Request $request, ?string $as = null): Response
{
$t = new Template($this->config, 'debugsp:authsource_list.twig');
$samlSpSources = Auth\Source::getSourcesOfType('saml:SP');
Expand All @@ -101,7 +101,7 @@ private function makeSPList(Request $request, string $as = null): Response
* @param string|null $as
* @return \SimpleSAML\XHTML\Template|\SimpleSAML\HTTP\RunnableResponse
*/
public function main(Request $request, string $as = null): Response
public function main(Request $request, ?string $as = null): Response
{
if (is_null($as)) {
$t = $this->makeSPList($request, $as);
Expand Down
2 changes: 1 addition & 1 deletion modules/saml/src/Error.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct(
private string $status,
private ?string $subStatus = null,
private ?string $statusMessage = null,
Throwable $cause = null,
?Throwable $cause = null,
) {
$st = self::shortStatus($status);
if ($subStatus !== null) {
Expand Down
2 changes: 1 addition & 1 deletion modules/saml/src/Error/NoAuthnContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class NoAuthnContext extends \SimpleSAML\Module\saml\Error
* @param string|null $message A short message explaining why this error happened.
* @param \Throwable|null $cause An exception that caused this error.
*/
public function __construct(string $responsible, string $message = null, Throwable $cause = null)
public function __construct(string $responsible, ?string $message = null, ?Throwable $cause = null)
{
parent::__construct($responsible, Constants::STATUS_NO_AUTHN_CONTEXT, $message, $cause);
}
Expand Down
2 changes: 1 addition & 1 deletion modules/saml/src/Error/NoAvailableIDP.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class NoAvailableIDP extends \SimpleSAML\Module\saml\Error
* @param string|null $message A short message explaining why this error happened.
* @param \Throwable|null $cause An exception that caused this error.
*/
public function __construct(string $responsible, string $message = null, Throwable $cause = null)
public function __construct(string $responsible, ?string $message = null, ?Throwable $cause = null)
{
parent::__construct($responsible, Constants::STATUS_NO_AVAILABLE_IDP, $message, $cause);
}
Expand Down
2 changes: 1 addition & 1 deletion modules/saml/src/Error/NoPassive.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class NoPassive extends \SimpleSAML\Module\saml\Error
* @param string|null $message A short message explaining why this error happened.
* @param \Throwable|null $cause An exception that caused this error.
*/
public function __construct(string $responsible, string $message = null, Throwable $cause = null)
public function __construct(string $responsible, ?string $message = null, ?Throwable $cause = null)
{
parent::__construct($responsible, Constants::STATUS_NO_PASSIVE, $message, $cause);
}
Expand Down
2 changes: 1 addition & 1 deletion modules/saml/src/Error/NoSupportedIDP.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class NoSupportedIDP extends \SimpleSAML\Module\saml\Error
* @param string|null $message A short message explaining why this error happened.
* @param \Throwable|null $cause An exception that caused this error.
*/
public function __construct(string $responsible, string $message = null, Throwable $cause = null)
public function __construct(string $responsible, ?string $message = null, ?Throwable $cause = null)
{
parent::__construct($responsible, Constants::STATUS_NO_SUPPORTED_IDP, $message, $cause);
}
Expand Down
2 changes: 1 addition & 1 deletion modules/saml/src/Error/ProxyCountExceeded.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ProxyCountExceeded extends \SimpleSAML\Module\saml\Error
* @param string|null $message A short message explaining why this error happened.
* @param \Throwable|null $cause An exception that caused this error.
*/
public function __construct(string $responsible, string $message = null, Throwable $cause = null)
public function __construct(string $responsible, ?string $message = null, ?Throwable $cause = null)
{
parent::__construct($responsible, Constants::STATUS_PROXY_COUNT_EXCEEDED, $message, $cause);
}
Expand Down
20 changes: 10 additions & 10 deletions modules/saml/src/IdP/SAML2.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,9 @@ public static function handleAuthError(Error\Exception $exception, array $state)
private static function getAssertionConsumerService(
array $supportedBindings,
Configuration $spMetadata,
string $AssertionConsumerServiceURL = null,
string $ProtocolBinding = null,
int $AssertionConsumerServiceIndex = null,
?string $AssertionConsumerServiceURL = null,
?string $ProtocolBinding = null,
?int $AssertionConsumerServiceIndex = null,
bool $authnRequestSigned = false,
): ?array {
/* We want to pick the best matching endpoint in the case where for example
Expand Down Expand Up @@ -533,9 +533,9 @@ public static function receiveAuthnRequest(IdP $idp): void
*
* @param \SimpleSAML\IdP $idp The IdP we are sending a logout request from.
* @param array $association The association that should be terminated.
* @param string|null $relayState An id that should be carried across the logout.
* @param string|null $relayState An id that should be carried across the logout.
*/
public static function sendLogoutRequest(IdP $idp, array $association, string $relayState = null): void
public static function sendLogoutRequest(IdP $idp, array $association, ?string $relayState = null): void
{
Logger::info('Sending SAML 2.0 LogoutRequest to: ' . var_export($association['saml:entityID'], true));

Expand Down Expand Up @@ -702,11 +702,11 @@ public static function receiveLogoutMessage(IdP $idp): void
*
* @param \SimpleSAML\IdP $idp The IdP we are sending a logout request from.
* @param array $association The association that should be terminated.
* @param string|NULL $relayState An id that should be carried across the logout.
* @param string|NULL $relayState An id that should be carried across the logout.
*
* @return string The logout URL.
*/
public static function getLogoutURL(IdP $idp, array $association, string $relayState = null): string
public static function getLogoutURL(IdP $idp, array $association, ?string $relayState = null): string
{
Logger::info('Sending SAML 2.0 LogoutRequest to: ' . var_export($association['saml:entityID'], true));

Expand Down Expand Up @@ -761,15 +761,15 @@ public static function getAssociationConfig(IdP $idp, array $association): Confi
* Retrieve the metadata of a hosted SAML 2 IdP.
*
* @param string $entityid The entity ID of the hosted SAML 2 IdP whose metadata we want.
* @param MetaDataStorageHandler $handler Optionally the metadata storage to use,
* @param MetaDataStorageHandler|null $handler Optionally the metadata storage to use,
* if omitted the configured handler will be used.
*
* @return array
* @throws \SimpleSAML\Error\CriticalConfigurationError
* @throws \SimpleSAML\Error\Exception
* @throws \SimpleSAML\Error\MetadataNotFound
*/
public static function getHostedMetadata(string $entityid, MetaDataStorageHandler $handler = null): array
public static function getHostedMetadata(string $entityid, ?MetaDataStorageHandler $handler = null): array
{
$globalConfig = Configuration::getInstance();
if ($handler === null) {
Expand Down Expand Up @@ -1410,7 +1410,7 @@ private static function buildLogoutRequest(
Configuration $idpMetadata,
Configuration $spMetadata,
array $association,
string $relayState = null,
?string $relayState = null,
): LogoutRequest {
$lr = Message::buildLogoutRequest($idpMetadata, $spMetadata);
$lr->setRelayState($relayState);
Expand Down
4 changes: 2 additions & 2 deletions src/SimpleSAML/Auth/Simple.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ class Simple
*/
public function __construct(
protected string $authSource,
Configuration $config = null,
Session $session = null,
?Configuration $config = null,
?Session $session = null,
) {
if ($config === null) {
$config = Configuration::getInstance();
Expand Down
2 changes: 1 addition & 1 deletion src/SimpleSAML/Compat/SspContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function getTempDir(): string
* @param string $date
* @param int|null $mode
*/
public function writeFile(string $filename, string $data, int $mode = null): void
public function writeFile(string $filename, string $data, ?int $mode = null): void
{
$sysUtils = new Utils\System();

Expand Down
8 changes: 4 additions & 4 deletions src/SimpleSAML/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ class Database
/**
* Retrieves the current database instance. Will create a new one if there isn't an existing connection.
*
* @param \SimpleSAML\Configuration $altConfig Optional: Instance of a \SimpleSAML\Configuration class
* @param \SimpleSAML\Configuration|null $altConfig Optional: Instance of a \SimpleSAML\Configuration class
*
* @return \SimpleSAML\Database The shared database connection.
*/
public static function getInstance(Configuration $altConfig = null): Database
public static function getInstance(?Configuration $altConfig = null): Database
{
$config = ($altConfig) ? $altConfig : Configuration::getInstance();
$instanceId = self::generateInstanceId($config);
Expand Down Expand Up @@ -159,12 +159,12 @@ private static function generateInstanceId(Configuration $config): string
* @param string $dsn Database connection string
* @param string|null $username SQL user
* @param string|null $password SQL password
* @param array $options PDO options
* @param array $options PDO options
*
* @throws \Exception If an error happens while trying to connect to the database.
* @return \PDO object
*/
private function connect(string $dsn, string $username = null, string $password = null, array $options): PDO
private function connect(string $dsn, ?string $username = null, ?string $password = null, array $options = []): PDO
{
try {
$db = new PDO($dsn, $username, $password, $options);
Expand Down
2 changes: 1 addition & 1 deletion src/SimpleSAML/Error/AuthSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class AuthSource extends Error
public function __construct(
private string $authsource,
private string $reason,
Throwable $cause = null,
?Throwable $cause = null,
) {
$this->authsource = $authsource;
$this->reason = $reason;
Expand Down
2 changes: 1 addition & 1 deletion src/SimpleSAML/Error/ConfigurationError.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ConfigurationError extends Error
* @param string|null $file The configuration file that originated this error.
* @param array|null $config The configuration array that led to this problem.
*/
public function __construct(string $reason = null, string $file = null, array $config = null)
public function __construct(?string $reason = null, ?string $file = null, ?array $config = null)
{
$file_str = '';
$reason_str = '.';
Expand Down
2 changes: 1 addition & 1 deletion src/SimpleSAML/Error/CriticalConfigurationError.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class CriticalConfigurationError extends ConfigurationError
* @param string|null $file The configuration file that originated this error.
* @param array|null $config The configuration array that led to this problem.
*/
public function __construct(string $reason = null, string $file = null, array $config = null)
public function __construct(?string $reason = null, ?string $file = null, ?array $config = null)
{
if ($config === null) {
$config = self::$minimum_config;
Expand Down
4 changes: 2 additions & 2 deletions src/SimpleSAML/Error/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public function customErrorHandler(
E_USER_DEPRECATED => 'User Deprecated',
E_NOTICE => 'Notice',
E_USER_NOTICE => 'User Notice',
// E_STRICT has become deprecated in PHP 8.4
E_STRICT => 'Runtime Notice',
// E_STRICT (2048) has become deprecated in PHP 8.4
2048 => 'Runtime Notice',
E_WARNING => 'Warning',
E_USER_WARNING => 'User Warning',
E_COMPILE_WARNING => 'Compile Warning',
Expand Down
2 changes: 1 addition & 1 deletion src/SimpleSAML/Error/UserAborted.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class UserAborted extends Error
*
* @param \Throwable|null $cause The exception that caused this error.
*/
public function __construct(Throwable $cause = null)
public function __construct(?Throwable $cause = null)
{
parent::__construct(ErrorCodes::USERABORTED, $cause);
}
Expand Down
2 changes: 1 addition & 1 deletion src/SimpleSAML/IdP.php
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ public function handleLogoutRequest(array &$state, ?string $assocId): void
* @param string|null $relayState The RelayState from the start of the logout.
* @param \SimpleSAML\Error\Exception|null $error The error that occurred during session termination (if any).
*/
public function handleLogoutResponse(string $assocId, ?string $relayState, Error\Exception $error = null): void
public function handleLogoutResponse(string $assocId, ?string $relayState, ?Error\Exception $error = null): void
{
$index = strpos($assocId, ':');
Assert::integer($index);
Expand Down
2 changes: 1 addition & 1 deletion src/SimpleSAML/IdP/IFrameLogoutHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function startLogout(array &$state, ?string $assocId): void
* @param string|null $relayState The RelayState from the start of the logout.
* @param \SimpleSAML\Error\Exception|null $error The error that occurred during session termination (if any).
*/
public function onResponse(string $assocId, ?string $relayState, Error\Exception $error = null): void
public function onResponse(string $assocId, ?string $relayState, ?Error\Exception $error = null): void
{
$this->idp->terminateAssociation($assocId);

Expand Down
2 changes: 1 addition & 1 deletion src/SimpleSAML/IdP/LogoutHandlerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ public function startLogout(array &$state, ?string $assocId): void;
* @param string|null $relayState The RelayState from the start of the logout.
* @param \SimpleSAML\Error\Exception|null $error The error that occurred during session termination (if any).
*/
public function onResponse(string $assocId, ?string $relayState, Error\Exception $error = null): void;
public function onResponse(string $assocId, ?string $relayState, ?Error\Exception $error = null): void;
}
Loading
Loading