Skip to content

Commit 08892e5

Browse files
authored
Versions update (#21)
* Update versions * Add override attribute * Add final attributes * Fix problems found by psalm * Update tests to use phpunit 12
1 parent e76902f commit 08892e5

File tree

9 files changed

+34
-39
lines changed

9 files changed

+34
-39
lines changed

.github/workflows/php.yml

Lines changed: 2 additions & 2 deletions
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.1', '8.2', '8.3']
17+
php-versions: ['8.3']
1818

1919
steps:
2020
- uses: actions/checkout@v2
@@ -32,7 +32,7 @@ jobs:
3232

3333
- name: Cache Composer packages
3434
id: composer-cache
35-
uses: actions/cache@v2
35+
uses: actions/cache@v3
3636
with:
3737
path: vendor
3838
key: ${{ runner.os }}-php-${{ matrix.php-versions }}-${{ hashFiles('**/composer.lock') }}

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
"keywords": ["php", "file system"],
66
"license": "MIT",
77
"require": {
8-
"php": ">=8.1"
8+
"php": ">=8.3"
99
},
1010
"require-dev": {
11-
"phpunit/phpunit": "^10.0",
11+
"phpunit/phpunit": "^12.0",
1212
"friendsofphp/php-cs-fixer": "^3.0",
13-
"vimeo/psalm": "^5.0",
14-
"infection/infection": "^0.27"
13+
"vimeo/psalm": "^6.0",
14+
"infection/infection": "^0.29"
1515
},
1616
"autoload": {
1717
"psr-4": {

docker/php/Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM php:8.2-cli-alpine
1+
FROM php:8.3-cli-alpine
22

33

44
RUN set -xe && apk update && apk add --no-cache \
@@ -12,8 +12,8 @@ RUN set -xe && apk update && apk add --no-cache \
1212
git \
1313
autoconf \
1414
g++ \
15-
linux-headers \
16-
make
15+
make \
16+
linux-headers
1717

1818

1919
RUN docker-php-ext-install zip opcache \
@@ -25,7 +25,7 @@ RUN docker-php-ext-install zip opcache \
2525
&& echo 'xdebug.mode=coverage' >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
2626

2727

28-
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer --version=2.7.8 \
28+
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer --version=2.8.8 \
2929
&& mkdir -p /.composer && chmod -Rf 777 /.composer
3030

3131

src/FileSystemHelperImpl.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public function __construct(?string $baseFolder = null)
3636
/**
3737
* {@inheritDoc}
3838
*/
39+
#[\Override]
3940
public function remove(\SplFileInfo|string $entity): void
4041
{
4142
$splEntity = $this->makeFileInfoAndCheckBasePath($entity);
@@ -65,6 +66,7 @@ public function remove(\SplFileInfo|string $entity): void
6566
/**
6667
* {@inheritDoc}
6768
*/
69+
#[\Override]
6870
public function removeIfExists(\SplFileInfo|string $entity): void
6971
{
7072
$splEntity = $this->makeFileInfoAndCheckBasePath($entity);
@@ -77,6 +79,7 @@ public function removeIfExists(\SplFileInfo|string $entity): void
7779
/**
7880
* {@inheritDoc}
7981
*/
82+
#[\Override]
8083
public function copy(\SplFileInfo|string $from, \SplFileInfo|string $to): \SplFileInfo
8184
{
8285
$source = $this->makeFileInfoAndCheckBasePath($from);
@@ -137,6 +140,7 @@ function (\SplFileInfo $file) use ($target): void {
137140
/**
138141
* {@inheritDoc}
139142
*/
143+
#[\Override]
140144
public function rename(\SplFileInfo|string $from, \SplFileInfo|string $to): \SplFileInfo
141145
{
142146
$source = $this->makeFileInfoAndCheckBasePath($from);
@@ -184,6 +188,7 @@ public function rename(\SplFileInfo|string $from, \SplFileInfo|string $to): \Spl
184188
/**
185189
* {@inheritDoc}
186190
*/
191+
#[\Override]
187192
public function mkdir(\SplFileInfo|string $path, int $mode = 0777): \SplFileInfo
188193
{
189194
$dir = $this->makeFileInfoAndCheckBasePath($path);
@@ -211,6 +216,7 @@ public function mkdir(\SplFileInfo|string $path, int $mode = 0777): \SplFileInfo
211216
/**
212217
* {@inheritDoc}
213218
*/
219+
#[\Override]
214220
public function mkdirIfNotExist(\SplFileInfo|string $path, int $mode = 0777): \SplFileInfo
215221
{
216222
$dir = $this->makeFileInfoAndCheckBasePath($path);
@@ -225,6 +231,7 @@ public function mkdirIfNotExist(\SplFileInfo|string $path, int $mode = 0777): \S
225231
/**
226232
* {@inheritDoc}
227233
*/
234+
#[\Override]
228235
public function emptyDir(\SplFileInfo|string $path): void
229236
{
230237
$dir = $this->makeFileInfoAndCheckBasePath($path);
@@ -250,6 +257,7 @@ public function emptyDir(\SplFileInfo|string $path): void
250257
/**
251258
* {@inheritDoc}
252259
*/
260+
#[\Override]
253261
public function getTmpDir(): \SplFileInfo
254262
{
255263
$dir = sys_get_temp_dir();
@@ -266,6 +274,7 @@ public function getTmpDir(): \SplFileInfo
266274
/**
267275
* {@inheritDoc}
268276
*/
277+
#[\Override]
269278
public function createDirectoryIterator(\SplFileInfo|string $dir): \Iterator
270279
{
271280
$splEntity = $this->makeFileInfoAndCheckBasePath($dir);
@@ -291,6 +300,7 @@ public function createDirectoryIterator(\SplFileInfo|string $dir): \Iterator
291300
/**
292301
* {@inheritDoc}
293302
*/
303+
#[\Override]
294304
public function iterateDirectory(\SplFileInfo|string $dir, callable $callback): void
295305
{
296306
$content = $this->createDirectoryIterator($dir);
@@ -302,6 +312,7 @@ public function iterateDirectory(\SplFileInfo|string $dir, callable $callback):
302312
/**
303313
* {@inheritDoc}
304314
*/
315+
#[\Override]
305316
public function makeFileInfo(mixed $path): \SplFileInfo
306317
{
307318
if (\is_string($path)) {

tests/BaseCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ protected function assertDirectoryHasPermissions(int $awaitedPermissions, \SplFi
161161
{
162162
$directory = self::convertPathToString($directory);
163163
$awaitedPermissions = \sprintf('%o', $awaitedPermissions);
164-
$realPermissions = substr(\sprintf('%o', fileperms($directory)), -3);
164+
$realPermissions = substr(\sprintf('%o', (string) fileperms($directory)), -3);
165165
$this->assertSame($awaitedPermissions, $realPermissions, 'Directory has correct permissions');
166166
}
167167
}

tests/Exception/FileSystemExceptionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
/**
1111
* @internal
1212
*/
13-
class FileSystemExceptionTest extends BaseCase
13+
final class FileSystemExceptionTest extends BaseCase
1414
{
1515
public function testCreate(): void
1616
{

tests/FileSystemFactoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
/**
1111
* @internal
1212
*/
13-
class FileSystemFactoryTest extends BaseCase
13+
final class FileSystemFactoryTest extends BaseCase
1414
{
1515
/**
1616
* @throws \Throwable

tests/FileSystemHelperImplTest.php

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
/**
1111
* @internal
1212
*/
13-
class FileSystemHelperImplTest extends BaseCase
13+
final class FileSystemHelperImplTest extends BaseCase
1414
{
1515
public function testEmptyBasePathUnexistedInConstructException(): void
1616
{
@@ -21,9 +21,7 @@ public function testEmptyBasePathUnexistedInConstructException(): void
2121
new FileSystemHelperImpl($path);
2222
}
2323

24-
/**
25-
* @dataProvider provideRemove
26-
*/
24+
#[\PHPUnit\Framework\Attributes\DataProvider('provideRemove')]
2725
public function testRemove(string|\SplFileInfo $file, ?string $baseDir = null, ?\Exception $exception = null): void
2826
{
2927
$helper = new FileSystemHelperImpl($baseDir);
@@ -101,9 +99,7 @@ public static function provideRemove(): array
10199
];
102100
}
103101

104-
/**
105-
* @dataProvider provideRemoveIfExists
106-
*/
102+
#[\PHPUnit\Framework\Attributes\DataProvider('provideRemoveIfExists')]
107103
public function testRemoveIfExists(string|\SplFileInfo $file, ?string $baseDir = null, ?\Exception $exception = null): void
108104
{
109105
$helper = new FileSystemHelperImpl($baseDir);
@@ -179,9 +175,7 @@ public static function provideRemoveIfExists(): array
179175
];
180176
}
181177

182-
/**
183-
* @dataProvider provideCopyFile
184-
*/
178+
#[\PHPUnit\Framework\Attributes\DataProvider('provideCopyFile')]
185179
public function testCopyFile(string|\SplFileInfo $from, string|\SplFileInfo $to, ?\Exception $exception = null, ?string $baseDir = null): void
186180
{
187181
$helper = new FileSystemHelperImpl($baseDir);
@@ -302,9 +296,7 @@ public function testCopyDir(): void
302296
$this->assertFileEquals($nestedFileSecondLevel, $destinationNestedFileSecondLevel);
303297
}
304298

305-
/**
306-
* @dataProvider provideRenameFile
307-
*/
299+
#[\PHPUnit\Framework\Attributes\DataProvider('provideRenameFile')]
308300
public function testRenameFile(string|\SplFileInfo $from, string|\SplFileInfo $to, ?\Exception $exception = null, ?string $baseDir = null): void
309301
{
310302
$helper = new FileSystemHelperImpl($baseDir);
@@ -426,9 +418,7 @@ public function testRenameDir(): void
426418
$this->assertFileDoesnotExist($nestedFileSecondLevel);
427419
}
428420

429-
/**
430-
* @dataProvider provideMkdir
431-
*/
421+
#[\PHPUnit\Framework\Attributes\DataProvider('provideMkdir')]
432422
public function testMkdir(\SplFileInfo|string $name, ?int $permissions = null, ?\Exception $exception = null, ?string $baseDir = null): void
433423
{
434424
$helper = new FileSystemHelperImpl($baseDir);
@@ -492,9 +482,7 @@ public static function provideMkdir(): array
492482
];
493483
}
494484

495-
/**
496-
* @dataProvider provideMkdirIfNotExist
497-
*/
485+
#[\PHPUnit\Framework\Attributes\DataProvider('provideMkdirIfNotExist')]
498486
public function testMkdirIfNotExist(\SplFileInfo|string $name, ?int $permissions = null, ?\Exception $exception = null, ?string $baseDir = null): void
499487
{
500488
$helper = new FileSystemHelperImpl($baseDir);

tests/Helper/PathHelperTest.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@
1010
/**
1111
* @internal
1212
*/
13-
class PathHelperTest extends BaseCase
13+
final class PathHelperTest extends BaseCase
1414
{
15-
/**
16-
* @dataProvider provideIsPathParentForPath
17-
*/
15+
#[\PHPUnit\Framework\Attributes\DataProvider('provideIsPathParentForPath')]
1816
public function testIsPathParentForPath(string $parentPath, string $path, bool $awaits): void
1917
{
2018
$testResult = PathHelper::isPathParentForPath($parentPath, $path);
@@ -71,9 +69,7 @@ public function testRealpathUnexisted(): void
7169
$this->assertNull($testResult);
7270
}
7371

74-
/**
75-
* @dataProvider provideUnifyPath
76-
*/
72+
#[\PHPUnit\Framework\Attributes\DataProvider('provideUnifyPath')]
7773
public function testUnifyPath(string $path, string $awaits): void
7874
{
7975
$testResult = PathHelper::unifyPath($path);

0 commit comments

Comments
 (0)