Skip to content

Commit 675e5ec

Browse files
committed
Fix several issues reported by Scrutinizer
1 parent e2deee4 commit 675e5ec

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

modules/core/src/Auth/Process/StatisticsWithAttribute.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,17 @@ public function __construct(array &$config, $reserved)
4747
parent::__construct($config, $reserved);
4848

4949
if (array_key_exists('attributename', $config)) {
50-
$this->attribute = $config['attributename'];
5150
if (!is_string($this->attribute)) {
5251
throw new Exception('Invalid attribute name given to core:StatisticsWithAttribute filter.');
5352
}
53+
$this->attribute = $config['attributename'];
5454
}
5555

5656
if (array_key_exists('type', $config)) {
57-
$this->typeTag = $config['type'];
5857
if (!is_string($this->typeTag)) {
5958
throw new Exception('Invalid typeTag given to core:StatisticsWithAttribute filter.');
6059
}
60+
$this->typeTag = $config['type'];
6161
}
6262

6363
if (array_key_exists('skipPassive', $config)) {

modules/core/src/Auth/Process/TargetedID.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ public function __construct(array &$config, $reserved)
7676
$this->identifyingAttribute = $config['identifyingAttribute'];
7777

7878
if (array_key_exists('nameId', $config)) {
79-
$this->generateNameId = $config['nameId'];
8079
if (!is_bool($this->generateNameId)) {
8180
throw new Exception('Invalid value of \'nameId\'-option to core:TargetedID filter.');
8281
}
82+
$this->generateNameId = $config['nameId'];
8383
}
8484

8585
$this->configUtils = new Utils\Config();

modules/core/src/Controller/ErrorReport.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace SimpleSAML\Module\core\Controller;
66

7-
use Exception;
7+
use Exception as BuiltinException;
88
use FILTER_REQUIRE_SCALAR;
99
use FILTER_VALIDATE_EMAIL;
1010
use SimpleSAML\{Configuration, Error, Logger, Session, Utils};
@@ -64,7 +64,7 @@ public function main(Request $request): RedirectResponse|Template
6464

6565
try {
6666
$data = $this->session->getData('core:errorreport', $reportId);
67-
} catch (Exception $e) {
67+
} catch (BuiltinException $e) {
6868
$data = null;
6969
Logger::error('Error loading error report data: ' . var_export($e->getMessage(), true));
7070
}

modules/core/src/Controller/Exception.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace SimpleSAML\Module\core\Controller;
66

7-
use DATE_W3C;
7+
use DateTimeInterface;
88
use SimpleSAML\Assert\Assert;
99
use SimpleSAML\{Auth, Configuration, Error, Logger, Module, Session, Utils};
1010
use SimpleSAML\XHTML\Template;
@@ -66,7 +66,7 @@ public function error(Request $request, string $code): Response
6666

6767
if ($ts !== 'ERRORURL_TS') {
6868
Assert::integerish($ts);
69-
$ts = date(DATE_W3C, intval($ts));
69+
$ts = date(DateTimeInterface::W3C, intval($ts));
7070
} else {
7171
$ts = null;
7272
}

modules/core/src/Controller/Login.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace SimpleSAML\Module\core\Controller;
66

7-
use Exception;
7+
use Exception as BuiltinException;
88
use SimpleSAML\{Auth, Configuration, Error, Module, Utils};
99
use SimpleSAML\Module\core\Auth\{UserPassBase, UserPassOrgBase};
1010
use SimpleSAML\XHTML\Template;
@@ -106,7 +106,7 @@ public function loginuserpass(Request $request): Response
106106
/** @var \SimpleSAML\Module\core\Auth\UserPassBase|null $source */
107107
$source = $this->authSource::getById($state[UserPassBase::AUTHID]);
108108
if ($source === null) {
109-
throw new Exception(
109+
throw new BuiltinException(
110110
'Could not find authentication source with id ' . $state[UserPassBase::AUTHID]
111111
);
112112
}
@@ -324,7 +324,7 @@ public function loginuserpassorg(Request $request): Response
324324
/** @var \SimpleSAML\Module\core\Auth\UserPassOrgBase $source */
325325
$source = $this->authSource::getById($state[UserPassOrgBase::AUTHID]);
326326
if ($source === null) {
327-
throw new Exception(
327+
throw new BuiltinException(
328328
'Could not find authentication source with id ' . $state[UserPassOrgBase::AUTHID]
329329
);
330330
}

modules/core/src/Controller/Logout.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace SimpleSAML\Module\core\Controller;
66

7-
use Exception;
7+
use Exception as BuiltinException;
88
use SimpleSAML\{Auth, Configuration, Error, IdP, Logger, Stats, Utils};
99
use SimpleSAML\Metadata\MetaDataStorageHandler;
1010
use SimpleSAML\Module\saml\Message;
@@ -319,7 +319,7 @@ public function logoutIframe(Request $request): Template
319319
$assocIdP = IdP::getByState($this->config, $sp);
320320
$url = call_user_func([$sp['Handler'], 'getLogoutURL'], $assocIdP, $sp, null);
321321
$sp['core:Logout-IFrame:URL'] = $url;
322-
} catch (Exception $e) {
322+
} catch (BuiltinException $e) {
323323
$sp['core:Logout-IFrame:State'] = 'failed';
324324
}
325325
}

0 commit comments

Comments
 (0)