Skip to content

Commit 06bbbd4

Browse files
committed
Replace Psalm with PHPstan
1 parent d8d955a commit 06bbbd4

File tree

13 files changed

+68
-121
lines changed

13 files changed

+68
-121
lines changed

.github/workflows/php.yml

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,8 @@ jobs:
162162
with:
163163
# Should be the higest supported version, so we can use the newest tools
164164
php-version: '8.4'
165-
tools: composer, composer-require-checker, composer-unused, phpcs, psalm
166-
# optional performance gain for psalm: opcache
167-
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, opcache, openssl, \
165+
tools: composer, composer-require-checker, composer-unused, phpcs
166+
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, \
168167
pcre, posix, soap, spl, xml
169168

170169
- name: Setup problem matchers for PHP
@@ -197,27 +196,14 @@ jobs:
197196
- name: PHP Code Sniffer
198197
run: phpcs
199198

200-
- name: Psalm
201-
continue-on-error: true
202-
run: |
203-
psalm -c psalm.xml \
204-
--show-info=true \
205-
--shepherd \
206-
--php-version=${{ steps.setup-php.outputs.php-version }}
207199

208-
- name: Psalm (testsuite)
200+
- name: PHPStan
209201
run: |
210-
psalm -c psalm-dev.xml \
211-
--show-info=true \
212-
--shepherd \
213-
--php-version=${{ steps.setup-php.outputs.php-version }}
202+
vendor/bin/phpstan analyze -c phpstan.neon
214203
215-
- name: Psalter
204+
- name: PHPStan (testsuite)
216205
run: |
217-
psalm --alter \
218-
--issues=UnnecessaryVarAnnotation \
219-
--dry-run \
220-
--php-version=${{ steps.setup-php.outputs.php-version }}
206+
vendor/bin/phpstan analyze -c phpstan-dev.neon
221207
222208
security:
223209
name: Security checks

phpstan-dev.neon

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
parameters:
2+
level: 9
3+
paths:
4+
- tests

phpstan.neon

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
parameters:
2+
level: 6
3+
paths:
4+
- src

psalm-dev.xml

Lines changed: 0 additions & 27 deletions
This file was deleted.

