diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml
index 81b9113..6f6a8f6 100644
--- a/.github/workflows/php.yml
+++ b/.github/workflows/php.yml
@@ -14,53 +14,61 @@ on: # yamllint disable-line rule:truthy
workflow_dispatch:
jobs:
+ phplinter:
+ name: 'PHP-Linter'
+ strategy:
+ fail-fast: false
+ matrix:
+ php-version: ['8.1', '8.2', '8.3', '8.4']
+
+ uses: simplesamlphp/simplesamlphp-test-framework/.github/workflows/reusable_phplinter.yml@v1.9.2
+ with:
+ php-version: ${{ matrix.php-version }}
+
linter:
- name: Linter
- runs-on: ['ubuntu-latest']
+ name: 'Linter'
+ strategy:
+ fail-fast: false
- steps:
- - uses: actions/checkout@v4
- with:
- # super-linter needs the full git history to get the
- # list of files that changed across commits
- fetch-depth: 0
-
- - name: Lint Code Base
- uses: super-linter/super-linter/slim@v7
- env:
- SAVE_SUPER_LINTER_OUTPUT: false
- # To report GitHub Actions status checks
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- LOG_LEVEL: NOTICE
- LINTER_RULES_PATH: 'tools/linters'
- VALIDATE_ALL_CODEBASE: true
- VALIDATE_CSS: true
- VALIDATE_JAVASCRIPT_ES: true
- VALIDATE_JSON: true
- VALIDATE_PHP_BUILTIN: true
- VALIDATE_YAML: true
- VALIDATE_XML: true
- VALIDATE_GITHUB_ACTIONS: true
+ uses: simplesamlphp/simplesamlphp-test-framework/.github/workflows/reusable_linter.yml@v1.9.2
+ with:
+ enable_eslinter: false
+ enable_jsonlinter: true
+ enable_stylelinter: false
+ enable_yamllinter: true
- quality:
- name: Quality control
- runs-on: [ubuntu-latest]
+ unit-tests-linux:
+ name: "Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
+ runs-on: ${{ matrix.operating-system }}
+ needs: [phplinter, linter]
+ strategy:
+ fail-fast: false
+ matrix:
+ operating-system: [ubuntu-latest]
+ php-versions: ['8.1', '8.2', '8.3', '8.4']
steps:
- name: Setup PHP, with composer and extensions
- id: setup-php
# https://github.com/shivammathur/setup-php
uses: shivammathur/setup-php@v2
with:
- # Should be the higest supported version, so we can use the newest tools
- php-version: '8.4'
- tools: composer, composer-require-checker, composer-unused, phpcs, psalm
- # optional performance gain for psalm: opcache
- extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, opcache, openssl, pcre, posix, spl, xml
+ php-version: ${{ matrix.php-versions }}
+ extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, spl, xml
+ tools: composer
+ ini-values: error_reporting=E_ALL
+ coverage: pcov
- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
+ - name: Setup problem matchers for PHPUnit
+ run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
+
+ - name: Set git to use LF
+ run: |
+ git config --global core.autocrlf false
+ git config --global core.eol lf
+
- uses: actions/checkout@v4
- name: Get composer cache directory
@@ -73,64 +81,60 @@ jobs:
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- - name: Validate composer.json and composer.lock
- run: composer validate
-
- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader
- - name: Check code for hard dependencies missing in composer.json
- run: composer-require-checker check --config-file=tools/composer-require-checker.json composer.json
-
- - name: Check code for unused dependencies in composer.json
- run: composer-unused
-
- - name: PHP Code Sniffer
- run: phpcs
+ - name: Run unit tests with coverage
+ if: ${{ matrix.php-versions == '8.4' }}
+ run: vendor/bin/phpunit
- - name: Psalm
- continue-on-error: true
- run: |
- psalm -c psalm.xml \
- --show-info=true \
- --shepherd \
- --php-version=${{ steps.setup-php.outputs.php-version }}
+ - name: Run unit tests (no coverage)
+ if: ${{ matrix.php-versions != '8.4' }}
+ run: vendor/bin/phpunit --no-coverage
- - name: Psalm (testsuite)
- run: |
- psalm -c psalm-dev.xml \
- --show-info=true \
- --shepherd \
- --php-version=${{ steps.setup-php.outputs.php-version }}
+ - name: Save coverage data
+ if: ${{ matrix.php-versions == '8.4' }}
+ uses: actions/upload-artifact@v4
+ with:
+ name: coverage-data
+ path: ${{ github.workspace }}/build
- - name: Psalter
- run: |
- psalm --alter \
- --issues=UnnecessaryVarAnnotation \
- --dry-run \
- --php-version=${{ steps.setup-php.outputs.php-version }}
+ unit-tests-windows:
+ name: "Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
+ runs-on: ${{ matrix.operating-system }}
+ needs: [phplinter, linter]
+ strategy:
+ fail-fast: true
+ matrix:
+ operating-system: [windows-latest]
+ php-versions: ['8.1', '8.2', '8.3', '8.4']
- security:
- name: Security checks
- runs-on: [ubuntu-latest]
steps:
- name: Setup PHP, with composer and extensions
# https://github.com/shivammathur/setup-php
uses: shivammathur/setup-php@v2
with:
- # Should be the lowest supported version
- php-version: '8.1'
- extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, posix, spl, xml
+ php-version: ${{ matrix.php-versions }}
+ extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, spl, xml
tools: composer
+ ini-values: error_reporting=E_ALL
coverage: none
- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
+ - name: Setup problem matchers for PHPUnit
+ run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
+
+ - name: Set git to use LF
+ run: |
+ git config --global core.autocrlf false
+ git config --global core.eol lf
+
- uses: actions/checkout@v4
- name: Get composer cache directory
- run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
+ run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$env:GITHUB_ENV"
- name: Cache composer dependencies
uses: actions/cache@v4
@@ -142,47 +146,28 @@ jobs:
- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader
- - name: Security check for locked dependencies
- run: composer audit
-
- - name: Update Composer dependencies
- run: composer update --no-progress --prefer-dist --optimize-autoloader
-
- - name: Security check for updated dependencies
- run: composer audit
+ - name: Run unit tests
+ run: vendor/bin/phpunit --no-coverage
- unit-tests-linux:
- name: "Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
- runs-on: ${{ matrix.operating-system }}
- needs: [linter, quality, security]
- strategy:
- fail-fast: false
- matrix:
- operating-system: [ubuntu-latest]
- php-versions: ['8.1', '8.2', '8.3', '8.4']
+ quality:
+ name: Quality control
+ runs-on: [ubuntu-latest]
+ needs: [unit-tests-linux]
steps:
- name: Setup PHP, with composer and extensions
+ id: setup-php
# https://github.com/shivammathur/setup-php
uses: shivammathur/setup-php@v2
with:
- php-version: ${{ matrix.php-versions }}
- extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, posix, spl, xml
- tools: composer
- ini-values: error_reporting=E_ALL
- coverage: pcov
+ # Should be the higest supported version, so we can use the newest tools
+ php-version: '8.4'
+ tools: composer, composer-require-checker, composer-unused, phpcs
+ extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, spl, xml
- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
- - name: Setup problem matchers for PHPUnit
- run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
-
- - name: Set git to use LF
- run: |
- git config --global core.autocrlf false
- git config --global core.eol lf
-
- uses: actions/checkout@v4
- name: Get composer cache directory
@@ -195,60 +180,51 @@ jobs:
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
+ - name: Validate composer.json and composer.lock
+ run: composer validate
+
- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader
- - name: Run unit tests with coverage
- if: ${{ matrix.php-versions == '8.4' }}
- run: vendor/bin/phpunit
+ - name: Check code for hard dependencies missing in composer.json
+ run: composer-require-checker check --config-file=tools/composer-require-checker.json composer.json
- - name: Run unit tests (no coverage)
- if: ${{ matrix.php-versions != '8.4' }}
- run: vendor/bin/phpunit --no-coverage
+ - name: Check code for unused dependencies in composer.json
+ run: composer-unused
- - name: Save coverage data
- if: ${{ matrix.php-versions == '8.4' }}
- uses: actions/upload-artifact@v4
- with:
- name: coverage-data
- path: ${{ github.workspace }}/build
+ - name: PHP Code Sniffer
+ run: phpcs
- unit-tests-windows:
- name: "Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
- runs-on: ${{ matrix.operating-system }}
- needs: [linter, quality, security]
- strategy:
- fail-fast: true
- matrix:
- operating-system: [windows-latest]
- php-versions: ['8.1', '8.2', '8.3', '8.4']
+ - name: PHPStan
+ run: |
+ vendor/bin/phpstan analyze -c phpstan.neon
+ - name: PHPStan (testsuite)
+ run: |
+ vendor/bin/phpstan analyze -c phpstan-dev.neon
+
+ security:
+ name: Security checks
+ runs-on: [ubuntu-latest]
+ needs: [unit-tests-linux]
steps:
- name: Setup PHP, with composer and extensions
# https://github.com/shivammathur/setup-php
uses: shivammathur/setup-php@v2
with:
- php-version: ${{ matrix.php-versions }}
- extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, posix, spl, xml
+ # Should be the lowest supported version
+ php-version: '8.1'
+ extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, spl, xml
tools: composer
- ini-values: error_reporting=E_ALL
coverage: none
- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
- - name: Setup problem matchers for PHPUnit
- run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
-
- - name: Set git to use LF
- run: |
- git config --global core.autocrlf false
- git config --global core.eol lf
-
- uses: actions/checkout@v4
- name: Get composer cache directory
- run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$env:GITHUB_ENV"
+ run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
- name: Cache composer dependencies
uses: actions/cache@v4
@@ -258,10 +234,16 @@ jobs:
restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies
- run: composer install --no-progress --prefer-dist --optimize-autoloader --ignore-platform-req=ext-posix
+ run: composer install --no-progress --prefer-dist --optimize-autoloader
- - name: Run unit tests
- run: vendor/bin/phpunit --no-coverage
+ - name: Security check for locked dependencies
+ run: composer audit
+
+ - name: Update Composer dependencies
+ run: composer update --no-progress --prefer-dist --optimize-autoloader
+
+ - name: Security check for updated dependencies
+ run: composer audit
coverage:
name: Code coverage
diff --git a/phpstan-dev.neon b/phpstan-dev.neon
new file mode 100644
index 0000000..4d29b8b
--- /dev/null
+++ b/phpstan-dev.neon
@@ -0,0 +1,4 @@
+parameters:
+ level: 9
+ paths:
+ - tests
diff --git a/phpstan.neon b/phpstan.neon
new file mode 100644
index 0000000..db37782
--- /dev/null
+++ b/phpstan.neon
@@ -0,0 +1,4 @@
+parameters:
+ level: 6
+ paths:
+ - src
diff --git a/psalm-dev.xml b/psalm-dev.xml
deleted file mode 100644
index 6116331..0000000
--- a/psalm-dev.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/psalm.xml b/psalm.xml
deleted file mode 100644
index 396c047..0000000
--- a/psalm.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Controller/Autotest.php b/src/Controller/Autotest.php
index ea7206e..639e52b 100644
--- a/src/Controller/Autotest.php
+++ b/src/Controller/Autotest.php
@@ -22,8 +22,7 @@
class Autotest
{
/**
- * @var \SimpleSAML\Auth\Simple|string
- * @psalm-var \SimpleSAML\Auth\Simple|class-string
+ * @var \SimpleSAML\Auth\Simple|class-string
*/
protected $authSimple = Auth\Simple::class;
@@ -149,7 +148,7 @@ private function getAuthSource(Request $request): Auth\Simple
/**
* Generate a response for success
*
- * @param array $attributes The attributes to include in the response
+ * @param array $attributes The attributes to include in the response
* @return \SimpleSAML\XHTML\Template
*
*/
diff --git a/tests/src/Controller/AutotestTest.php b/tests/src/Controller/AutotestTest.php
index 7383c0d..8eca210 100644
--- a/tests/src/Controller/AutotestTest.php
+++ b/tests/src/Controller/AutotestTest.php
@@ -70,6 +70,7 @@ public function isAuthenticated(): bool
return false;
}
+ /** @param array $params */
public function login(array $params = []): void
{
// stub
@@ -103,6 +104,7 @@ public function isAuthenticated(): bool
return false;
}
+ /** @param array $params */
public function requireAuth(array $params = []): void
{
// stub
@@ -135,6 +137,7 @@ public function isAuthenticated(): bool
return true;
}
+ /** @param array $params */
public function login(array $params = []): void
{
// stub
@@ -167,7 +170,8 @@ public function isAuthenticated(): bool
return true;
}
- public function logout($params = null): void
+ /** @param array|string|null $params */
+ public function logout(array|string|null $params = null): void
{
// stub
}
@@ -200,6 +204,7 @@ public function isAuthenticated(): bool
return true;
}
+ /** @return array */
public function getAttributes(): array
{
return ['some' => ['multi', 'valued', 'attribute'], 'something' => ['else']];
@@ -235,7 +240,11 @@ public function testMissingSourceId(string $endpoint): void
);
$c = new Controller\Autotest($this->config, $this->session);
- $response = call_user_func([$c, $endpoint], $request);
+ $callable = [$c, $endpoint];
+ $this->assertIsCallable($callable);
+
+ /** @var \SimpleSAML\XHTML\Template $response */
+ $response = call_user_func($callable, $request);
$this->assertEquals(Response::HTTP_INTERNAL_SERVER_ERROR, $response->getStatusCode());
$this->assertEquals(
@@ -246,7 +255,7 @@ public function testMissingSourceId(string $endpoint): void
/**
- * @return array
+ * @return array
*/
public static function endpoints(): array
{