Skip to content

Commit b61511d

Browse files
author
Aleksandr Denisyuk
authored
Release 3.0.x
2 parents 0c6c3e4 + e390abd commit b61511d

File tree

7 files changed

+36
-30
lines changed

7 files changed

+36
-30
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,68 +20,55 @@ jobs:
2020
parallel-lint:
2121
name: 'ParallelLint'
2222
runs-on: 'ubuntu-latest'
23-
2423
steps:
2524
- name: Checkout repository
2625
uses: actions/checkout@v3
27-
2826
- name: Setup PHP
2927
uses: shivammathur/setup-php@v2
3028
with:
31-
php-version: '8.1'
29+
php-version: '8.2'
3230
coverage: none
33-
3431
- name: Install dependencies
3532
uses: ramsey/composer-install@v2
36-
3733
- name: Run ParallelLint
3834
run: composer parallel-lint -- --no-progress --ignore-fails
3935

4036
psalm:
4137
name: 'Psalm'
4238
runs-on: 'ubuntu-latest'
43-
4439
steps:
4540
- name: Checkout repository
4641
uses: actions/checkout@v3
47-
4842
- name: Setup PHP
4943
uses: shivammathur/setup-php@v2
5044
with:
51-
php-version: '8.1'
45+
php-version: '8.2'
5246
coverage: none
53-
5447
- name: Install dependencies
5548
uses: ramsey/composer-install@v2
56-
5749
- name: Run Psalm
58-
run: composer psalm -- --no-progress --no-cache --output-format=github
50+
run: composer psalm -- --show-info=false --no-progress --no-suggestions --no-cache
5951

6052
php-cs-fixer:
6153
name: 'PHPCsFixer'
6254
runs-on: 'ubuntu-latest'
63-
6455
steps:
6556
- name: Checkout repository
6657
uses: actions/checkout@v3
67-
6858
- name: Setup PHP
6959
uses: shivammathur/setup-php@v2
7060
with:
71-
php-version: '8.1'
61+
php-version: '8.2'
7262
coverage: none
73-
7463
- name: Install dependencies
7564
uses: ramsey/composer-install@v2
76-
7765
- name: Run PHPCsFixer
7866
run: composer php-cs-fixer:diff -- --no-interaction --using-cache=no
7967

8068
phpunit:
8169
name: 'PHPUnit'
8270
needs: ['parallel-lint', 'psalm', 'php-cs-fixer']
8371
runs-on: ${{ matrix.operating-system }}
84-
8572
strategy:
8673
fail-fast: false
8774
matrix:
@@ -91,24 +78,21 @@ jobs:
9178
php-version:
9279
- '8.0'
9380
- '8.1'
81+
- '8.2'
9482
composer-dependency:
9583
- 'lowest'
9684
- 'highest'
97-
9885
steps:
9986
- name: Checkout repository
10087
uses: actions/checkout@v3
101-
10288
- name: Setup PHP
10389
uses: shivammathur/setup-php@v2
10490
with:
10591
php-version: ${{ matrix.php-version }}
10692
coverage: none
107-
10893
- name: Install dependencies
10994
uses: ramsey/composer-install@v2
11095
with:
11196
dependency-versions: ${{ matrix.composer-dependency }}
112-
11397
- name: Run PHPUnit
11498
run: composer phpunit -- --no-interaction --do-not-cache-result

Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM php:8.2-cli
2+
3+
RUN \
4+
apt-get update ; \
5+
apt-get install -y unzip ; \
6+
pecl install pcov ; \
7+
docker-php-ext-enable pcov ;
8+
9+
COPY --from=composer:2.4 /usr/bin/composer /usr/local/bin/composer
10+
11+
WORKDIR /usr/local/packages/tmpfile/

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2022 Aleksandr Denisyuk
1+
Copyright (c) 2017 Aleksandr Denisyuk
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
init:
2+
docker build -t tmpfile:8.2 ./
3+
4+
exec:
5+
docker run --name tmpfile --rm --interactive --tty --volume ${PWD}:/usr/local/packages/tmpfile/ tmpfile:8.2 /bin/bash

composer.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,18 @@
4646
},
4747
"scripts": {
4848
"phpunit": "./vendor/bin/phpunit --verbose --colors=always --no-coverage",
49+
"phpunit:clear-cache": "rm ./build/cache/phpunit.cache",
4950
"phpunit-coverage": "./vendor/bin/phpunit --verbose --colors=always --coverage-text",
5051
"phpunit-coverage-html": "./vendor/bin/phpunit --verbose --colors=always --coverage-html ./build/logs/phpunit-coverage/",
5152
"parallel-lint": "./vendor/bin/parallel-lint --colors ./src/ ./tests/",
5253
"php-cs-fixer:fix": "./vendor/bin/php-cs-fixer fix --verbose --ansi --show-progress=dots",
5354
"php-cs-fixer:diff": "./vendor/bin/php-cs-fixer fix --verbose --ansi --dry-run --diff",
55+
"php-cs-fixer:clear-cache": "rm ./build/cache/php-cs-fixer.cache",
5456
"psalm": "./vendor/bin/psalm --show-info=true",
55-
"psalm:set-baseline": "@psalm --set-baseline=./psalm-baseline.xml",
56-
"psalm:update-baseline": "@psalm --update-baseline",
57-
"psalm:ignore-baseline": "@psalm --ignore-baseline",
57+
"psalm:clear-cache": "rm -rf ./build/cache/psalm/",
58+
"psalm:set-baseline": "@psalm --set-baseline=./psalm-baseline.xml --no-cache",
59+
"psalm:update-baseline": "@psalm --update-baseline --no-cache",
60+
"psalm:ignore-baseline": "@psalm --ignore-baseline --no-cache",
5861
"test": [
5962
"@parallel-lint",
6063
"@psalm",

src/TmpFile.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public function __construct()
1414
$this->filename = tempnam(sys_get_temp_dir(), 'php');
1515

1616
if (false === $this->filename) {
17-
throw new \RuntimeException("tempnam() couldn't create a temp file."); // @codeCoverageIgnore
17+
throw new \RuntimeException('tempnam() couldn\'t create a temp file.'); // @codeCoverageIgnore
1818
}
1919

2020
$this->handler = static function (string $filename): void {

tests/TmpFileTest.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
use PHPUnit\Framework\TestCase;
88
use TmpFile\TmpFile;
99

10-
class TmpFileTest extends TestCase
10+
final class TmpFileTest extends TestCase
1111
{
12-
public function testCreateTmpFileWithReturningFilename(): void
12+
public function testCreateTmpFile(): void
1313
{
1414
$tmpFile = new TmpFile();
1515

@@ -25,14 +25,17 @@ public function testCreateTmpFileWithStringableBehavior(): void
2525

2626
public function testRemoveTmpFileOnGarbageCollection(): void
2727
{
28-
$filename = (new TmpFile())->getFilename();
28+
$filename = (static function (): string {
29+
return (new TmpFile())->getFilename();
30+
})();
2931

3032
$this->assertFileDoesNotExist($filename);
3133
}
3234

33-
public function testRemoveTmpFileThroughUnlink(): void
35+
public function testRemoveTmpFileViaUnlink(): void
3436
{
3537
$tmpFile = new TmpFile();
38+
3639
unlink($tmpFile->getFilename());
3740

3841
$this->assertFileDoesNotExist($tmpFile->getFilename());

0 commit comments

Comments
 (0)