Skip to content

Commit 26f1862

Browse files
committed
Migrate Psalm to PHPStan
1 parent 1322db4 commit 26f1862

7 files changed

Lines changed: 23 additions & 92 deletions

File tree

.github/workflows/php.yml

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,8 @@ jobs:
5252
with:
5353
# Should be the higest supported version, so we can use the newest tools
5454
php-version: '8.3'
55-
tools: composer, composer-require-checker, composer-unused, phpcs, psalm
56-
# optional performance gain for psalm: opcache
57-
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, opcache, openssl, pcre, posix, spl, xml
55+
tools: composer, composer-require-checker, composer-unused, phpcs
56+
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, posix, spl, xml
5857

5958
- name: Setup problem matchers for PHP
6059
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
@@ -86,27 +85,13 @@ jobs:
8685
- name: PHP Code Sniffer
8786
run: phpcs
8887

89-
- name: Psalm
90-
continue-on-error: true
91-
run: |
92-
psalm -c psalm.xml \
93-
--show-info=true \
94-
--shepherd \
95-
--php-version=${{ steps.setup-php.outputs.php-version }}
96-
97-
- name: Psalm (testsuite)
88+
- name: PHPStan
9889
run: |
99-
psalm -c psalm-dev.xml \
100-
--show-info=true \
101-
--shepherd \
102-
--php-version=${{ steps.setup-php.outputs.php-version }}
90+
vendor/bin/phpstan analyze -c phpstan.neon --debug
10391
104-
- name: Psalter
92+
- name: PHPStan (testsuite)
10593
run: |
106-
psalm --alter \
107-
--issues=UnnecessaryVarAnnotation \
108-
--dry-run \
109-
--php-version=${{ steps.setup-php.outputs.php-version }}
94+
vendor/bin/phpstan analyze -c phpstan-dev.neon --debug
11095
11196
security:
11297
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 & 32 deletions
This file was deleted.

src/Auth/Source/Twitter.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ class Twitter extends Auth\Source
4444
/**
4545
* Constructor for this authentication source.
4646
*
47-
* @param array $info Information about this authentication source.
48-
* @param array $config Configuration.
47+
* @param array<mixed> $info Information about this authentication source.
48+
* @param array<mixed> $config Configuration.
4949
*/
5050
public function __construct(array $info, array $config)
5151
{
@@ -67,7 +67,7 @@ public function __construct(array $info, array $config)
6767
/**
6868
* Log-in using Twitter platform
6969
*
70-
* @param array &$state Information about the current authentication.
70+
* @param array<mixed> &$state Information about the current authentication.
7171
*/
7272
public function authenticate(array &$state): void
7373
{
@@ -78,7 +78,7 @@ public function authenticate(array &$state): void
7878
/**
7979
* Retrieve temporary credentials
8080
*
81-
* @param array &$state Information about the current authentication.
81+
* @param array<mixed> &$state Information about the current authentication.
8282
*/
8383
private function temporaryCredentials(array &$state): never
8484
{
@@ -110,7 +110,7 @@ private function temporaryCredentials(array &$state): never
110110

111111

112112
/**
113-
* @param array &$state
113+
* @param array<mixed> &$state
114114
* @param \Symfony\Component\HttpFoundation\Request $request
115115
*/
116116
public function finalStep(array &$state, Request $request): void

src/Controller/Twitter.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
use SimpleSAML\Auth;
99
use SimpleSAML\Configuration;
1010
use SimpleSAML\Error;
11+
use SimpleSAML\HTTP\RunnableResponse;;
1112
use SimpleSAML\Module\authtwitter\Auth\Source\Twitter as TwitterSource;
1213
use SimpleSAML\Session;
13-
use Symfony\Component\HttpFoundation\{Request, StreamedResponse};
14+
use Symfony\Component\HttpFoundation\Request;;
1415

1516
/**
1617
* Controller class for the authtwitter module.
@@ -54,7 +55,7 @@ public function linkback(Request $request): StreamedResponse
5455
$state = Auth\State::loadState(base64_decode($authState), TwitterSource::STAGE_INIT);
5556

5657
// Find authentication source
57-
if (is_null($state) || !array_key_exists(TwitterSource::AUTHID, $state)) {
58+
if (!array_key_exists(TwitterSource::AUTHID, $state)) {
5859
throw new Error\BadRequest('No data in state for ' . TwitterSource::AUTHID);
5960
}
6061

@@ -80,10 +81,6 @@ public function linkback(Request $request): StreamedResponse
8081
);
8182
}
8283

83-
return new StreamedResponse(
84-
function () use (&$state): never {
85-
Auth\Source::completeAuth($state);
86-
},
87-
);
84+
return new RunnableResponse([Auth\Source::class, 'completeAuth'], [$state]);
8885
}
8986
}

0 commit comments

Comments
 (0)