Skip to content

Commit ca0e771

Browse files
committed
Replace Psalm with PHPStan
1 parent d8c736f commit ca0e771

File tree

8 files changed

+22
-91
lines changed

8 files changed

+22
-91
lines changed

.gitattributes

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ codecov.yml export-ignore
55
.editorconfig export-ignore
66
.gitattributes export-ignore
77
.gitignore export-ignore
8-
psalm.xml export-ignore
9-
psalm-dev.xml export-ignore
8+
phpstan.neon export-ignore
9+
phpstan-dev.neon export-ignore
10+
phpstan-baseline.neon export-ignore
11+
phpstan-baseline-dev.neon export-ignore
1012
phpcs.xml export-ignore
1113
phpunit.xml export-ignore
1214
.php_cs.dist export-ignore

.github/workflows/php.yml

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,7 @@ jobs:
165165
with:
166166
# Should be the higest supported version, so we can use the newest tools
167167
php-version: '8.5'
168-
tools: composer, composer-require-checker, composer-unused, psalm
169-
# optional performance gain for psalm: opcache
168+
tools: composer, composer-require-checker, composer-unused
170169
extensions: ctype, date, dom, fileinfo, filter, hash, intl, ldap, mbstring, opcache, openssl, pcre, spl, xml
171170

172171
- name: Setup problem matchers for PHP
@@ -199,27 +198,13 @@ jobs:
199198
- name: PHP Code Sniffer
200199
run: vendor/bin/phpcs
201200

202-
- name: Psalm
203-
continue-on-error: true
201+
- name: PHPStan
204202
run: |
205-
psalm -c psalm.xml \
206-
--show-info=true \
207-
--shepherd \
208-
--php-version=${{ steps.setup-php.outputs.php-version }}
203+
vendor/bin/phpstan analyze -c phpstan.neon --debug
209204
210-
- name: Psalm (testsuite)
205+
- name: PHPStan (testsuite)
211206
run: |
212-
psalm -c psalm-dev.xml \
213-
--show-info=true \
214-
--shepherd \
215-
--php-version=${{ steps.setup-php.outputs.php-version }}
216-
217-
- name: Psalter
218-
run: |
219-
psalm --alter \
220-
--issues=UnnecessaryVarAnnotation \
221-
--dry-run \
222-
--php-version=${{ steps.setup-php.outputs.php-version }}
207+
vendor/bin/phpstan analyze -c phpstan-dev.neon --debug
223208
224209
security:
225210
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: 5
3+
paths:
4+
- src

psalm-dev.xml

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

psalm.xml

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

src/Auth/Source/Negotiate.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function __construct(array $info, array $config)
6767
*
6868
* @param array &$state Information about the current authentication.
6969
*/
70-
public function authenticate(array &$state): void
70+
public function authenticate(array &$state): never
7171
{
7272
// set the default backend to config
7373
$state['LogoutState'] = [
@@ -95,14 +95,10 @@ public function authenticate(array &$state): void
9595
) {
9696
Logger::debug('Negotiate - session disabled. falling back');
9797
$this->fallBack($state);
98-
// never executed
99-
assert(false);
10098
}
10199

102100
if (!$this->checkMask()) {
103101
$this->fallBack($state);
104-
// never executed
105-
assert(false);
106102
}
107103

108104
// No auth token. Send it.
@@ -235,17 +231,13 @@ public function externalAuth(array &$state): void
235231
];
236232
Logger::info('Negotiate - authenticate(): ' . $user . ' authorized.');
237233
Auth\Source::completeAuth($state);
238-
// Never reached.
239-
assert(false);
240234
}
241235
}
242236

243237

244238
/**
245239
* Passes control of the login process to a different module.
246240
*
247-
* @param string $state Information about the current authentication.
248-
*
249241
* @throws \SimpleSAML\Error\BadRequest If couldn't determine the auth source.
250242
* @throws \SimpleSAML\Error\NoState
251243
* @throws \SimpleSAML\Error\Exception
@@ -265,7 +257,6 @@ public static function external(): void
265257
}
266258
$httpUtils = new Utils\HTTP();
267259
$httpUtils->redirectUntrustedURL($sid['url'], ['negotiateext.auth' => 'false']);
268-
assert(false);
269260
}
270261

271262
Assert::isArray($state);
@@ -294,7 +285,6 @@ public static function external(): void
294285
}
295286

296287
self::fallBack($state);
297-
assert(false);
298288
}
299289

300290

tests/src/Controller/NegotiateControllerTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,14 @@ public function testEnable(): void
130130

131131
// Validate cookie
132132
$cookies = $response->headers->getCookies();
133+
$cookie = null;
133134
foreach ($cookies as $cookie) {
134135
if ($cookie->getName() === 'NEGOTIATE_AUTOLOGIN_DISABLE_PERMANENT') {
135136
break;
136137
}
137138
}
138139

140+
$this->assertNotNull($cookie);
139141
$this->assertEquals($cookie->getValue(), null);
140142
$this->assertEquals($cookie->getDomain(), null);
141143
$this->assertEquals($cookie->getPath(), '/');
@@ -160,12 +162,14 @@ public function testDisable(): void
160162

161163
// Validate cookie
162164
$cookies = $response->headers->getCookies();
165+
$cookie = null;
163166
foreach ($cookies as $cookie) {
164167
if ($cookie->getName() === 'NEGOTIATE_AUTOLOGIN_DISABLE_PERMANENT') {
165168
break;
166169
}
167170
}
168171

172+
$this->assertNotNull($cookie);
169173
$this->assertEquals($cookie->getValue(), 'true');
170174
$this->assertEquals($cookie->getDomain(), null);
171175
$this->assertEquals($cookie->getPath(), '/');

0 commit comments

Comments
 (0)