Skip to content

Commit cacc152

Browse files
committed
Migrate Psalm to PHPstan
1 parent 5429e5a commit cacc152

7 files changed

Lines changed: 23 additions & 87 deletions

File tree

.github/workflows/php.yml

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

6160
- name: Setup problem matchers for PHP
6261
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
@@ -88,27 +87,13 @@ jobs:
8887
- name: PHP Code Sniffer
8988
run: phpcs
9089

91-
- name: Psalm
92-
continue-on-error: true
93-
run: |
94-
psalm -c psalm.xml \
95-
--show-info=true \
96-
--shepherd \
97-
--php-version=${{ steps.setup-php.outputs.php-version }}
98-
99-
- name: Psalm (testsuite)
90+
- name: PHPStan
10091
run: |
101-
psalm -c psalm-dev.xml \
102-
--show-info=true \
103-
--shepherd \
104-
--php-version=${{ steps.setup-php.outputs.php-version }}
92+
vendor/bin/phpstan analyze -c phpstan.neon --debug
10593
106-
- name: Psalter
94+
- name: PHPStan (testsuite)
10795
run: |
108-
psalm --alter \
109-
--issues=UnnecessaryVarAnnotation \
110-
--dry-run \
111-
--php-version=${{ steps.setup-php.outputs.php-version }}
96+
vendor/bin/phpstan analyze -c phpstan-dev.neon --debug
11297
11398
security:
11499
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/Auth/Source/Hash.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ class Hash extends UserPassBase
2626
* Our users, stored in an associative array. The key of the array is "<username>:<passwordhash>",
2727
* while the value of each element is a new array with the attributes for each user.
2828
*
29-
* @var array
29+
* @var array<string, mixed>
3030
*/
3131
private array $users;
3232

3333

3434
/**
3535
* Constructor for this authentication source.
3636
*
37-
* @param array $info Information about this authentication source.
38-
* @param array $config Configuration.
37+
* @param array<string, mixed> $info Information about this authentication source.
38+
* @param array<string, mixed> $config Configuration.
3939
*
4040
* @throws \Exception in case of a configuration error.
4141
*/
@@ -87,7 +87,7 @@ public function __construct(array $info, array $config)
8787
* @param string $username The username the user wrote.
8888
* @param string $password The password the user wrote.
8989
*
90-
* @return array Associative array with the users attributes.
90+
* @return array<string, mixed> Associative array with the users attributes.
9191
*
9292
* @throws \SimpleSAML\Error\Error if authentication fails.
9393
*/

src/Auth/Source/Htpasswd.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,23 @@ class Htpasswd extends UserPassBase
2626
/**
2727
* Our users, stored in an array, where each value is "<username>:<passwordhash>".
2828
*
29-
* @var array
29+
* @var array<int, mixed>
3030
*/
3131
private array $users;
3232

3333
/**
3434
* An array containing static attributes for our users.
3535
*
36-
* @var array
36+
* @var array<string, mixed>
3737
*/
3838
private array $attributes = [];
3939

4040

4141
/**
4242
* Constructor for this authentication source.
4343
*
44-
* @param array $info Information about this authentication source.
45-
* @param array $config Configuration.
44+
* @param array<string, mixed> $info Information about this authentication source.
45+
* @param array<string, mixed> $config Configuration.
4646
*
4747
* @throws \Exception if the htpasswd file is not readable or the static_attributes array is invalid.
4848
*/
@@ -81,7 +81,7 @@ public function __construct(array $info, array $config)
8181
* @param string $username The username the user wrote.
8282
* @param string $password The password the user wrote.
8383
*
84-
* @return array Associative array with the users attributes.
84+
* @return array<string, mixed> Associative array with the users attributes.
8585
*
8686
* @throws \SimpleSAML\Error\Error if authentication fails.
8787
*/

0 commit comments

Comments
 (0)