Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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 \
Expand All @@ -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: |
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "*"
Expand All @@ -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"
Expand Down
4 changes: 1 addition & 3 deletions src/Path/DiffPathLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/Report/FileReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,9 @@ private function getFixedSeverityCount(Severity $severity): int
/** @param list<Violation> $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(...);
));
}
}
8 changes: 4 additions & 4 deletions src/Report/Report.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions src/Sniff/SimparaSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<array{beginOffset: int, closingOffset: int|null}> */
Expand Down