Skip to content

Commit 1396810

Browse files
authored
Merge pull request #28 from yamadashy/feat/php8.5
feat: Add PHP 8.5 support and require PHP 8.1+
2 parents f478208 + 95ccc00 commit 1396810

File tree

8 files changed

+75
-34
lines changed

8 files changed

+75
-34
lines changed

.devcontainer/Dockerfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
2525
lsb-release \
2626
&& apt-get clean && rm -rf /var/lib/apt/lists/*
2727

28-
# Install PHP 8.4 from Sury repository
28+
# Install PHP 8.5 from Sury repository
2929
RUN curl -sSL https://packages.sury.org/php/README.txt | bash -x && \
3030
apt-get update && apt-get install -y --no-install-recommends \
31-
php8.4-cli \
32-
php8.4-mbstring \
33-
php8.4-xml \
34-
php8.4-curl \
35-
php8.4-zip \
31+
php8.5-cli \
32+
php8.5-mbstring \
33+
php8.5-xml \
34+
php8.5-curl \
35+
php8.5-zip \
3636
&& apt-get clean && rm -rf /var/lib/apt/lists/*
3737

3838
# Install Composer

.github/workflows/tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ubuntu-latest
1414
strategy:
1515
matrix:
16-
php-version: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
16+
php-version: ['8.1', '8.2', '8.3', '8.4', '8.5']
1717
steps:
1818
- uses: actions/checkout@v6
1919
- name: Setup PHP
@@ -31,7 +31,7 @@ jobs:
3131
- name: Setup PHP
3232
uses: shivammathur/setup-php@v2
3333
with:
34-
php-version: '8.3'
34+
php-version-file: '.tool-versions'
3535
- name: Install dependencies
3636
run: composer update --no-interaction --no-progress --ansi
3737
- name: Run coding standards check
@@ -45,7 +45,7 @@ jobs:
4545
- name: Setup PHP
4646
uses: shivammathur/setup-php@v2
4747
with:
48-
php-version: '8.4'
48+
php-version-file: '.tool-versions'
4949
- name: Install dependencies
5050
run: composer update --no-interaction --no-progress --ansi
5151
- name: Run static analysis
@@ -67,7 +67,7 @@ jobs:
6767
runs-on: ubuntu-latest
6868
strategy:
6969
matrix:
70-
php-version: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
70+
php-version: ['8.1', '8.2', '8.3', '8.4', '8.5']
7171
dependency-version: [prefer-lowest, prefer-stable]
7272
steps:
7373
- uses: actions/checkout@v6

.tool-versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
php 8.4.1
1+
php 8.5.0

CLAUDE.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
PHPStan Friendly Formatter is a PHPStan extension that provides enhanced error output with syntax-highlighted code context around errors. It transforms standard PHPStan output into a visually clear format showing actual problematic code with line numbers.
8+
9+
## Commands
10+
11+
```bash
12+
composer test # Run PHPUnit tests
13+
composer cs-fix-dry # Check code style (dry run)
14+
composer cs-fix # Fix code style issues
15+
composer analyze # Run PHPStan with friendly formatter
16+
composer tests # Run all: cs-fix-dry → analyze → test
17+
```
18+
19+
## Architecture
20+
21+
```
22+
src/
23+
├── FriendlyErrorFormatter.php # Main entry point, implements PHPStan ErrorFormatter
24+
├── CodeHighlight/
25+
│ ├── CodeHighlighter.php # Syntax highlighting with version fallback
26+
│ └── FallbackHighlighter.php # Non-highlighted fallback
27+
├── Config/
28+
│ └── FriendlyFormatterConfig.php # Formatter configuration (lineBefore, lineAfter, editorUrl)
29+
└── ErrorFormat/
30+
├── ErrorWriter.php # Formats individual errors with code context
31+
└── SummaryWriter.php # Error identifier summary statistics
32+
```
33+
34+
**Data Flow:** PHPStan AnalysisResult → FriendlyErrorFormatter → ErrorWriter (with CodeHighlighter) → SummaryWriter → Console output
35+
36+
## Key Configuration Files
37+
38+
- `phpstan.neon.dist` - PHPStan config (level 10, paths, formatter settings)
39+
- `extension.neon` - PHPStan extension registration and parameter schema
40+
- `.php-cs-fixer.dist.php` - Code style rules
41+
- `phpunit.xml` - PHPUnit 10/11 compatible config
42+
- `.tool-versions` - PHP version for local dev and CI (used by `php-version-file` in GitHub Actions)
43+
44+
## Compatibility
45+
46+
- PHP: ^8.1 (tested on 8.1, 8.2, 8.3, 8.4, 8.5)
47+
- PHPStan: ^1.0 || ^2.0
48+
- PHPUnit: ^10.0 || ^11.0 (tests use PHP 8 attributes)
49+
- php-console-highlighter: ^0.3 || ^0.4 || ^0.5 || ^1.0 (with graceful fallback)
50+
51+
The codebase handles multiple dependency versions through class existence checks and fallback implementations.

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
}
1212
],
1313
"require": {
14-
"php": "^7.4 || ^8.0",
14+
"php": "^8.1",
1515
"php-parallel-lint/php-console-highlighter": "^0.3 || ^0.4 || ^0.5 || ^1.0",
16-
"phpstan/phpstan": "^0.12 || ^1.0 || ^2.0"
16+
"phpstan/phpstan": "^1.0 || ^2.0"
1717
},
1818
"require-dev": {
1919
"friendsofphp/php-cs-fixer": "^3.4.0",
2020
"phpstan/phpstan-phpunit": "^2.0",
21-
"phpunit/phpunit": "^8.5.26 || ^10.0.0"
21+
"phpunit/phpunit": "^10.0 || ^11.0"
2222
},
2323
"minimum-stability": "dev",
2424
"prefer-stable": true,

phpunit.xml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,17 @@
44
bootstrap="vendor/autoload.php"
55
cacheDirectory=".phpunit.cache"
66
executionOrder="depends,defects"
7-
requireCoverageMetadata="true"
8-
beStrictAboutCoverageMetadata="true"
97
beStrictAboutOutputDuringTests="true"
10-
displayDetailsOnPhpunitDeprecations="true"
11-
failOnPhpunitDeprecation="true"
128
failOnRisky="true"
139
failOnWarning="true">
1410
<testsuites>
1511
<testsuite name="default">
1612
<directory>tests</directory>
1713
</testsuite>
1814
</testsuites>
19-
20-
<source restrictDeprecations="true" restrictNotices="true" restrictWarnings="true">
15+
<coverage>
2116
<include>
2217
<directory>src</directory>
2318
</include>
24-
</source>
19+
</coverage>
2520
</phpunit>

tests/CodeHighlight/CodeHighlighterTest.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,19 @@
22

33
namespace Tests\CodeHighlight;
44

5+
use PHPUnit\Framework\Attributes\CoversClass;
6+
use PHPUnit\Framework\Attributes\DataProvider;
57
use PHPUnit\Framework\TestCase;
68
use Tests\TestUtils\StringUtil;
79
use Yamadashy\PhpStanFriendlyFormatter\CodeHighlight\CodeHighlighter;
810

911
/**
1012
* @internal
11-
*
12-
* @coversDefaultClass \Yamadashy\PhpStanFriendlyFormatter\CodeHighlight\CodeHighlighter
1313
*/
14+
#[CoversClass(CodeHighlighter::class)]
1415
final class CodeHighlighterTest extends TestCase
1516
{
16-
/**
17-
* @dataProvider provideHighlightCases
18-
*
19-
* @covers ::highlight
20-
*/
17+
#[DataProvider('provideHighlightCases')]
2118
public function testHighlight(
2219
string $filePath,
2320
int $lineNumber,

tests/FriendlyErrorFormatterTest.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,21 @@
88
use PHPStan\File\NullRelativePathHelper;
99
use PHPStan\ShouldNotHappenException;
1010
use PHPStan\Testing\ErrorFormatterTestCase;
11+
use PHPUnit\Framework\Attributes\CoversClass;
12+
use PHPUnit\Framework\Attributes\DataProvider;
1113
use Tests\TestUtils\StringUtil;
1214
use Yamadashy\PhpStanFriendlyFormatter\FriendlyErrorFormatter;
1315

1416
/**
1517
* @internal
16-
*
17-
* @coversDefaultClass \Yamadashy\PhpStanFriendlyFormatter\FriendlyErrorFormatter
1818
*/
19+
#[CoversClass(FriendlyErrorFormatter::class)]
1920
final class FriendlyErrorFormatterTest extends ErrorFormatterTestCase
2021
{
2122
/**
22-
* @dataProvider provideFormatErrorsCases
23-
*
2423
* @param list<string> $expectedOutputSubstrings
25-
*
26-
* @covers ::formatErrors
2724
*/
25+
#[DataProvider('provideFormatErrorsCases')]
2826
public function testFormatErrors(
2927
int $expectedExitCode,
3028
int $numFileErrors,

0 commit comments

Comments
 (0)