Skip to content

Commit 6775323

Browse files
authored
PHP 8.1 (#10)
* Fix code style * Add fixes for PHP 8.1
1 parent c6ec285 commit 6775323

File tree

6 files changed

+24
-15
lines changed

6 files changed

+24
-15
lines changed

.github/workflows/php.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
strategy:
1515
fail-fast: true
1616
matrix:
17-
php-versions: ['8.0']
17+
php-versions: ['8.0', '8.1']
1818

1919
steps:
2020
- uses: actions/checkout@v2

composer.json

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
},
1010
"require-dev": {
1111
"phpunit/phpunit": "^9.0",
12-
"friendsofphp/php-cs-fixer": "^2.0|^3.0",
13-
"sebastian/phpcpd": "^5.0|^6.0",
12+
"friendsofphp/php-cs-fixer": "^3.0",
13+
"sebastian/phpcpd": "^6.0",
1414
"vimeo/psalm": "^4.0",
15-
"psalm/plugin-phpunit": "^0.15.1"
15+
"psalm/plugin-phpunit": "^0.16"
1616
},
1717
"autoload": {
1818
"psr-4": {
@@ -25,13 +25,19 @@
2525
}
2626
},
2727
"scripts": {
28-
"test": "vendor/bin/phpunit --configuration phpunit.xml.dist",
29-
"coverage": "vendor/bin/phpunit --configuration phpunit.xml.dist --coverage-html=tests/coverage",
30-
"fixer": "vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -vv --allow-risky=yes",
28+
"test": [
29+
"vendor/bin/phpunit --configuration phpunit.xml.dist"
30+
],
31+
"coverage": [
32+
"vendor/bin/phpunit --configuration phpunit.xml.dist --coverage-html=tests/coverage"
33+
],
34+
"fixer": [
35+
"vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -vv --allow-risky=yes"
36+
],
3137
"linter": [
3238
"vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -vv --allow-risky=yes --dry-run --stop-on-violation",
3339
"vendor/bin/phpcpd ./ --exclude vendor --exclude tests",
34-
"vendor/bin/psalm --show-info=true"
40+
"vendor/bin/psalm --show-info=true --php-version=$(php -r \"echo phpversion();\")"
3541
]
3642
},
3743
"repositories": [

docker/php/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ RUN docker-php-ext-install zip soap \
2424
&& echo 'xdebug.mode=coverage' >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
2525

2626

27+
<<<<<<< HEAD
28+
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer --version=2.2.7 \
29+
=======
2730
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer --version=2.1.8 \
31+
>>>>>>> origin/master
2832
&& mkdir -p /.composer && chmod -Rf 777 /.composer
2933

3034

psalm.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
<?xml version="1.0"?>
22
<psalm
3-
totallyTyped="true"
43
cacheDirectory="/tmp"
54
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
65
xmlns="https://getpsalm.org/schema/config"
76
xsi:schemaLocation="https://getpsalm.org/schema/config file:///var/www/vendor/vimeo/psalm/config.xsd"
87
>
98
<projectFiles>
109
<directory name="./src" />
10+
<directory name="./tests" />
1111
<ignoreFiles>
1212
</ignoreFiles>
1313
</projectFiles>
1414

1515
<issueHandlers>
16+
<PropertyNotSetInConstructor errorLevel="suppress"/>
1617
</issueHandlers>
1718

1819
<plugins>

src/FileSystemHelperBase.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ public function remove(SplFileInfo|string $entity): void
5050
} elseif ($splEntity->isDir()) {
5151
$this->iterateDirectory(
5252
$splEntity,
53-
function (SplFileInfo $file): void {
54-
$this->remove($file);
55-
}
53+
fn (SplFileInfo $file): mixed => $this->remove($file)
5654
);
5755
$this->runPhpFunction(
5856
'rmdir',
@@ -239,9 +237,7 @@ public function emptyDir(SplFileInfo|string $path): void
239237

240238
$this->iterateDirectory(
241239
$dir,
242-
function (SplFileInfo $entity): void {
243-
$this->remove($entity);
244-
}
240+
fn (SplFileInfo $file): mixed => $this->remove($file)
245241
);
246242
}
247243

tests/BaseCase.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use RecursiveDirectoryIterator;
99
use RecursiveIteratorIterator;
1010
use RuntimeException;
11+
use SplFileInfo;
1112

1213
/**
1314
* Basic class for all tests in suite.
@@ -115,6 +116,7 @@ protected function removeDir(string $folderPath): void
115116
$folderPath,
116117
RecursiveDirectoryIterator::SKIP_DOTS
117118
);
119+
/** @var iterable<SplFileInfo> */
118120
$files = new RecursiveIteratorIterator(
119121
$it,
120122
RecursiveIteratorIterator::CHILD_FIRST

0 commit comments

Comments
 (0)