Skip to content

Commit b9533cd

Browse files
committed
Scrutinizer fixes
1 parent 4d57b26 commit b9533cd

File tree

4 files changed

+23
-16
lines changed

4 files changed

+23
-16
lines changed

lib/PowerIdPDisco.php

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
namespace SimpleSAML\Module\discopower;
44

5+
use SimpleSAML\Configuration;
6+
use SimpleSAML\Locale\Translate;
7+
use SimpleSAML\Logger;
8+
use SimpleSAML\Session;
9+
use SimpleSAML\Utils\HTTP;
10+
use SimpleSAML\XHTML\Template;
511
use Webmozart\Assert\Assert;
612

713
/**
@@ -52,7 +58,7 @@ public function __construct(array $metadataSets, $instance)
5258
{
5359
parent::__construct($metadataSets, $instance);
5460

55-
$this->discoconfig = \SimpleSAML\Configuration::getConfig('module_discopower.php');
61+
$this->discoconfig = Configuration::getConfig('module_discopower.php');
5662

5763
$this->cdcDomain = $this->discoconfig->getString('cdc.domain', null);
5864
if ($this->cdcDomain !== null && $this->cdcDomain[0] !== '.') {
@@ -74,7 +80,7 @@ public function __construct(array $metadataSets, $instance)
7480
*/
7581
protected function log($message)
7682
{
77-
\SimpleSAML\Logger::info('PowerIdPDisco.'.$this->instance.': '.$message);
83+
Logger::info('PowerIdPDisco.'.$this->instance.': '.$message);
7884
}
7985

8086

@@ -137,7 +143,7 @@ protected function idplistStructured($list)
137143
}
138144

139145
foreach ($slist as $tab => $tbslist) {
140-
uasort($slist[$tab], ['\SimpleSAML\Module\discopower\PowerIdPDisco', 'mcmp']);
146+
uasort($slist[$tab], [self::class, 'mcmp']);
141147
}
142148

143149
return $slist;
@@ -249,7 +255,8 @@ public function handleRequest()
249255
$idpList = $this->idplistStructured($this->filterList($idpList));
250256
$preferredIdP = $this->getRecommendedIdP();
251257

252-
$t = new \SimpleSAML\XHTML\Template($this->config, 'discopower:disco.tpl.php', 'disco');
258+
$t = new Template($this->config, 'discopower:disco.tpl.php', 'disco');
259+
$translator = $t->getTranslator();
253260

254261
$t->data['return'] = $this->returnURL;
255262
$t->data['returnIDParam'] = $this->returnIdParam;
@@ -271,22 +278,22 @@ public function handleRequest()
271278
}
272279

273280
/* store the tab list in the session */
274-
$session = \SimpleSAML\Session::getSessionFromRequest();
281+
$session = Session::getSessionFromRequest();
275282
$session->setData('discopower:tabList', 'faventry', $this->data['faventry']);
276283
$session->setData('discopower:tabList', 'tabs', array_keys($idpList));
277284
$session->setData('discopower:tabList', 'defaulttab', $t->data['defaulttab']);
278285

279286
$t->data['score'] = $this->discoconfig->getValue('score', 'quicksilver');
280287
$t->data['preferredidp'] = $preferredIdP;
281-
$t->data['urlpattern'] = htmlspecialchars(\SimpleSAML\Utils\HTTP::getSelfURLNoQuery());
288+
$t->data['urlpattern'] = htmlspecialchars(HTTP::getSelfURLNoQuery());
282289
$t->data['rememberenabled'] = $this->config->getBoolean('idpdisco.enableremember', false);
283290
$t->data['rememberchecked'] = $this->config->getBoolean('idpdisco.rememberchecked', false);
284291
$t->data['jquery'] = ['core' => true, 'ui' => true];
285292
foreach (array_keys($idpList) as $tab) {
286-
if ($t->getTag('{discopower:tabs:'.$tab.'}') === null) {
287-
$t->includeInlineTranslation('{discopower:tabs:'.$tab.'}', $tab);
293+
if ($translator->getTag('{discopower:tabs:'.$tab.'}') === null) {
294+
$translator->includeInlineTranslation('{discopower:tabs:'.$tab.'}', $tab);
288295
}
289-
$t->data['tabNames'][$tab] = \SimpleSAML\Locale\Translate::noop('{discopower:tabs:'.$tab.'}');
296+
$t->data['tabNames'][$tab] = $translator::noop('{discopower:tabs:'.$tab.'}');
290297
}
291298
$t->show();
292299
}
@@ -344,7 +351,7 @@ private function processMetadata($t, $metadata, $favourite)
344351
}
345352
$html .= $entity['translated'];
346353
if (array_key_exists('icon', $entity) && $entity['icon'] !== null) {
347-
$iconUrl = \SimpleSAML\Utils\HTTP::resolveURL($entity['icon']);
354+
$iconUrl = HTTP::resolveURL($entity['icon']);
348355
$html .= '<img alt="Icon for identity provider" class="entryicon" src="'.
349356
htmlspecialchars($iconUrl).'" />';
350357
}
@@ -429,7 +436,7 @@ protected function setPreviousIdP($idp)
429436
'secure' => true,
430437
'httponly' => false,
431438
];
432-
\SimpleSAML\Utils\HTTP::setCookie('_saml_idp', $newCookie, $params, false);
439+
HTTP::setCookie('_saml_idp', $newCookie, $params, false);
433440
}
434441

435442

www/assets/js/quicksilver.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
String.prototype.score = function (abbreviation,offset) {
3939
offset = offset || 0 // TODO: I think this is unused... remove
4040

41-
if (abbreviation.length == 0) {
41+
if (abbreviation.length === 0) {
4242
return 0.9
4343
}
4444
if (abbreviation.length > this.length) {
@@ -75,7 +75,7 @@ String.prototype.score = function (abbreviation,offset) {
7575
var j = 0;
7676
var c = this.charCodeAt(index - 1)
7777
if ( c==32 || c == 9) {
78-
for (var j=(index-2); j >= 0; j--) {
78+
for (j=(index-2); j >= 0; j--) {
7979
c = this.charCodeAt(j)
8080
score -= ((c == 32 || c == 9) ? 1 : 0.15)
8181
}

www/assets/js/suggest.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ String.prototype.score = function (abbreviation,offset) {
1616
}
1717
}
1818

19-
for (var i = 0; i < suggest_cache['len']; ++i) {
20-
if (!(this.match(suggest_cache['re'][i]['initialword']) || this.match(suggest_cache['re'][i]['word']))) {
19+
for (var j = 0; j < suggest_cache['len']; ++j) {
20+
if (!(this.match(suggest_cache['re'][j]['initialword']) || this.match(suggest_cache['re'][j]['word']))) {
2121
return 0;
2222
}
2323
}

www/assets/js/tablist.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ $(document).ready(function() {
55
for (var i = 0; i < data["tabs"].length; i++) {
66
var tab = data["tabs"][i];
77
$("#query_"+tab).liveUpdate("#list_"+tab);
8-
if (data["faventry"] == null && i == 0) {
8+
if (data["faventry"] === null && i === 0) {
99
$("#query_"+tab).focus();
1010
}
1111
}

0 commit comments

Comments
 (0)