Skip to content

Commit 7577ea4

Browse files
authored
Merge pull request #34 from simplesamlphp/feature/replace-psalm
Replace super-linter with custom linters
2 parents f464100 + 7d2574f commit 7577ea4

File tree

6 files changed

+27
-100
lines changed

6 files changed

+27
-100
lines changed

.github/workflows/php.yml

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ jobs:
117117
uses: shivammathur/setup-php@v2
118118
with:
119119
php-version: ${{ matrix.php-versions }}
120-
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, posix, spl, xml
120+
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, posix, spl, xml, zip
121121
tools: composer
122122
ini-values: error_reporting=E_ALL
123123
coverage: none
@@ -201,27 +201,13 @@ jobs:
201201
- name: PHP Code Sniffer
202202
run: phpcs
203203

204-
- name: Psalm
205-
continue-on-error: true
206-
run: |
207-
psalm -c psalm.xml \
208-
--show-info=true \
209-
--shepherd \
210-
--php-version=${{ steps.setup-php.outputs.php-version }}
211-
212-
- name: Psalm (testsuite)
204+
- name: PHPStan
213205
run: |
214-
psalm -c psalm-dev.xml \
215-
--show-info=true \
216-
--shepherd \
217-
--php-version=${{ steps.setup-php.outputs.php-version }}
206+
vendor/bin/phpstan analyze -c phpstan.neon
218207
219-
- name: Psalter
208+
- name: PHPStan (testsuite)
220209
run: |
221-
psalm --alter \
222-
--issues=UnnecessaryVarAnnotation \
223-
--dry-run \
224-
--php-version=${{ steps.setup-php.outputs.php-version }}
210+
vendor/bin/phpstan analyze -c phpstan-dev.neon
225211
226212
security:
227213
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: 5
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 & 36 deletions
This file was deleted.

src/PowerIdPDisco.php

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,16 @@ class PowerIdPDisco extends IdPDisco
5151
/**
5252
* The default sort weight for entries without 'discopower.weight'.
5353
*
54-
* @var int|null
54+
* @var int
5555
*/
56-
private static ?int $defaultWeight = 100;
56+
private static int $defaultWeight = 100;
5757

5858
/**
5959
* Initializes this discovery service.
6060
*
6161
* The constructor does the parsing of the request. If this is an invalid request, it will throw an exception.
6262
*
63-
* @param array $metadataSets Array with metadata sets we find remote entities in.
63+
* @param array<mixed> $metadataSets Array with metadata sets we find remote entities in.
6464
* @param string $instance The name of this instance of the discovery service.
6565
*/
6666
public function __construct(array $metadataSets, string $instance)
@@ -102,8 +102,8 @@ protected function log(string $message): void
102102
* higher, and will always put IdP's with names configured before those with
103103
* only an entityID.
104104
*
105-
* @param array $a The metadata of the first entity.
106-
* @param array $b The metadata of the second entity.
105+
* @param array<mixed> $a The metadata of the first entity.
106+
* @param array<mixed> $b The metadata of the second entity.
107107
*
108108
* @return int How $a compares to $b.
109109
*/
@@ -135,9 +135,9 @@ public static function mcmp(array $a, array $b): int
135135
/**
136136
* Structure the list of IdPs in a hierarchy based upon the tags.
137137
*
138-
* @param array $list A list of IdPs.
138+
* @param array<mixed> $list A list of IdPs.
139139
*
140-
* @return array The list of IdPs structured accordingly.
140+
* @return array<mixed> The list of IdPs structured accordingly.
141141
*/
142142
protected function idplistStructured(array $list): array
143143
{
@@ -178,8 +178,8 @@ protected function idplistStructured(array $list): array
178178
/**
179179
* Do the actual filtering according the rules defined.
180180
*
181-
* @param array $filter A set of rules regarding filtering.
182-
* @param array $entry An entry to be evaluated by the filters.
181+
* @param array<mixed> $filter A set of rules regarding filtering.
182+
* @param array<mixed> $entry An entry to be evaluated by the filters.
183183
* @param boolean $default What to do in case the entity does not match any rules. Defaults to true.
184184
*
185185
* @return boolean True if the entity should be kept, false if it should be discarded according to the filters.
@@ -213,9 +213,9 @@ private function processFilter(array $filter, array $entry, bool $default = true
213213
* Filter a list of entities according to any filters defined in the parent class, plus discopower configuration
214214
* options regarding filtering.
215215
*
216-
* @param array $list A list of entities to filter.
216+
* @param array<mixed> $list A list of entities to filter.
217217
*
218-
* @return array The list in $list after filtering entities.
218+
* @return array<mixed> The list in $list after filtering entities.
219219
*/
220220
protected function filterList(array $list): array
221221
{
@@ -358,8 +358,8 @@ public function handleRequest(): void
358358

359359
/**
360360
* @param \SimpleSAML\XHTML\Template $t
361-
* @param array $metadata
362-
* @return array
361+
* @param array<mixed> $metadata
362+
* @return array<mixed>
363363
*/
364364
private function processMetadata(Template $t, array $metadata): array
365365
{
@@ -389,7 +389,7 @@ private function processMetadata(Template $t, array $metadata): array
389389
/**
390390
* Get the IdP entities saved in the common domain cookie.
391391
*
392-
* @return array List of IdP entities.
392+
* @return string[] List of IdP entities.
393393
*/
394394
private function getCDC(): array
395395
{
@@ -401,10 +401,6 @@ private function getCDC(): array
401401
$ret = explode(' ', $ret);
402402
foreach ($ret as &$idp) {
403403
$idp = base64_decode($idp);
404-
if ($idp === false) {
405-
// not properly base64 encoded
406-
return [];
407-
}
408404
}
409405

410406
return $ret;

0 commit comments

Comments
 (0)