Skip to content

Commit bf0b785

Browse files
committed
Replace Psalm with PHPstan
1 parent b969760 commit bf0b785

File tree

9 files changed

+49
-98
lines changed

9 files changed

+49
-98
lines changed

.github/workflows/php.yml

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

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

88-
- name: Psalm
89-
continue-on-error: true
90-
run: |
91-
psalm -c psalm.xml \
92-
--show-info=true \
93-
--shepherd \
94-
--php-version=${{ steps.setup-php.outputs.php-version }}
95-
96-
- name: Psalm (testsuite)
87+
- name: PHPStan
9788
run: |
98-
psalm -c psalm-dev.xml \
99-
--show-info=true \
100-
--shepherd \
101-
--php-version=${{ steps.setup-php.outputs.php-version }}
89+
vendor/bin/phpstan analyze -c phpstan.neon --debug
10290
103-
- name: Psalter
91+
- name: PHPStan (testsuite)
10492
run: |
105-
psalm --alter \
106-
--issues=UnnecessaryVarAnnotation \
107-
--dry-run \
108-
--php-version=${{ steps.setup-php.outputs.php-version }}
93+
vendor/bin/phpstan analyze -c phpstan-dev.neon --debug
10994
11095
security:
11196
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/Ldap.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ class Ldap extends UserPassBase
4949
/**
5050
* Constructor for this authentication source.
5151
*
52-
* @param array $info Information about this authentication source.
53-
* @param array $config Configuration.
52+
* @param array<mixed> $info Information about this authentication source.
53+
* @param array<mixed> $config Configuration.
5454
*/
5555
public function __construct(array $info, array $config)
5656
{
@@ -72,10 +72,14 @@ public function __construct(array $info, array $config)
7272
* @param string $username The username the user wrote.
7373
* @param string $password The password the user wrote.
7474
* @param array|null $sasl_args SASL options
75-
* @return array Associative array with the users attributes.
75+
* @return array<mixed> Associative array with the users attributes.
7676
*/
77-
protected function loginSasl(string $username, #[\SensitiveParameter]string $password, array $sasl_args = []): array
78-
{
77+
protected function loginSasl(
78+
string $username,
79+
#[\SensitiveParameter]
80+
string $password,
81+
array $sasl_args = [],
82+
): array {
7983
if (preg_match('/^\s*$/', $password)) {
8084
// The empty string is considered an anonymous bind to Symfony
8185
throw new Error\Error('WRONGUSERPASS');
@@ -164,7 +168,7 @@ protected function loginSasl(string $username, #[\SensitiveParameter]string $pas
164168
*
165169
* @param string $username The username the user wrote.
166170
* @param string $password The password the user wrote.
167-
* @return array Associative array with the users attributes.
171+
* @return array<mixed> Associative array with the users attributes.
168172
*/
169173
protected function login(string $username, #[\SensitiveParameter]string $password): array
170174
{
@@ -176,7 +180,7 @@ protected function login(string $username, #[\SensitiveParameter]string $passwor
176180
* Attempt to find a user's attributes given its username.
177181
*
178182
* @param string $username The username who's attributes we want.
179-
* @return array Associative array with the users attributes.
183+
* @return array<mixed> Associative array with the users attributes.
180184
*/
181185
public function getAttributes(string $username): array
182186
{
@@ -232,7 +236,7 @@ public function getAttributes(string $username): array
232236

233237
/**
234238
* @param \Symfony\Component\Ldap\Entry $entry
235-
* @return array
239+
* @return array<mixed>
236240
*/
237241
private function processAttributes(Entry $entry): array
238242
{

src/Auth/Source/LdapMulti.php

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,22 @@ class LdapMulti extends UserPassOrgBase
3333

3434
/**
3535
* An array with mappings for organization => authsource.
36+
*
37+
* @var array<mixed>
3638
*/
3739
private array $mapping;
3840

3941
/**
4042
* An array with descriptions for organizations.
43+
*
44+
* @var array<mixed>
4145
*/
4246
private array $orgs;
4347

4448
/**
4549
* An array of organization IDs to LDAP configuration objects.
50+
*
51+
* @var array<mixed>
4652
*/
4753
private array $ldapOrgs;
4854

@@ -55,8 +61,8 @@ class LdapMulti extends UserPassOrgBase
5561
/**
5662
* Constructor for this authentication source.
5763
*
58-
* @param array $info Information about this authentication source.
59-
* @param array $config Configuration.
64+
* @param array<mixed. $info Information about this authentication source.
65+
* @param array<mixed> $config Configuration.
6066
*/
6167
public function __construct(array $info, array $config)
6268
{
@@ -109,9 +115,9 @@ public function __construct(array $info, array $config)
109115
*
110116
* @param string $username The username the user wrote.
111117
* @param string $password The password the user wrote.
112-
* @param string $organizaion The organization the user chose.
113-
* @param array|null $sasl_args SASL options
114-
* @return array Associative array with the users attributes.
118+
* @param string $organization The organization the user chose.
119+
* @param array<mixed>|null $sasl_args SASL options
120+
* @return array<mixed> Associative array with the users attributes.
115121
*/
116122
protected function loginSasl(
117123
string $username,
@@ -134,6 +140,9 @@ protected function loginSasl(
134140

135141
$ldap = new class (['AuthId' => $authsource], $sourceConfig->toArray()) extends Ldap
136142
{
143+
/**
144+
* @return array<mixed>
145+
*/
137146
public function loginOverload(
138147
string $username,
139148
#[\SensitiveParameter]string $password,
@@ -146,19 +155,21 @@ public function loginOverload(
146155
return $ldap->loginOverload($username, $password, $sasl_args);
147156
}
148157

158+
149159
/**
150160
* Attempt to log in using the given username and password.
151161
*
152162
* @param string $username The username the user wrote.
153163
* @param string $password The password the user wrote.
154-
* @param string $organizaion The organization the user chose.
155-
* @return array Associative array with the users attributes.
164+
* @param string $organization The organization the user chose.
165+
* @return array<mixed> Associative array with the users attributes.
156166
*/
157167
protected function login(string $username, #[\SensitiveParameter]string $password, string $organization): array
158168
{
159169
return $this->loginSasl($username, $password, $organization);
160170
}
161171

172+
162173
/**
163174
* Retrieve list of organizations.
164175
*

src/Connector/Ldap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class Ldap implements ConnectorInterface
4444
* @param int $version
4545
* @param string $extension
4646
* @param bool $debug
47-
* @param array $options
47+
* @param array<mixed> $options
4848
*/
4949
public function __construct(
5050
string $connection_strings,

src/ConnectorInterface.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ public function whoami(): string;
6464
/**
6565
* Search the LDAP-directory for a specific object
6666
*
67-
* @param array $searchBase
67+
* @param string[] $searchBase
6868
* @param string $filter
69-
* @param array $options
69+
* @param array<mixed> $options
7070
* @param boolean $allowMissing
7171
* @return \Symfony\Component\Ldap\Entry|null The result of the search or null if none found
7272
* @psalm-return ($allowMissing is true ? \Symfony\Component\Ldap\Entry|null : \Symfony\Component\Ldap\Entry)
@@ -85,9 +85,9 @@ public function search(
8585
/**
8686
* Search the LDAP-directory for any object matching the search filter
8787
*
88-
* @param array $searchBase
88+
* @param string[] $searchBase
8989
* @param string $filter
90-
* @param array $options
90+
* @param array<mixed> $options
9191
* @param boolean $allowMissing
9292
* @return \Symfony\Component\Ldap\Entry[] The result of the search
9393
*

0 commit comments

Comments
 (0)