Skip to content

Commit bd97031

Browse files
committed
Issue #47: Remove PHP 8.1 and add PHP 8.4 & 8.5 support
Signed-off-by: alexmerlin <[email protected]>
1 parent 234e3eb commit bd97031

File tree

7 files changed

+80
-55
lines changed

7 files changed

+80
-55
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
on:
2+
- push
3+
4+
name: Run PHPStan checks
5+
6+
jobs:
7+
mutation:
8+
name: PHPStan ${{ matrix.php }}-${{ matrix.os }}
9+
10+
runs-on: ${{ matrix.os }}
11+
12+
strategy:
13+
matrix:
14+
os:
15+
- ubuntu-latest
16+
17+
php:
18+
- "8.2"
19+
- "8.3"
20+
- "8.4"
21+
- "8.5"
22+
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
27+
- name: Install PHP
28+
uses: shivammathur/setup-php@v2
29+
with:
30+
php-version: "${{ matrix.php }}"
31+
coverage: pcov
32+
ini-values: assert.exception=1, zend.assertions=1, error_reporting=-1, log_errors_max_len=0, display_errors=On
33+
tools: composer:v2, cs2pr
34+
35+
- name: Determine composer cache directory
36+
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
37+
38+
- name: Cache dependencies installed with composer
39+
uses: actions/cache@v4
40+
with:
41+
path: ${{ env.COMPOSER_CACHE_DIR }}
42+
key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
43+
restore-keys: |
44+
php${{ matrix.php }}-composer-
45+
46+
- name: Install dependencies with composer
47+
run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
48+
49+
- name: Run static analysis with PHPStan
50+
run: vendor/bin/phpstan analyse

composer.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@
3535
"require-dev": {
3636
"laminas/laminas-coding-standard": "^3.0",
3737
"mikey179/vfsstream": "^1.6.7",
38-
"phpunit/phpunit": "^10.2",
39-
"vimeo/psalm": "^6.0"
38+
"phpstan/phpstan": "^2.1.17",
39+
"phpstan/phpstan-phpunit": "^2.0.6",
40+
"phpunit/phpunit": "^10.2"
4041
},
4142
"autoload-dev": {
4243
"psr-4": {
@@ -51,8 +52,8 @@
5152
],
5253
"cs-check": "phpcs",
5354
"cs-fix": "phpcbf",
55+
"static-analysis": "phpstan analyse --memory-limit 1G",
5456
"test": "phpunit --colors=always",
55-
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml",
56-
"static-analysis": "psalm --shepherd --stats"
57+
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml"
5758
}
5859
}

phpstan.neon

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
includes:
2+
- vendor/phpstan/phpstan-phpunit/extension.neon
3+
parameters:
4+
level: 5
5+
paths:
6+
- src
7+
- test
8+
treatPhpDocTypesAsCertain: false

psalm-baseline.xml

Lines changed: 0 additions & 13 deletions
This file was deleted.

psalm.xml

Lines changed: 0 additions & 21 deletions
This file was deleted.

test/Command/DemoCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class DemoCommandTest extends TestCase
2020
public function testWillCreateCommand(): void
2121
{
2222
$command = new DemoCommand();
23-
$this->assertInstanceOf(DemoCommand::class, $command);
23+
$this->assertContainsOnlyInstancesOf(DemoCommand::class, [$command]);
2424
}
2525

