From 78600a97b1c5903dc6a4566a99499ea5b286e33e Mon Sep 17 00:00:00 2001 From: Jordi Kroon Date: Thu, 6 Aug 2026 21:24:58 +0200 Subject: [PATCH 1/2] Add PHP 8.4 support --- .github/workflows/ci.yml | 19 +++++++++++++------ README.md | 2 +- composer.json | 4 ++-- src/Path/DiffPathLoader.php | 4 +--- src/Report/FileReport.php | 4 ++-- src/Report/Report.php | 8 ++++---- src/Sniff/SimparaSniff.php | 4 +--- 7 files changed, 24 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 967c6b1..71ffe91 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,16 +59,23 @@ jobs: run: "vendor/bin/phpstan analyse --no-progress --error-format=github" tests: - name: "Tests" + name: "Tests (PHP ${{ matrix.php-version }})" runs-on: "ubuntu-latest" + strategy: + fail-fast: false + matrix: + php-version: + - "8.4" + - "8.5" + steps: - uses: "actions/checkout@v7" - name: "Setup PHP" uses: "shivammathur/setup-php@v2" with: - php-version: "8.5" + php-version: "${{ matrix.php-version }}" tools: "composer" coverage: "xdebug" @@ -81,7 +88,7 @@ jobs: run: "vendor/bin/phpunit --configuration phpunit.xml.dist --colors=always" - name: "Generate coverage summary" - if: ${{ ! cancelled() }} + if: ${{ ! cancelled() && matrix.php-version == '8.5' }} run: | echo '```' > var/.phpunit.cache/coverage.txt vendor/bin/phpunit \ @@ -92,18 +99,18 @@ jobs: - name: "Report test results" uses: "mikepenz/action-junit-report@v6" - if: ${{ ! cancelled() }} + if: ${{ ! cancelled() && matrix.php-version == '8.5' }} with: report_paths: "var/.phpunit.cache/junit.xml" annotate_only: true - name: "Post coverage summary" - if: ${{ ! cancelled() }} + if: ${{ ! cancelled() && matrix.php-version == '8.5' }} run: 'cat var/.phpunit.cache/coverage.txt >> "$GITHUB_STEP_SUMMARY"' - name: "Upload coverage report" uses: "actions/upload-artifact@v7" - if: ${{ ! cancelled() }} + if: ${{ ! cancelled() && matrix.php-version == '8.5' }} with: name: "coverage-report" path: | diff --git a/README.md b/README.md index 179d77d..75053e2 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ A static-analysis linter for DocBook XML files. It scans XML documentation sourc ### Requirements -- PHP 8.5+ +- PHP 8.4+ - Extensions: `dom`, `libxml`, `simplexml` ### Setup diff --git a/composer.json b/composer.json index db89730..e7d8725 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "license": "Apache-2.0", "bin": ["bin/docbook-cs"], "require": { - "php": "^8.5", + "php": "^8.4", "ext-dom": "*", "ext-libxml": "*", "ext-simplexml": "*" @@ -14,7 +14,7 @@ "phpunit/phpunit": "^13.2.4", "phpstan/phpstan": "^2.2.5", "phpunit/php-code-coverage": "^14.2.3", - "squizlabs/php_codesniffer": "^4.0.1", + "squizlabs/php_codesniffer": "^4.0.2", "phpstan/phpstan-strict-rules": "^2.0.12", "phpstan/phpstan-phpunit": "^2.0.18", "shipmonk/dead-code-detector": "^1.3.2" diff --git a/src/Path/DiffPathLoader.php b/src/Path/DiffPathLoader.php index a536b34..406ddc7 100644 --- a/src/Path/DiffPathLoader.php +++ b/src/Path/DiffPathLoader.php @@ -68,9 +68,7 @@ private function candidates(string $path): array } } - return array_map($this->normalize(...), $candidates) - |> array_unique(...) - |> array_values(...); + return array_values(array_unique(array_map($this->normalize(...), $candidates))); } private function isAbsolute(string $path): bool diff --git a/src/Report/FileReport.php b/src/Report/FileReport.php index 02ec303..635266e 100644 --- a/src/Report/FileReport.php +++ b/src/Report/FileReport.php @@ -243,9 +243,9 @@ private function getFixedSeverityCount(Severity $severity): int /** @param list $violations */ private function countViolationSeverity(array $violations, Severity $severity): int { - return array_filter( + return count(array_filter( $violations, static fn(Violation $violation): bool => $violation->severity === $severity, - ) |> count(...); + )); } } diff --git a/src/Report/Report.php b/src/Report/Report.php index e993874..4f50d99 100644 --- a/src/Report/Report.php +++ b/src/Report/Report.php @@ -50,18 +50,18 @@ public function getScannedFilesCount(): int public function getViolatingFilesCount(): int { - return array_filter( + return count(array_filter( $this->fileReports, static fn(FileReport $fileReport): bool => $fileReport->hasFinalViolations(), - ) |> count(...); + )); } public function getChangedFilesCount(): int { - return array_filter( + return count(array_filter( $this->fileReports, static fn(FileReport $fileReport): bool => $fileReport->changed, - ) |> count(...); + )); } public function getFoundViolationsCount(): int diff --git a/src/Sniff/SimparaSniff.php b/src/Sniff/SimparaSniff.php index 54e83ca..4c931af 100644 --- a/src/Sniff/SimparaSniff.php +++ b/src/Sniff/SimparaSniff.php @@ -231,9 +231,7 @@ private function getAllowedElements(): array $additional = array_map('trim', explode(',', $extra)); $additional = array_filter($additional, static fn(string $s): bool => $s !== ''); - return array_merge(self::SIMPARA_ALLOWED, $additional) - |> array_unique(...) - |> array_values(...); + return array_values(array_unique(array_merge(self::SIMPARA_ALLOWED, $additional))); } /** @return list */ From 4597b55faf09ad9b914369f9e30de9abc0c7125a Mon Sep 17 00:00:00 2001 From: Jordi Kroon Date: Fri, 7 Aug 2026 09:55:16 +0200 Subject: [PATCH 2/2] Bump CI/CD