Skip to content

Commit 471f03f

Browse files
committed
Fix sniffer-issues
1 parent 27a0d88 commit 471f03f

25 files changed

+168
-61
lines changed

src/Cas/AttributeExtractor.php

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,23 @@
1616
*/
1717
class AttributeExtractor
1818
{
19-
/** @var Configuration */
20-
private Configuration $casconfig;
21-
22-
/** @var ProcessingChainFactory */
23-
private ProcessingChainFactory $processingChainFactory;
24-
25-
/** @var State */
19+
/** @var \SimpleSAML\Auth\State */
2620
private State $authState;
2721

2822
/**
2923
* ID of the Authentication Source used during authn.
3024
*/
3125
private ?string $authSourceId = null;
3226

27+
3328
public function __construct(
34-
Configuration $casconfig,
35-
ProcessingChainFactory $processingChainFactory,
29+
protected Configuration $casconfig,
30+
protected ProcessingChainFactory $processingChainFactory,
3631
) {
37-
$this->casconfig = $casconfig;
38-
$this->processingChainFactory = $processingChainFactory;
3932
$this->authState = new State();
4033
}
4134

35+
4236
/**
4337
* Determine the user and any CAS attributes based on the attributes from the
4438
* authsource and the CAS configuration.
@@ -97,6 +91,7 @@ public function extractUserAndAttributes(?array $state): array
9791
];
9892
}
9993

94+
10095
/**
10196
* Run authproc filters with the processing chain
10297
* Creating the ProcessingChain require metadata.
@@ -129,14 +124,15 @@ protected function runAuthProcs(array &$state): void
129124
$this->processingChainFactory->build($state)->processState($state);
130125
}
131126

127+
132128
/**
133129
* This is a wrapper around Auth/State::loadState that facilitates testing by
134130
* hiding the static method
135131
*
136132
* @param string $stateId
137133
*
138134
* @return array|null
139-
* @throws NoState
135+
* @throws \SimpleSAML\Error\NoState
140136
*/
141137
public function manageState(string $stateId): ?array
142138
{
@@ -154,6 +150,7 @@ public function manageState(string $stateId): ?array
154150
return $state;
155151
}
156152

153+
157154
/**
158155
* @param string $id
159156
* @param string $stage

src/Cas/CasException.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@
1212
*/
1313
class CasException extends Exception
1414
{
15-
/** @var string */
16-
private string $casCode;
17-
1815
/**
1916
* CasException constructor.
17+
*
2018
* @param string $casCode
2119
* @param string $message
2220
*/
23-
public function __construct(string $casCode, string $message)
24-
{
21+
public function __construct(
22+
protected string $casCode,
23+
string $message,
24+
) {
2525
parent::__construct($message);
26-
$this->casCode = $casCode;
2726
}
2827

28+
2929
/**
3030
* @return string
3131
*/

src/Cas/Factories/ProcessingChainFactory.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,12 @@
1616

1717
class ProcessingChainFactory
1818
{
19-
/** @var Configuration */
20-
private Configuration $casconfig;
21-
2219
public function __construct(
23-
Configuration $casconfig,
20+
protected Configuration $casconfig,
2421
) {
25-
$this->casconfig = $casconfig;
2622
}
2723

24+
2825
/**
2926
* @codeCoverageIgnore
3027
* @throws \Exception

src/Cas/Protocol/Cas20.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252

5353
use function base64_encode;
5454
use function count;
55-
use function filter_var;
5655
use function is_null;
5756
use function is_string;
5857
use function str_replace;

src/Cas/ServiceValidator.php

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

55
namespace SimpleSAML\Module\casserver\Cas;
66

7+
use ErrorException;
78
use SimpleSAML\Configuration;
89
use SimpleSAML\Logger;
910
use SimpleSAML\Module\casserver\Codebooks\OverrideConfigPropertiesEnum;
@@ -14,26 +15,23 @@
1415
*/
1516
class ServiceValidator
1617
{
17-
/**
18-
* @var \SimpleSAML\Configuration
19-
*/
20-
private Configuration $mainConfig;
21-
2218
/**
2319
* ServiceValidator constructor.
24-
* @param Configuration $mainConfig
20+
* @param \SimpleSAML\Configuration $mainConfig
2521
*/
26-
public function __construct(Configuration $mainConfig)
27-
{
28-
$this->mainConfig = $mainConfig;
22+
public function __construct(
23+
protected Configuration $mainConfig,
24+
) {
2925
}
3026

27+
3128
/**
3229
* Check that the $service is allowed, and if so return the configuration to use.
3330
*
3431
* @param string $service The service url. Assume to already be url decoded
3532
*
36-
* @return Configuration|null Return the configuration to use for this service, or null if service is not allowed
33+
* @return \SimpleSAML\Configuration|null Return the configuration to use for this service,
34+
* or null if service is not allowed
3735
* @throws \ErrorException
3836
*/
3937
public function checkServiceURL(string $service): ?Configuration
@@ -82,6 +80,7 @@ public function checkServiceURL(string $service): ?Configuration
8280
return Configuration::loadFromArray($serviceConfig);
8381
}
8482

83+
8584
/**
8685
* @param string $legalUrl The string or regex to use for comparison
8786
* @param string $service The service to compare
@@ -96,14 +95,14 @@ protected function validateServiceIsLegal(string $legalUrl, string $service): bo
9695
// Since "If the regex pattern passed does not compile to a valid regex, an E_WARNING is emitted. "
9796
// we will throw an exception if the warning is emitted and use try-catch to handle it
9897
set_error_handler(static function ($severity, $message, $file, $line) {
99-
throw new \ErrorException($message, $severity, $severity, $file, $line);
98+
throw new ErrorException($message, $severity, $severity, $file, $line);
10099
}, E_WARNING);
101100

102101
try {
103102
if (preg_match($legalUrl, $service) === 1) {
104103
$isValid = true;
105104
}
106-
} catch (\ErrorException $e) {
105+
} catch (ErrorException $e) {
107106
// do nothing
108107
Logger::warning("Invalid CAS legal service url '$legalUrl'. Error " . preg_last_error_msg());
109108
} finally {

src/Cas/Ticket/DelegatingTicketStore.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public function __construct(Configuration $casConfig)
6969
}
7070
}
7171

72+
7273
/**
7374
* Get the ticket, searching one or all of the delegates
7475
* @param string $ticketId The ticket to find
@@ -103,6 +104,7 @@ public function getTicket(string $ticketId): ?array
103104
}
104105
}
105106

107+
106108
/**
107109
* @param array $ticket Ticket to add
108110
* @throws \Exception from any delegate stores ONLY if no delegates worked

src/Cas/Ticket/SQLTicketStore.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ private function get(string $key): ?array
325325
* @param array $value
326326
* @param int|null $expire
327327
*
328-
* @throws Exception
328+
* @throws \Exception
329329
*/
330330
private function set(string $key, array $value, ?int $expire = null): void
331331
{

src/Controller/Cas10Controller.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class Cas10Controller
2424
{
2525
use UrlTrait;
2626

27+
2728
/** @var \SimpleSAML\Logger */
2829
protected Logger $logger;
2930

@@ -39,6 +40,7 @@ class Cas10Controller
3940
/** @var \SimpleSAML\Module\casserver\Cas\Ticket\TicketStore */
4041
protected TicketStore $ticketStore;
4142

43+
4244
/**
4345
* @param \SimpleSAML\Configuration $sspConfig
4446
* @param \SimpleSAML\Configuration|null $casConfig
@@ -68,6 +70,7 @@ public function __construct(
6870
$this->ticketStore = $ticketStore ?? new $ticketStoreClass($this->casConfig);
6971
}
7072

73+
7174
/**
7275
* @param \Symfony\Component\HttpFoundation\Request $request
7376
* @param bool $renew [OPTIONAL] - if this parameter is set, ticket validation will only succeed if the
@@ -76,7 +79,7 @@ public function __construct(
7679
* @param string|null $ticket [REQUIRED] - the service ticket issued by /login.
7780
* @param string|null $service [REQUIRED] - the identifier of the service for which the ticket was issued
7881
*
79-
* @return Response
82+
* @return \Symfony\Component\HttpFoundation\Response
8083
*/
8184
public function validate(
8285
Request $request,
@@ -162,6 +165,7 @@ public function validate(
162165
);
163166
}
164167

168+
165169
/**
166170
* Used by the unit tests
167171
*

src/Controller/Cas20Controller.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class Cas20Controller
2626
use UrlTrait;
2727
use TicketValidatorTrait;
2828

29+
2930
/** @var \SimpleSAML\Logger */
3031
protected Logger $logger;
3132

@@ -44,6 +45,7 @@ class Cas20Controller
4445
/** @var \SimpleSAML\Module\casserver\Cas\Ticket\TicketStore */
4546
protected TicketStore $ticketStore;
4647

48+
4749
/**
4850
* @param \SimpleSAML\Configuration $sspConfig
4951
* @param \SimpleSAML\Configuration|null $casConfig
@@ -78,6 +80,7 @@ public function __construct(
7880
$this->httpUtils = $httpUtils ?? new Utils\HTTP();
7981
}
8082

83+
8184
/**
8285
* @param \Symfony\Component\HttpFoundation\Request $request
8386
* @param string|null $TARGET Query parameter name for "service" used by older CAS clients'
@@ -109,6 +112,7 @@ public function serviceValidate(
109112
);
110113
}
111114

115+
112116
/**
113117
* /proxy provides proxy tickets to services that have
114118
* acquired proxy-granting tickets and will be proxying authentication to back-end services.
@@ -199,6 +203,7 @@ public function proxy(
199203
);
200204
}
201205

206+
202207
/**
203208
* @param \Symfony\Component\HttpFoundation\Request $request
204209
* @param string|null $TARGET Query parameter name for "service" used by older CAS clients'
@@ -230,6 +235,7 @@ public function proxyValidate(
230235
);
231236
}
232237

238+
233239
/**
234240
* Used by the unit tests
235241
*

src/Controller/Cas30Controller.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class Cas30Controller
2929
{
3030
use UrlTrait;
3131

32+
3233
/** @var \SimpleSAML\Logger */
3334
protected Logger $logger;
3435

@@ -44,6 +45,7 @@ class Cas30Controller
4445
/** @var \SimpleSAML\Module\casserver\Cas\Protocol\SamlValidateResponder */
4546
protected SamlValidateResponder $validateResponder;
4647

48+
4749
/**
4850
* @param \SimpleSAML\Configuration $sspConfig
4951
* @param \SimpleSAML\Configuration|null $casConfig

0 commit comments

Comments
 (0)