2626
/**

test/FileLockerTest.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,28 @@ public function testAccessors(): void
3232
$fileLocker = new FileLocker();
3333
$this->assertFalse($fileLocker->isEnabled());
3434
$fileLocker->enable();
35-
$this->assertInstanceOf(FileLocker::class, $fileLocker);
35+
$this->assertContainsOnlyInstancesOf(FileLocker::class, [$fileLocker]);
3636
$this->assertTrue($fileLocker->isEnabled());
3737
$fileLocker->disable();
38-
$this->assertInstanceOf(FileLocker::class, $fileLocker);
38+
$this->assertContainsOnlyInstancesOf(FileLocker::class, [$fileLocker]);
3939
$this->assertFalse($fileLocker->isEnabled());
4040
$fileLocker->setEnabled(true);
41-
$this->assertInstanceOf(FileLocker::class, $fileLocker);
41+
$this->assertContainsOnlyInstancesOf(FileLocker::class, [$fileLocker]);
4242
$this->assertTrue($fileLocker->isEnabled());
4343
$fileLocker->setEnabled(false);
44-
$this->assertInstanceOf(FileLocker::class, $fileLocker);
44+
$this->assertContainsOnlyInstancesOf(FileLocker::class, [$fileLocker]);
4545
$this->assertFalse($fileLocker->isEnabled());
4646
$this->assertNull($fileLocker->getDirPath());
4747
$fileLocker->setDirPath('test');
48-
$this->assertInstanceOf(FileLocker::class, $fileLocker);
48+
$this->assertContainsOnlyInstancesOf(FileLocker::class, [$fileLocker]);
4949
$this->assertSame('test', $fileLocker->getDirPath());
5050
$this->assertNull($fileLocker->getCommandName());
5151
$fileLocker->setCommandName('test');
52-
$this->assertInstanceOf(FileLocker::class, $fileLocker);
52+
$this->assertContainsOnlyInstancesOf(FileLocker::class, [$fileLocker]);
5353
$this->assertSame('test', $fileLocker->getCommandName());
5454
$this->assertNull($fileLocker->getLockFile());
5555
$fileLocker->setLockFile('test');
56-
$this->assertInstanceOf(FileLocker::class, $fileLocker);
56+
$this->assertContainsOnlyInstancesOf(FileLocker::class, [$fileLocker]);
5757
$this->assertSame('test', $fileLocker->getLockFile());
5858
$this->assertSame('test/command-test.lock', $fileLocker->getLockFilePath());
5959
}
@@ -65,7 +65,7 @@ public function testWillInitLockFile(): void
6565
$fileLocker = new FileLocker(true, $config['dirPath'], 'test');
6666
$this->assertNull($fileLocker->getLockFile());
6767
$fileLocker->initLockFile();
68-
$this->assertInstanceOf(FileLocker::class, $fileLocker);
68+
$this->assertContainsOnlyInstancesOf(FileLocker::class, [$fileLocker]);
6969
$this->assertIsResource($fileLocker->getLockFile());
7070
}
7171

@@ -79,7 +79,7 @@ public function testWillNotLockWhenDisabled(): void
7979
$fileLocker = new FileLocker(false, $config['dirPath'], 'test');
8080
$this->assertNull($fileLocker->getLockFile());
8181
$fileLocker->lock();
82-
$this->assertInstanceOf(FileLocker::class, $fileLocker);
82+
$this->assertContainsOnlyInstancesOf(FileLocker::class, [$fileLocker]);
8383
$this->assertNull($fileLocker->getLockFile());
8484
}
8585

@@ -93,7 +93,7 @@ public function testWillNotLockWithoutValidCommandName(): void
9393
$fileLocker = new FileLocker(true, $config['dirPath']);
9494
$this->assertNull($fileLocker->getLockFile());
9595
$fileLocker->lock();
96-
$this->assertInstanceOf(FileLocker::class, $fileLocker);
96+
$this->assertContainsOnlyInstancesOf(FileLocker::class, [$fileLocker]);
9797
$this->assertNull($fileLocker->getLockFile());
9898
}
9999

@@ -107,7 +107,7 @@ public function testWillLockWhenLockedAndEnabledAndHasValidCommandName(): void
107107
$fileLocker = new FileLocker(true, $config['dirPath'], 'test');
108108
$this->assertNull($fileLocker->getLockFile());
109109
$fileLocker->lock();
110-
$this->assertInstanceOf(FileLocker::class, $fileLocker);
110+
$this->assertContainsOnlyInstancesOf(FileLocker::class, [$fileLocker]);
111111
$this->assertIsResource($fileLocker->getLockFile());
112112
$this->assertFileExists($fileLocker->getLockFilePath());
113113
}
@@ -119,7 +119,7 @@ public function testWillNotUnlockWhenDisabled(): void
119119
$fileLocker = new FileLocker(false, $config['dirPath'], 'test');
120120
$this->assertNull($fileLocker->getLockFile());
121121
$fileLocker->unlock();
122-
$this->assertInstanceOf(FileLocker::class, $fileLocker);
122+
$this->assertContainsOnlyInstancesOf(FileLocker::class, [$fileLocker]);
123123
$this->assertNull($fileLocker->getLockFile());
124124
}
125125

@@ -130,7 +130,7 @@ public function testWillNotUnlockWithoutValidCommandName(): void
130130
$fileLocker = new FileLocker(false, $config['dirPath']);
131131
$this->assertNull($fileLocker->getLockFile());
132132
$fileLocker->unlock();
133-
$this->assertInstanceOf(FileLocker::class, $fileLocker);
133+
$this->assertContainsOnlyInstancesOf(FileLocker::class, [$fileLocker]);
134134
$this->assertNull($fileLocker->getLockFile());
135135
}
136136

@@ -141,7 +141,7 @@ public function testWillNotUnlockWhenEnabledAndWithoutValidCommandName(): void
141141
$fileLocker = new FileLocker(true, $config['dirPath']);
142142
$this->assertNull($fileLocker->getLockFile());
143143
$fileLocker->unlock();
144-
$this->assertInstanceOf(FileLocker::class, $fileLocker);
144+
$this->assertContainsOnlyInstancesOf(FileLocker::class, [$fileLocker]);
145145
$this->assertNull($fileLocker->getLockFile());
146146
}
147147

@@ -154,11 +154,11 @@ public function testWillUnlockWhenLockedAndEnabledAndHasValidCommandName(): void
154154

155155
$fileLocker = new FileLocker(true, $config['dirPath'], 'test');
156156
$fileLocker->lock();
157-
$this->assertInstanceOf(FileLocker::class, $fileLocker);
157+
$this->assertContainsOnlyInstancesOf(FileLocker::class, [$fileLocker]);
158158
$this->assertIsResource($fileLocker->getLockFile());
159159
$this->assertFileExists($fileLocker->getLockFilePath());
160160
$fileLocker->unlock();
161-
$this->assertInstanceOf(FileLocker::class, $fileLocker);
161+
$this->assertContainsOnlyInstancesOf(FileLocker::class, [$fileLocker]);
162162
$this->assertFileIsReadable($fileLocker->getLockFilePath());
163163
$this->assertFileIsWritable($fileLocker->getLockFilePath());
164164
}

0 commit comments

Comments
 (0)