From 8792d3b5840ea642eac881a637f8caf80f85c7cc Mon Sep 17 00:00:00 2001 From: Gustavo Freze Date: Mon, 12 Jan 2026 21:44:52 -0300 Subject: [PATCH 01/10] chore: Update CI configuration for PHP 8.5 and add caching for Composer. --- .github/workflows/ci.yml | 41 ++++++++++++++++++++------- Makefile | 60 ++++++++++++++++++++++++++++++---------- composer.json | 2 +- 3 files changed, 77 insertions(+), 26 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 358ac92..ee615a6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,22 +6,31 @@ on: permissions: contents: read -env: - PHP_VERSION: '8.3' - jobs: auto-review: - name: Auto review + name: Auto review (PHP ${{ matrix.php }}) runs-on: ubuntu-latest + strategy: + matrix: + php: [ '8.3', '8.4', '8.5' ] steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Configure PHP uses: shivammathur/setup-php@v2 with: - php-version: ${{ env.PHP_VERSION }} + php-version: ${{ matrix.php }} + + - name: Cache Composer + uses: actions/cache@v4 + with: + path: | + ~/.composer/cache + ~/.cache/composer + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- - name: Install dependencies run: composer update --no-progress --optimize-autoloader @@ -30,17 +39,29 @@ jobs: run: composer review tests: - name: Tests + name: Tests (PHP ${{ matrix.php }}) runs-on: ubuntu-latest + strategy: + matrix: + php: [ '8.3', '8.4', '8.5' ] steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 - - name: Use PHP ${{ env.PHP_VERSION }} + - name: Use PHP ${{ matrix.php }} uses: shivammathur/setup-php@v2 with: - php-version: ${{ env.PHP_VERSION }} + php-version: ${{ matrix.php }} + + - name: Cache Composer + uses: actions/cache@v4 + with: + path: | + ~/.composer/cache + ~/.cache/composer + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- - name: Install dependencies run: composer update --no-progress --optimize-autoloader diff --git a/Makefile b/Makefile index 96ccd27..0dce7bd 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,4 @@ -ifeq ($(OS),Windows_NT) - PWD := $(shell cd) -else - PWD := $(shell pwd -L) -endif - +PWD := $(CURDIR) ARCH := $(shell uname -m) PLATFORM := @@ -11,28 +6,63 @@ ifeq ($(ARCH),arm64) PLATFORM := --platform=linux/amd64 endif -DOCKER_RUN = docker run ${PLATFORM} --rm -it --net=host -v ${PWD}:/app -w /app gustavofreze/php:8.3 +DOCKER_RUN = docker run ${PLATFORM} --rm -it --net=host -v ${PWD}:/app -w /app gustavofreze/php:8.5-alpine -.PHONY: configure test test-file test-no-coverage review show-reports clean +RESET := \033[0m +GREEN := \033[0;32m +YELLOW := \033[0;33m -configure: +.DEFAULT_GOAL := help + +.PHONY: configure +configure: ## Install and optimize Composer dependencies @${DOCKER_RUN} composer update --optimize-autoloader -test: +.PHONY: test +test: ## Run all tests with coverage @${DOCKER_RUN} composer tests -test-file: +.PHONY: test-file +test-file: ## Run tests for a specific file (usage: make test-file FILE=path/to/file) @${DOCKER_RUN} composer test-file ${FILE} -test-no-coverage: +.PHONY: test-no-coverage +test-no-coverage: ## Run all tests without coverage @${DOCKER_RUN} composer tests-no-coverage -review: +.PHONY: review +review: ## Run code review/static analysis @${DOCKER_RUN} composer review -show-reports: +.PHONY: show-reports +show-reports: ## Open coverage and mutation reports in browser @sensible-browser report/coverage/coverage-html/index.html report/coverage/mutation-report.html -clean: +.PHONY: clean +clean: ## Clean generated files and reset permissions @sudo chown -R ${USER}:${USER} ${PWD} @rm -rf report vendor .phpunit.cache *.lock + +.PHONY: help +help: ## Display this help message + @echo "Usage: make [target]" + @echo "" + @echo "$$(printf '$(GREEN)')Setup$$(printf '$(RESET)')" + @grep -E '^(configure):.*?## .*$$' $(MAKEFILE_LIST) \ + | awk 'BEGIN {FS = ":.*? ## "}; {printf "$(YELLOW)%-25s$(RESET) %s\n", $$1, $$2}' + @echo "" + @echo "$$(printf '$(GREEN)')Testing$$(printf '$(RESET)')" + @grep -E '^(test|test-file|test-no-coverage):.*?## .*$$' $(MAKEFILE_LIST) \ + | awk 'BEGIN {FS = ":.*?## "}; {printf "$(YELLOW)%-25s$(RESET) %s\n", $$1, $$2}' + @echo "" + @echo "$$(printf '$(GREEN)')Quality$$(printf '$(RESET)')" + @grep -E '^(review):.*?## .*$$' $(MAKEFILE_LIST) \ + | awk 'BEGIN {FS = ":.*?## "}; {printf "$(YELLOW)%-25s$(RESET) %s\n", $$1, $$2}' + @echo "" + @echo "$$(printf '$(GREEN)')Reports$$(printf '$(RESET)')" + @grep -E '^(show-reports):.*?## .*$$' $(MAKEFILE_LIST) \ + | awk 'BEGIN {FS = ":.*?## "}; {printf "$(YELLOW)%-25s$(RESET) %s\n", $$1, $$2}' + @echo "" + @echo "$$(printf '$(GREEN)')Cleanup$$(printf '$(RESET)')" + @grep -E '^(clean):.*?## .*$$' $(MAKEFILE_LIST) \ + | awk 'BEGIN {FS = ":.*?## "}; {printf "$(YELLOW)%-25s$(RESET) %s\n", $$1, $$2}' diff --git a/composer.json b/composer.json index d3d71df..7bdf848 100644 --- a/composer.json +++ b/composer.json @@ -40,7 +40,7 @@ } }, "require": { - "php": "^8.3", + "php": "^8.5", "ext-bcmath": "*" }, "require-dev": { From c05e094e84aa64f411070520d112c0e1da0aea39 Mon Sep 17 00:00:00 2001 From: Gustavo Freze Date: Mon, 12 Jan 2026 21:47:50 -0300 Subject: [PATCH 02/10] chore: Update CI configuration for PHP 8.5 and add caching for Composer. --- .github/workflows/ci.yml | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ee615a6..0d12596 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,13 +6,13 @@ on: permissions: contents: read +env: + PHP_VERSION: '8.5' + jobs: auto-review: - name: Auto review (PHP ${{ matrix.php }}) + name: Auto review (PHP ${{ env.PHP_VERSION }}) runs-on: ubuntu-latest - strategy: - matrix: - php: [ '8.3', '8.4', '8.5' ] steps: - name: Checkout @@ -21,7 +21,7 @@ jobs: - name: Configure PHP uses: shivammathur/setup-php@v2 with: - php-version: ${{ matrix.php }} + php-version: ${{ env.PHP_VERSION }} - name: Cache Composer uses: actions/cache@v4 @@ -39,20 +39,17 @@ jobs: run: composer review tests: - name: Tests (PHP ${{ matrix.php }}) + name: Tests (PHP ${{ env.PHP_VERSION }}) runs-on: ubuntu-latest - strategy: - matrix: - php: [ '8.3', '8.4', '8.5' ] steps: - name: Checkout uses: actions/checkout@v6 - - name: Use PHP ${{ matrix.php }} + - name: Configure PHP uses: shivammathur/setup-php@v2 with: - php-version: ${{ matrix.php }} + php-version: ${{ env.PHP_VERSION }} - name: Cache Composer uses: actions/cache@v4 From 348af75a8c5f15b0e9bbb1febfe408575457c58a Mon Sep 17 00:00:00 2001 From: Gustavo Freze Date: Mon, 12 Jan 2026 21:53:22 -0300 Subject: [PATCH 03/10] chore: Update CI configuration for PHP 8.5 and add caching for Composer. --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0d12596..52c34e6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ env: jobs: auto-review: - name: Auto review (PHP ${{ env.PHP_VERSION }}) + name: Auto review runs-on: ubuntu-latest steps: @@ -23,7 +23,7 @@ jobs: with: php-version: ${{ env.PHP_VERSION }} - - name: Cache Composer + - name: Cache dependencies uses: actions/cache@v4 with: path: | @@ -39,7 +39,7 @@ jobs: run: composer review tests: - name: Tests (PHP ${{ env.PHP_VERSION }}) + name: Tests runs-on: ubuntu-latest steps: @@ -51,7 +51,7 @@ jobs: with: php-version: ${{ env.PHP_VERSION }} - - name: Cache Composer + - name: Cache dependencies uses: actions/cache@v4 with: path: | From 72c590a088a663675237c19c819cef77a0ebb214 Mon Sep 17 00:00:00 2001 From: Gustavo Freze Date: Mon, 12 Jan 2026 21:55:25 -0300 Subject: [PATCH 04/10] chore: Update CI configuration for PHP 8.5 and add caching for Composer. --- .github/workflows/ci.yml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 52c34e6..f55fe88 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ env: jobs: auto-review: - name: Auto review + name: Auto review runs-on: ubuntu-latest steps: @@ -29,17 +29,19 @@ jobs: path: | ~/.composer/cache ~/.cache/composer + vendor key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer- + restore-keys: | + ${{ runner.os }}-composer- - name: Install dependencies - run: composer update --no-progress --optimize-autoloader + run: composer install --no-progress --optimize-autoloader --prefer-dist --no-interaction - name: Run review run: composer review tests: - name: Tests + name: Tests runs-on: ubuntu-latest steps: @@ -57,11 +59,13 @@ jobs: path: | ~/.composer/cache ~/.cache/composer + vendor key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer- + restore-keys: | + ${{ runner.os }}-composer- - name: Install dependencies - run: composer update --no-progress --optimize-autoloader + run: composer install --no-progress --optimize-autoloader --prefer-dist --no-interaction - name: Run tests run: composer tests From 8eb9f09e3b95be48b2d212ccd2de244a57844c58 Mon Sep 17 00:00:00 2001 From: Gustavo Freze Date: Mon, 12 Jan 2026 21:59:59 -0300 Subject: [PATCH 05/10] chore: Update CI configuration for PHP 8.5 and add caching for Composer. --- .github/workflows/ci.yml | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f55fe88..db0b310 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ env: jobs: auto-review: - name: Auto review + name: Auto review runs-on: ubuntu-latest steps: @@ -23,17 +23,6 @@ jobs: with: php-version: ${{ env.PHP_VERSION }} - - name: Cache dependencies - uses: actions/cache@v4 - with: - path: | - ~/.composer/cache - ~/.cache/composer - vendor - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-composer- - - name: Install dependencies run: composer install --no-progress --optimize-autoloader --prefer-dist --no-interaction @@ -41,29 +30,18 @@ jobs: run: composer review tests: - name: Tests + name: Tests runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v6 - - name: Configure PHP + - name: Use PHP ${{ env.PHP_VERSION }} uses: shivammathur/setup-php@v2 with: php-version: ${{ env.PHP_VERSION }} - - name: Cache dependencies - uses: actions/cache@v4 - with: - path: | - ~/.composer/cache - ~/.cache/composer - vendor - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-composer- - - name: Install dependencies run: composer install --no-progress --optimize-autoloader --prefer-dist --no-interaction From 7f577ce6763175679c45711610c3f779499dead4 Mon Sep 17 00:00:00 2001 From: Gustavo Freze Date: Mon, 12 Jan 2026 22:06:19 -0300 Subject: [PATCH 06/10] chore: Update CI configuration for PHP 8.5 and add caching for Composer. --- .github/workflows/ci.yml | 51 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index db0b310..a7a6e31 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,8 +10,8 @@ env: PHP_VERSION: '8.5' jobs: - auto-review: - name: Auto review + build: + name: Build runs-on: ubuntu-latest steps: @@ -22,28 +22,69 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ env.PHP_VERSION }} + extensions: bcmath + tools: composer:2 + + - name: Validate composer.json + run: composer validate --no-interaction - name: Install dependencies run: composer install --no-progress --optimize-autoloader --prefer-dist --no-interaction + - name: Upload vendor and composer.lock as artifact + uses: actions/upload-artifact@v4 + with: + name: vendor-artifact + path: | + vendor + composer.lock + + auto-review: + name: Auto review + runs-on: ubuntu-latest + needs: build + + steps: + - name: Checkout + uses: actions/checkout@v6 + + - name: Configure PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ env.PHP_VERSION }} + extensions: bcmath + tools: composer:2 + + - name: Download vendor artifact from build + uses: actions/download-artifact@v4 + with: + name: vendor-artifact + path: . + - name: Run review run: composer review tests: name: Tests runs-on: ubuntu-latest + needs: auto-review steps: - name: Checkout uses: actions/checkout@v6 - - name: Use PHP ${{ env.PHP_VERSION }} + - name: Configure PHP uses: shivammathur/setup-php@v2 with: php-version: ${{ env.PHP_VERSION }} + extensions: bcmath + tools: composer:2 - - name: Install dependencies - run: composer install --no-progress --optimize-autoloader --prefer-dist --no-interaction + - name: Download vendor artifact from build + uses: actions/download-artifact@v4 + with: + name: vendor-artifact + path: . - name: Run tests run: composer tests From 37ea68ef167a55c0eadca219811cca0e7926e709 Mon Sep 17 00:00:00 2001 From: Gustavo Freze Date: Mon, 12 Jan 2026 22:13:59 -0300 Subject: [PATCH 07/10] chore: Update CI configuration for PHP 8.5 and add caching for Composer. --- .github/workflows/ci.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a7a6e31..c2149a4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,6 +61,12 @@ jobs: name: vendor-artifact path: . + - name: Make vendor binaries executable + run: | + if [ -d vendor/bin ]; then + chmod +x vendor/bin/* || true + fi + - name: Run review run: composer review @@ -86,5 +92,11 @@ jobs: name: vendor-artifact path: . + - name: Make vendor binaries executable + run: | + if [ -d vendor/bin ]; then + chmod +x vendor/bin/* || true + fi + - name: Run tests run: composer tests From bd662573e2e7494bd24eca9e9ccfb0bf21267785 Mon Sep 17 00:00:00 2001 From: Gustavo Freze Date: Mon, 12 Jan 2026 22:16:15 -0300 Subject: [PATCH 08/10] chore: Update CI configuration for PHP 8.5 and add caching for Composer. --- .github/workflows/ci.yml | 12 ------------ composer.json | 14 +++++++------- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c2149a4..a7a6e31 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,12 +61,6 @@ jobs: name: vendor-artifact path: . - - name: Make vendor binaries executable - run: | - if [ -d vendor/bin ]; then - chmod +x vendor/bin/* || true - fi - - name: Run review run: composer review @@ -92,11 +86,5 @@ jobs: name: vendor-artifact path: . - - name: Make vendor binaries executable - run: | - if [ -d vendor/bin ]; then - chmod +x vendor/bin/* || true - fi - - name: Run tests run: composer tests diff --git a/composer.json b/composer.json index 7bdf848..d89ee31 100644 --- a/composer.json +++ b/composer.json @@ -54,13 +54,13 @@ "ext-bcmath": "Enables the extension which is an interface to the GNU implementation as a Basic Calculator utility library." }, "scripts": { - "test": "phpunit -d memory_limit=2G --configuration phpunit.xml tests", - "phpcs": "phpcs --standard=PSR12 --extensions=php ./src", - "phpmd": "phpmd ./src text phpmd.xml --suffixes php --ignore-violations-on-exit", - "phpstan": "phpstan analyse -c phpstan.neon.dist --quiet --no-progress", - "test-file": "phpunit --configuration phpunit.xml --no-coverage --filter", - "mutation-test": "infection --threads=max --logger-html=report/coverage/mutation-report.html --coverage=report/coverage", - "test-no-coverage": "phpunit --configuration phpunit.xml --no-coverage tests", + "test": "php -d memory_limit=2G ./vendor/bin/phpunit --configuration phpunit.xml tests", + "phpcs": "php ./vendor/bin/phpcs --standard=PSR12 --extensions=php ./src", + "phpmd": "php ./vendor/bin/phpmd ./src text phpmd.xml --suffixes php --ignore-violations-on-exit", + "phpstan": "php ./vendor/bin/phpstan analyse -c phpstan.neon.dist --quiet --no-progress", + "test-file": "php ./vendor/bin/phpunit --configuration phpunit.xml --no-coverage --filter", + "mutation-test": "php ./vendor/bin/infection --threads=max --logger-html=report/coverage/mutation-report.html --coverage=report/coverage", + "test-no-coverage": "php ./vendor/bin/phpunit --configuration phpunit.xml --no-coverage tests", "review": [ "@phpcs", "@phpmd", From f17fd14d7223c42658245c04128ae0654330f4b1 Mon Sep 17 00:00:00 2001 From: Gustavo Freze Date: Mon, 12 Jan 2026 22:49:23 -0300 Subject: [PATCH 09/10] chore: Update CI configuration for PHP 8.5 and add caching for Composer. --- .gitattributes | 1 - composer.json | 7 ++---- phpmd.xml | 61 -------------------------------------------------- 3 files changed, 2 insertions(+), 67 deletions(-) delete mode 100644 phpmd.xml diff --git a/.gitattributes b/.gitattributes index 22aac70..8c85471 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4,7 +4,6 @@ /LICENSE export-ignore /Makefile export-ignore /README.md export-ignore -/phpmd.xml export-ignore /phpunit.xml export-ignore /phpstan.neon.dist export-ignore /infection.json.dist export-ignore diff --git a/composer.json b/composer.json index d89ee31..1b1ad02 100644 --- a/composer.json +++ b/composer.json @@ -44,11 +44,10 @@ "ext-bcmath": "*" }, "require-dev": { - "phpmd/phpmd": "^2.15", "phpunit/phpunit": "^11.5", "phpstan/phpstan": "^1.12", - "infection/infection": "^0.29", - "squizlabs/php_codesniffer": "^3.11" + "infection/infection": "^0.32", + "squizlabs/php_codesniffer": "^3.13" }, "suggest": { "ext-bcmath": "Enables the extension which is an interface to the GNU implementation as a Basic Calculator utility library." @@ -56,14 +55,12 @@ "scripts": { "test": "php -d memory_limit=2G ./vendor/bin/phpunit --configuration phpunit.xml tests", "phpcs": "php ./vendor/bin/phpcs --standard=PSR12 --extensions=php ./src", - "phpmd": "php ./vendor/bin/phpmd ./src text phpmd.xml --suffixes php --ignore-violations-on-exit", "phpstan": "php ./vendor/bin/phpstan analyse -c phpstan.neon.dist --quiet --no-progress", "test-file": "php ./vendor/bin/phpunit --configuration phpunit.xml --no-coverage --filter", "mutation-test": "php ./vendor/bin/infection --threads=max --logger-html=report/coverage/mutation-report.html --coverage=report/coverage", "test-no-coverage": "php ./vendor/bin/phpunit --configuration phpunit.xml --no-coverage tests", "review": [ "@phpcs", - "@phpmd", "@phpstan" ], "tests": [ diff --git a/phpmd.xml b/phpmd.xml deleted file mode 100644 index 4d81dcd..0000000 --- a/phpmd.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - PHPMD Custom rules - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From c8058eba5a021b6bba07d91e2f8784e3e866339b Mon Sep 17 00:00:00 2001 From: Gustavo Freze Date: Mon, 12 Jan 2026 22:53:03 -0300 Subject: [PATCH 10/10] chore: Update CI configuration for PHP 8.5 and add caching for Composer. --- infection.json.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/infection.json.dist b/infection.json.dist index 8bf7f17..94d059a 100644 --- a/infection.json.dist +++ b/infection.json.dist @@ -18,6 +18,7 @@ "mutators": { "@default": true, "UnwrapLtrim": false, + "ReturnRemoval": false, "DecrementInteger": false }, "minCoveredMsi": 100,