diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3ea5207..579c8ae 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.2' + php-version: '8.3' coverage: none - name: Install dependencies uses: ramsey/composer-install@v2 @@ -42,13 +42,29 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.2' + php-version: '8.3' coverage: none - name: Install dependencies uses: ramsey/composer-install@v2 - name: Run Psalm run: composer psalm -- --show-info=false --no-progress --no-suggestions --no-cache + rector: + name: 'Rector' + runs-on: 'ubuntu-latest' + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.3' + coverage: none + - name: Install dependencies + uses: ramsey/composer-install@v2 + - name: Run Rector + run: composer rector:diff -- --no-progress-bar --clear-cache + php-cs-fixer: name: 'PHPCsFixer' runs-on: 'ubuntu-latest' @@ -58,7 +74,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.2' + php-version: '8.3' coverage: none - name: Install dependencies uses: ramsey/composer-install@v2 @@ -67,7 +83,7 @@ jobs: phpunit: name: 'PHPUnit' - needs: ['parallel-lint', 'psalm', 'php-cs-fixer'] + needs: ['parallel-lint', 'psalm', 'rector', 'php-cs-fixer'] runs-on: ${{ matrix.operating-system }} strategy: fail-fast: false @@ -79,6 +95,7 @@ jobs: - '8.0' - '8.1' - '8.2' + - '8.3' composer-dependency: - 'lowest' - 'highest' diff --git a/Dockerfile b/Dockerfile index fa00dec..04cbff0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,24 @@ -FROM php:8.2-cli +FROM php:8.3-cli-trixie -RUN \ +RUN set -eux ; \ apt-get update ; \ - apt-get install -y unzip ; \ + apt-get install -y --no-install-recommends \ + git \ + unzip \ + zip \ + libzip-dev \ + pkg-config \ + ca-certificates ; \ + rm -rf /var/lib/apt/lists/* ; + +RUN set -eux ; \ + docker-php-ext-configure zip ; \ + docker-php-ext-install -j"$(nproc)" zip ; \ pecl install pcov ; \ docker-php-ext-enable pcov ; -COPY --from=composer:2.4 /usr/bin/composer /usr/local/bin/composer +COPY --from=composer/composer:2.9 /usr/bin/composer /usr/local/bin/composer + +WORKDIR /usr/local/packages/tmpfile -WORKDIR /usr/local/packages/tmpfile/ +CMD ["php", "-v"] diff --git a/Makefile b/Makefile index c4262d8..9c34245 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ init: - docker build -t tmpfile:8.2 ./ + docker build -t tmpfile:php8.3-cli-trixie ./ exec: - docker run --name tmpfile --rm --interactive --tty --volume ${PWD}:/usr/local/packages/tmpfile/ tmpfile:8.2 /bin/bash + docker run --name tmpfile --rm --interactive --tty --volume ${PWD}:/usr/local/packages/tmpfile/ tmpfile:php8.3-cli-trixie /bin/bash diff --git a/composer.json b/composer.json index 875e04e..9e0a615 100644 --- a/composer.json +++ b/composer.json @@ -12,8 +12,8 @@ "authors": [ { "name": "Aleksandr Denisyuk", - "email": "a@denisyuk.by", - "homepage": "https://denisyuk.by/", + "email": "aleksandr@denisyuk.email", + "homepage": "https://denisyuk.website/", "role": "Developer" } ], @@ -24,12 +24,13 @@ "php": "^8.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.10", + "friendsofphp/php-cs-fixer": "^3.91", "php-parallel-lint/php-console-highlighter": "^1.0", - "php-parallel-lint/php-parallel-lint": "^1.3", - "phpunit/phpunit": "^9.5", - "psalm/plugin-phpunit": "^0.17.0", - "vimeo/psalm": "^4.26" + "php-parallel-lint/php-parallel-lint": "^1.4", + "phpunit/phpunit": "^9.6", + "psalm/plugin-phpunit": "^0.18", + "rector/rector": "^2.2", + "vimeo/psalm": "^5.26" }, "suggest": { "denisyukphp/tmpfile-manager": "Allows more advanced creating and removing temp files." @@ -45,22 +46,26 @@ } }, "scripts": { - "phpunit": "./vendor/bin/phpunit --verbose --colors=always --no-coverage", - "phpunit:clear-cache": "rm ./build/cache/phpunit.cache", - "phpunit-coverage": "./vendor/bin/phpunit --verbose --colors=always --coverage-text", - "phpunit-coverage-html": "./vendor/bin/phpunit --verbose --colors=always --coverage-html ./build/logs/phpunit-coverage/", "parallel-lint": "./vendor/bin/parallel-lint --colors ./src/ ./tests/", - "php-cs-fixer:fix": "./vendor/bin/php-cs-fixer fix --verbose --ansi --show-progress=dots", - "php-cs-fixer:diff": "./vendor/bin/php-cs-fixer fix --verbose --ansi --dry-run --diff", - "php-cs-fixer:clear-cache": "rm ./build/cache/php-cs-fixer.cache", "psalm": "./vendor/bin/psalm --show-info=true", "psalm:clear-cache": "rm -rf ./build/cache/psalm/", "psalm:set-baseline": "@psalm --set-baseline=./psalm-baseline.xml --no-cache", "psalm:update-baseline": "@psalm --update-baseline --no-cache", "psalm:ignore-baseline": "@psalm --ignore-baseline --no-cache", + "rector:fix": "./vendor/bin/rector process", + "rector:diff": "./vendor/bin/rector process --dry-run", + "rector:clear-cache": "rm -rf ./build/cache/rector/", + "php-cs-fixer:fix": "./vendor/bin/php-cs-fixer fix --verbose --ansi --show-progress=dots", + "php-cs-fixer:diff": "./vendor/bin/php-cs-fixer fix --verbose --ansi --dry-run --diff", + "php-cs-fixer:clear-cache": "rm ./build/cache/php-cs-fixer.cache", + "phpunit": "./vendor/bin/phpunit --verbose --colors=always --no-coverage", + "phpunit:clear-cache": "rm ./build/cache/phpunit.cache", + "phpunit-coverage": "./vendor/bin/phpunit --verbose --colors=always --coverage-text", + "phpunit-coverage-html": "./vendor/bin/phpunit --verbose --colors=always --coverage-html ./build/logs/phpunit-coverage/", "test": [ "@parallel-lint", "@psalm", + "@rector:diff", "@php-cs-fixer:diff", "@phpunit" ] diff --git a/rector.php b/rector.php new file mode 100644 index 0000000..160b270 --- /dev/null +++ b/rector.php @@ -0,0 +1,26 @@ +withCache( + cacheDirectory: __DIR__.'/build/cache/rector', + cacheClass: FileCacheStorage::class, + ) + ->withPaths([ + __DIR__.'/src', + __DIR__.'/tests', + ]) + ->withPhpSets( + php80: true, + ) + ->withSets([ + SetList::DEAD_CODE, + SetList::PRIVATIZATION, + SetList::TYPE_DECLARATION, + ]) +; diff --git a/src/TmpFile.php b/src/TmpFile.php index b3d4adc..617f73b 100644 --- a/src/TmpFile.php +++ b/src/TmpFile.php @@ -4,7 +4,7 @@ namespace TmpFile; -final class TmpFile implements TmpFileInterface +final class TmpFile implements \Stringable, TmpFileInterface { private string $filename; private \Closure $handler; diff --git a/tests/TmpFileTest.php b/tests/TmpFileTest.php index a6e3f4c..d7550e6 100644 --- a/tests/TmpFileTest.php +++ b/tests/TmpFileTest.php @@ -25,9 +25,7 @@ public function testCreateTmpFileWithStringableBehavior(): void public function testRemoveTmpFileOnGarbageCollection(): void { - $filename = (static function (): string { - return (new TmpFile())->getFilename(); - })(); + $filename = (static fn (): string => (new TmpFile())->getFilename())(); $this->assertFileDoesNotExist($filename); }