psalm.xml

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/IdP/ADFS.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public static function receivePassiveAuthnRequest(
119119
$password = Password::getChildrenOfClass($usernameToken->toXML());
120120
$password = array_pop($password);
121121

122-
if ($username === null || $password === null) {
122+
if ($password === null) {
123123
throw new Error\BadRequest('Missing username or password in SOAP header.');
124124
} else {
125125
$_SERVER['PHP_AUTH_USER'] = $username->getContent();
@@ -207,7 +207,7 @@ function () use ($idp, &$state) {
207207
* @param string $issuer
208208
* @param string $target
209209
* @param string $nameid
210-
* @param array $attributes
210+
* @param array<mixed> $attributes
211211
* @param int $assertionLifetime
212212
* @param string $method
213213
* @return \SimpleSAML\SAML11\XML\saml\Assertion
@@ -287,7 +287,7 @@ private static function generateActiveAssertion(
287287
* @param string $issuer
288288
* @param string $target
289289
* @param string $nameid
290-
* @param array $attributes
290+
* @param array<mixed> $attributes
291291
* @param int $assertionLifetime
292292
* @return \SimpleSAML\SAML11\XML\saml\Assertion
293293
*/
@@ -409,7 +409,7 @@ private static function postResponse(string $wreply, string $wresult, ?string $w
409409

410410

411411
/**
412-
* @param array $state
412+
* @param array<mixed> $state
413413
* @throws \Exception
414414
*/
415415
public static function sendPassiveResponse(array $state): void
@@ -519,7 +519,7 @@ public static function sendPassiveResponse(array $state): void
519519

520520

521521
/**
522-
* @param array $state
522+
* @param array<mixed> $state
523523
* @throws \Exception
524524
*/
525525
public static function sendResponse(array $state): void
@@ -603,7 +603,7 @@ public static function sendResponse(array $state): void
603603

604604
/**
605605
* @param \SimpleSAML\IdP $idp
606-
* @param array $state
606+
* @param array<mixed> $state
607607
*/
608608
public static function sendLogoutResponse(IdP $idp, array $state): void
609609
{
@@ -645,7 +645,7 @@ public static function receiveLogoutMessage(IdP $idp): void
645645
* accepts an association array, and returns a URL that can be accessed to terminate the association
646646
*
647647
* @param \SimpleSAML\IdP $idp
648-
* @param array $association
648+
* @param array<mixed> $association
649649
* @param string $relayState
650650
* @return string
651651
*/

src/IdP/MetadataBuilder.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ protected function signDocument(AbstractMetadataDocument $document): AbstractMet
9999
{
100100
$cryptoUtils = new Utils\Crypto();
101101

102-
/** @var array $keyArray */
102+
/** @var array<mixed> $keyArray */
103103
$keyArray = $cryptoUtils->loadPrivateKey($this->config, true, 'metadata.sign.');
104104
$certArray = $cryptoUtils->loadPublicKey($this->config, false, 'metadata.sign.');
105105
$algo = $this->config->getOptionalString('metadata.sign.algorithm', C::SIG_RSA_SHA256);
@@ -123,6 +123,8 @@ protected function signDocument(AbstractMetadataDocument $document): AbstractMet
123123

124124
/**
125125
* This method builds the md:Organization element, if any
126+
*
127+
* @return \SimpleSAML\SAML2\XML\md\Organization
126128
*/
127129
private function getOrganization(): ?Organization
128130
{
@@ -157,6 +159,8 @@ private function getOrganization(): ?Organization
157159

158160
/**
159161
* This method builds the role descriptor elements
162+
*
163+
* @return \SimpleSAML\SAML2\XML\md\AbstractRoleDescriptor[]
160164
*/
161165
private function getRoleDescriptor(): array
162166
{
@@ -177,6 +181,8 @@ private function getRoleDescriptor(): array
177181

178182
/**
179183
* This method builds the SecurityTokenService element
184+
*
185+
* @return \SimpleSAML\WSSecurity\XML\fed\SecurityTokenServiceType
180186
*/
181187
public function getSecurityTokenService(): SecurityTokenServiceType
182188
{
@@ -202,6 +208,8 @@ public function getSecurityTokenService(): SecurityTokenServiceType
202208

203209
/**
204210
* This method builds the md:KeyDescriptor elements, if any
211+
*
212+
* @return \SimpleSAML\SAML2\XML\md\KeyDescriptor[]
205213
*/
206214
private function getKeyDescriptor(): array
207215
{
@@ -238,6 +246,8 @@ private function getKeyDescriptor(): array
238246

239247
/**
240248
* This method builds the md:ContactPerson elements, if any
249+
*
250+
* @return \SimpleSAML\SAML2\XML\md\ContactPerson[]
241251
*/
242252
private function getContactPerson(): array
243253
{
@@ -255,6 +265,8 @@ private function getContactPerson(): array
255265

256266
/**
257267
* This method builds the md:Extensions, if any
268+
*
269+
* @return \SimpleSAML\SAML2\XML\md\Extensions|null
258270
*/
259271
private function getExtensions(): ?Extensions
260272
{
@@ -332,6 +344,13 @@ private function getExtensions(): ?Extensions
332344
}
333345

334346

347+
/**
348+
* @param string $use
349+
* @param string $x509Cert
350+
* @param string|null $keyName
351+
*
352+
* @return \SimpleSAML\SAML2\XML\md\KeyDescriptor
353+
*/
335354
private static function buildKeyDescriptor(string $use, string $x509Cert, ?string $keyName): KeyDescriptor
336355
{
337356
Assert::oneOf($use, ['encryption', 'signing']);

src/IdP/PassiveIdP.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class PassiveIdP
2929
/**
3030
* A cache for resolving IdP id's.
3131
*
32-
* @var array
32+
* @var \SimpleSAML\Module\adfs\IdP\PassiveIdP[]
3333
*/
3434
private static array $idpCache = [];
3535

@@ -130,7 +130,7 @@ public static function getById(Configuration $config, string $id): PassiveIdP
130130
* Retrieve the IdP "owning" the state.
131131
*
132132
* @param \SimpleSAML\Configuration $config The Configuration.
133-
* @param array &$state The state array.
133+
* @param array<mixed> &$state The state array.
134134
*
135135
* @return \SimpleSAML\Module\adfs\IdP\PassiveIdP The IdP.
136136
*/
@@ -167,7 +167,7 @@ public function isAuthenticated(): bool
167167
/**
168168
* Called after authproc has run.
169169
*
170-
* @param array $state The authentication request state array.
170+
* @param array<mixed> $state The authentication request state array.
171171
*/
172172
public static function postAuthProc(array $state): void
173173
{
@@ -191,7 +191,7 @@ public static function postAuthProc(array $state): void
191191
/**
192192
* The user is authenticated.
193193
*
194-
* @param array $state The authentication request state array.
194+
* @param array<mixed> $state The authentication request state array.
195195
*
196196
* @throws \SimpleSAML\Error\Exception If we are not authenticated.
197197
*/
@@ -238,7 +238,7 @@ public static function postAuth(array $state): Response
238238
*
239239
* This function authenticates the user.
240240
*
241-
* @param array &$state The authentication request state.
241+
* @param array<mixed> &$state The authentication request state.
242242
*/
243243
private function authenticate(array &$state): Response
244244
{
@@ -249,7 +249,7 @@ private function authenticate(array &$state): Response
249249
/**
250250
* Process authentication requests.
251251
*
252-
* @param array &$state The authentication request state.
252+
* @param array<mixed> &$state The authentication request state.
253253
*/
254254
public function handleAuthenticationRequest(array &$state): Response
255255
{
@@ -314,7 +314,7 @@ public function getLogoutHandler(): LogoutHandlerInterface
314314
*
315315
* This function will never return.
316316
*
317-
* @param array &$state The logout request state.
317+
* @param array<mixed> &$state The logout request state.
318318
*/
319319
public function finishLogout(array &$state): Response
320320
{

src/MetadataExchange.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ class MetadataExchange
5656
{
5757
/**
5858
* Constructor.
59-
*
60-
* @param \SimpleSAML\Configuration $config The general configuration
61-
* @param \SimpleSAML\Configuration $metadata The metadata configuration
6259
*/
6360
public function __construct()
6461
{
@@ -68,7 +65,7 @@ public function __construct()
6865
/**
6966
* Build a mex document
7067
*
71-
* @return \SimpleSAML\WSSecurity\XML\wsdl\Definitions
68+
* @return \SimpleSAML\WSDL\XML\wsdl\Definitions
7269
*/
7370
public function buildDocument(): Definitions
7471
{
@@ -89,7 +86,7 @@ public function buildDocument(): Definitions
8986
/**
9087
* This method builds the wsp:Policy elements
9188
*
92-
* @param \SimpleSAML\WSSecurity\XML\wsp\Policy[]
89+
* @return \SimpleSAML\WSSecurity\XML\wsp\Policy[]
9390
*/
9491
private function getPolicies(): array
9592
{
@@ -106,7 +103,7 @@ private function getPolicies(): array
106103
/**
107104
* This method builds the wsdl:types elements
108105
*
109-
* @param \SimpleSAML\WSSecurity\XML\wsdl\Types[]
106+
* @return \SimpleSAML\WSSL\XML\wsdl\Types[]
110107
private function getTypes(): array
111108
{
112109
$defaultEndpoint = Module::getModuleURL('adfs/services/trust/mex');
@@ -132,7 +129,7 @@ private function getTypes(): array
132129
/**
133130
* This method builds the wsdl:message elements
134131
*
135-
* @param \SimpleSAML\WSSecurity\XML\wsdl\Message[]
132+
* @return \SimpleSAML\WSDL\XML\wsdl\Message[]
136133
*/
137134
private function getMessages(): array
138135
{
@@ -190,7 +187,7 @@ private function getMessages(): array
190187
/**
191188
* This method builds the wsdl:portType elements
192189
*
193-
* @param \SimpleSAML\WSSecurity\XML\wsdl\PortType[]
190+
* @return \SimpleSAML\WSDL\XML\wsdl\PortType[]
194191
*/
195192
private function getPortTypes(): array
196193
{
@@ -258,7 +255,7 @@ private function getPortTypes(): array
258255
/**
259256
* This method builds the wsdl:binding elements
260257
*
261-
* @param \SimpleSAML\WSSecurity\XML\wsdl\Binding[]
258+
* @return \SimpleSAML\WSDL\XML\wsdl\Binding[]
262259
*/
263260
private function getBindings(): array
264261
{
@@ -569,7 +566,7 @@ private function getBindings(): array
569566
/**
570567
* This method builds the wsdl:service elements
571568
*
572-
* @param \SimpleSAML\WSSecurity\XML\wsdl\Service[]
569+
* @return \SimpleSAML\WSDL\XML\wsdl\Service[]
573570
*/
574571
private function getServices(): array
575572
{

0 commit comments

Comments
 (0)