Skip to content

Commit 3e6be2e

Browse files
committed
Changes from psalm and phpcs
1 parent f3e6abb commit 3e6be2e

2 files changed

Lines changed: 52 additions & 14 deletions

File tree

lib/Auth/Process/Fticks.php

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
* - https://wiki.geant.org/display/gn42jra3/F-ticks+standard
66
* - https://tools.ietf.org/html/draft-johansson-fticks-00
77
*
8-
* @author Guy Halse, http://orcid.org/0000-0002-9388-8592
8+
* @author Guy Halse, http://orcid.org/0000-0002-9388-8592
99
* @copyright Copyright (c) 2018, South African Identity Federation
10-
* @package SimpleSAMLphp
10+
* @package SimpleSAMLphp
1111
*/
1212
class sspmod_fticks_Auth_Process_Fticks extends SimpleSAML_Auth_ProcessingFilter
1313
{
@@ -23,26 +23,27 @@ class sspmod_fticks_Auth_Process_Fticks extends SimpleSAML_Auth_ProcessingFilter
2323
/** @var string The logging backend */
2424
private $logdest = 'simplesamlphp';
2525

26-
/** @var string Backend specific logging config */
26+
/** @var array Backend specific logging config */
2727
private $logconfig = array();
2828

29-
/** @var string The username attribute to use */
29+
/** @var string|false The username attribute to use */
3030
private $userId = false;
3131

32-
/** @var string The realm attribute to use */
32+
/** @var string|false The realm attribute to use */
3333
private $realm = false;
3434

3535
/** @var string The hashing algorithm to use */
3636
private $algorithm = 'sha256';
3737

38-
/** @var array F-ticks attributes to exclude */
39-
private $exclude = array();
38+
/** @var array|false F-ticks attributes to exclude */
39+
private $exclude = false;
4040

4141

4242
/**
4343
* Log a message to the desired destination
4444
*
45-
* @param string $msg message to log
45+
* @param string $msg message to log
46+
* @return void
4647
*/
4748
private function _log($msg)
4849
{
@@ -102,8 +103,8 @@ private function _log($msg)
102103
/**
103104
* Generate a PN hash
104105
*
105-
* @param array $state
106-
* @return string $hash
106+
* @param array $state
107+
* @return string|false $hash
107108
* @throws \SimpleSAML\Error\Exception
108109
*/
109110
private function _generatePNhash(&$state) {
@@ -143,7 +144,7 @@ private function _generatePNhash(&$state) {
143144
* value = 1*( ALPHA / DIGIT / '_' / '-' / ':' / '.' / ',' / ';')
144145
* ... but add a / for entityIDs
145146
*
146-
* @param string $value
147+
* @param string $value
147148
* @return string $value
148149
*/
149150
private function _escapeFticks($value)
@@ -154,8 +155,8 @@ private function _escapeFticks($value)
154155
/**
155156
* Initialize this filter, parse configuration.
156157
*
157-
* @param array $config Configuration information about this filter.
158-
* @param mixed $reserved For future use.
158+
* @param array $config Configuration information about this filter.
159+
* @param mixed $reserved For future use.
159160
* @throws \SimpleSAML\Error\Exception
160161
*/
161162
public function __construct($config, $reserved)
@@ -254,7 +255,8 @@ public function __construct($config, $reserved)
254255
/**
255256
* Process this filter
256257
*
257-
* @param mixed &$state
258+
* @param mixed &$state
259+
* @return void
258260
*/
259261
public function process(&$state)
260262
{
@@ -320,6 +322,10 @@ public function process(&$state)
320322
if ($this->exclude !== false) {
321323
$fticks = array_filter(
322324
$fticks,
325+
/**
326+
* @param string $k
327+
* @return bool
328+
*/
323329
function($k) {
324330
return !in_array($k, $this->exclude);
325331
},
@@ -331,6 +337,11 @@ function($k) {
331337
$this->_log(
332338
'F-TICKS/'.$this->federation.'/'.self::$_fticksVersion.'#' .
333339
implode('#', array_map(
340+
/**
341+
* @param string $k
342+
* @param string $v
343+
* @return string
344+
*/
334345
function($k, $v) {
335346
return $k.'='.$this->_escapeFticks($v);
336347
},

tests/lib/Auth/Process/FticksTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class_alias('\PHPUnit\Framework\TestCase', '\PHPUnit_Framework_TestCase', true);
99
*/
1010
class sspmod_fticks_Auth_Process_FticksTest extends \PHPUnit_Framework_TestCase
1111
{
12+
/** @var array minimal request */
1213
private static $_minrequest = array(
1314
'Source' => array(
1415
'entityid' => 'https://localhost/sp',
@@ -18,6 +19,7 @@ class sspmod_fticks_Auth_Process_FticksTest extends \PHPUnit_Framework_TestCase
1819
),
1920
);
2021

22+
/** @var array SP request */
2123
private static $_sprequest = array(
2224
'saml:sp:IdP' => 'https://localhost/saml:sp:IdP',
2325
'saml:sp:SessionIndex' => 'saml:sp:SessionIndex',
@@ -27,6 +29,7 @@ class sspmod_fticks_Auth_Process_FticksTest extends \PHPUnit_Framework_TestCase
2729
),
2830
);
2931

32+
/** @var array IdP request */
3033
private static $_idprequest = array(
3134
'SimpleSAML_Auth_State.id' => 'SimpleSAML_Auth_State.id',
3235
'SimpleSAML_Auth_State.stage' => 'sspmod_core_Auth_UserPassBase.state',
@@ -47,6 +50,9 @@ private static function processFilter(array $config, array $request)
4750
return $request;
4851
}
4952

53+
/**
54+
* @return void
55+
*/
5056
protected function setUp()
5157
{
5258
\SimpleSAML_Configuration::loadFromArray(array(
@@ -59,6 +65,9 @@ protected function setUp()
5965
*/
6066
}
6167

68+
/**
69+
* @return void
70+
*/
6271
public function testMinimal()
6372
{
6473
$config = array('federation' => 'ACME', 'logdest' => 'stdout');
@@ -67,6 +76,9 @@ public function testMinimal()
6776
$result = self::processFilter($config, $request);
6877
}
6978

79+
/**
80+
* @return void
81+
*/
7082
public function testAsServiceProvider()
7183
{
7284
$config = array('federation' => 'ACME', 'logdest' => 'stdout',);
@@ -75,6 +87,9 @@ public function testAsServiceProvider()
7587
$result = self::processFilter($config, $request);
7688
}
7789

90+
/**
91+
* @return void
92+
*/
7893
public function testSPwithUserId()
7994
{
8095
$config = array('federation' => 'ACME', 'logdest' => 'stdout', 'userId' => 'eduPersonPrincipalName');
@@ -87,6 +102,9 @@ public function testSPwithUserId()
87102
$result = self::processFilter($config, $request);
88103
}
89104

105+
/**
106+
* @return void
107+
*/
90108
public function testAsIdentityProvider()
91109
{
92110
$config = array('federation' => 'ACME', 'logdest' => 'stdout',);
@@ -95,6 +113,9 @@ public function testAsIdentityProvider()
95113
$result = self::processFilter($config, $request);
96114
}
97115

116+
/**
117+
* @return void
118+
*/
98119
public function testExample()
99120
{
100121
$config = array(
@@ -116,6 +137,9 @@ public function testExample()
116137
$result = self::processFilter($config, $request);
117138
}
118139

140+
/**
141+
* @return void
142+
*/
119143
public function testFilteringArray()
120144
{
121145
$config = array('federation' => 'ACME', 'logdest' => 'stdout', 'exclude' => array('PN', 'AM'));
@@ -124,6 +148,9 @@ public function testFilteringArray()
124148
$result = self::processFilter($config, $request);
125149
}
126150

151+
/**
152+
* @return void
153+
*/
127154
public function testFilteringString()
128155
{
129156
$config = array('federation' => 'ACME', 'logdest' => 'stdout', 'exclude' => 'AM');

0 commit comments

Comments
 (0)